use of org.eclipse.sirius.components.trees.TreeItem in project sirius-components by eclipse-sirius.
the class TreeRenderer method renderTreeItem.
private TreeItem renderTreeItem(VariableManager treeItemVariableManager) {
String id = this.treeDescription.getTreeItemIdProvider().apply(treeItemVariableManager);
String kind = this.treeDescription.getKindProvider().apply(treeItemVariableManager);
String label = this.treeDescription.getLabelProvider().apply(treeItemVariableManager);
boolean editable = this.treeDescription.getEditableProvider().apply(treeItemVariableManager);
boolean deletable = this.treeDescription.getDeletableProvider().apply(treeItemVariableManager);
String imageURL = this.treeDescription.getImageURLProvider().apply(treeItemVariableManager);
Boolean hasChildren = this.treeDescription.getHasChildrenProvider().apply(treeItemVariableManager);
List<?> children = this.treeDescription.getChildrenProvider().apply(treeItemVariableManager);
List<TreeItem> childrenTreeItems = new ArrayList<>(children.size());
boolean expanded = !children.isEmpty();
for (Object child : children) {
VariableManager childVariableManager = treeItemVariableManager.createChild();
childVariableManager.put(VariableManager.SELF, child);
childrenTreeItems.add(this.renderTreeItem(childVariableManager));
}
// @formatter:off
return TreeItem.newTreeItem(id).kind(kind).label(label).editable(editable).deletable(deletable).imageURL(imageURL).children(childrenTreeItems).hasChildren(hasChildren).expanded(expanded).build();
// @formatter:on
}
use of org.eclipse.sirius.components.trees.TreeItem in project sirius-components by eclipse-sirius.
the class TreeRenderer method render.
public Tree render() {
String treeId = this.treeDescription.getIdProvider().apply(this.variableManager);
String label = this.treeDescription.getLabelProvider().apply(this.variableManager);
List<?> rootElements = this.treeDescription.getElementsProvider().apply(this.variableManager);
List<TreeItem> childrenItems = new ArrayList<>(rootElements.size());
for (Object rootElement : rootElements) {
VariableManager rootElementVariableManager = this.variableManager.createChild();
rootElementVariableManager.put(VariableManager.SELF, rootElement);
childrenItems.add(this.renderTreeItem(rootElementVariableManager));
}
// @formatter:off
return Tree.newTree(treeId).descriptionId(this.treeDescription.getId()).label(label).children(childrenItems).build();
// @formatter:on
}
Aggregations