Search in sources :

Example 1 with FSTreeItem

use of org.uberfire.ext.widgets.core.client.tree.FSTreeItem in project kie-wb-common by kiegroup.

the class TreeNavigator method loadRoots.

private FSTreeItem loadRoots(final List<FolderItem> segments, final Map<FolderItem, List<FolderItem>> siblings) {
    FSTreeItem parent = null;
    for (final FolderItem segment : segments) {
        FSTreeItem item;
        if (tree.isEmpty()) {
            item = new FSTreeItem(FSTreeItem.FSType.FOLDER, segment.getFileName().replaceAll(" ", "\u00a0"));
            item.setUserObject(segment);
            tree.addItem(item);
            parent = item;
        } else {
            if (parent == null) {
                parent = findItemInTree(segment);
            } else {
                item = findItemInTree(segment);
                if (item == null) {
                    item = loadSiblings(segment, new TreeNavigatorItemImpl(parent), siblings);
                    if (item != null) {
                        item.setUserObject(segment);
                    }
                } else if (needsLoading(item)) {
                    item.getChild(0).getElement().getStyle().setDisplay(Style.Display.NONE);
                }
                parent = item;
            }
        }
    }
    return parent;
}
Also used : FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) FSTreeItem(org.uberfire.ext.widgets.core.client.tree.FSTreeItem)

Example 2 with FSTreeItem

use of org.uberfire.ext.widgets.core.client.tree.FSTreeItem in project kie-wb-common by kiegroup.

the class TreeNavigator method loadContent.

@Override
public void loadContent(final FolderListing content, final Map<FolderItem, List<FolderItem>> siblings) {
    if (content == null || content.getItem() == null) {
        clear();
        return;
    }
    if (content.equals(activeContent)) {
        if (tree.getSelectedItem() != null) {
            tree.getSelectedItem().setState(TreeItem.State.OPEN, true, false);
        }
        return;
    }
    this.activeContent = content;
    FSTreeItem item = null;
    if (!tree.isEmpty()) {
        item = findItemInTree(content.getItem());
    }
    if (item == null) {
        if (content.getSegments().isEmpty()) {
            final FolderItem rootItem = content.getItem();
            item = new FSTreeItem(FSTreeItem.FSType.FOLDER, rootItem.getFileName().replaceAll(" ", "\u00a0"));
            tree.addItem(item);
            item.setUserObject(rootItem);
        } else {
            final FSTreeItem parent = loadRoots(content.getSegments(), siblings);
            if (parent != null) {
                item = loadSiblings(content.getItem(), new TreeNavigatorItemImpl(parent), siblings);
                if (item != null) {
                    item.setUserObject(content.getItem());
                }
            }
        }
    }
    if (item != null) {
        item.setState(TreeItem.State.OPEN, true, false);
        tree.setSelectedItem(item);
        item.removeItems();
        loadContent(new TreeNavigatorItemImpl(item), content);
    }
}
Also used : FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) FSTreeItem(org.uberfire.ext.widgets.core.client.tree.FSTreeItem)

Aggregations

FolderItem (org.kie.workbench.common.screens.explorer.model.FolderItem)2 FSTreeItem (org.uberfire.ext.widgets.core.client.tree.FSTreeItem)2