Search in sources :

Example 6 with TreeItem

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
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) TreeItem(org.eclipse.sirius.components.trees.TreeItem) ArrayList(java.util.ArrayList)

Example 7 with TreeItem

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
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) TreeItem(org.eclipse.sirius.components.trees.TreeItem) ArrayList(java.util.ArrayList)

Aggregations

TreeItem (org.eclipse.sirius.components.trees.TreeItem)7 VariableManager (org.eclipse.sirius.components.representations.VariableManager)6 Failure (org.eclipse.sirius.components.representations.Failure)5 ArrayList (java.util.ArrayList)4 TreeDescription (org.eclipse.sirius.components.trees.description.TreeDescription)4 List (java.util.List)3 Objects (java.util.Objects)3 Optional (java.util.Optional)3 Collectors (java.util.stream.Collectors)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)3 EditingContext (org.eclipse.sirius.components.emf.services.EditingContext)3 IStatus (org.eclipse.sirius.components.representations.IStatus)3 Success (org.eclipse.sirius.components.representations.Success)3 IDeleteTreeItemHandler (org.eclipse.sirius.web.services.explorer.api.IDeleteTreeItemHandler)3 Service (org.springframework.stereotype.Service)3 UUID (java.util.UUID)2 Predicate (java.util.function.Predicate)2 EObject (org.eclipse.emf.ecore.EObject)2 EditingDomain (org.eclipse.emf.edit.domain.EditingDomain)2