Example usage for com.google.gwt.user.client.ui TreeItem getChild

List of usage examples for com.google.gwt.user.client.ui TreeItem getChild

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui TreeItem getChild.

Prototype

public TreeItem getChild(int index) 

Source Link

Document

Gets the child at the specified index.

Usage

From source file:org.pentaho.gwt.widgets.client.filechooser.TreeBuilder.java

License:Open Source License

private static void buildSolutionTree(TreeItem parentTreeItem, RepositoryFileTree fileTree,
        boolean showHiddenFiles, boolean showLocalizedFileNames, FileFilter filter) {
    for (RepositoryFileTree repositoryFileTree : fileTree.getChildren()) {
        RepositoryFile file = repositoryFileTree.getFile();
        boolean isVisible = !file.isHidden();
        boolean isDirectory = file.isFolder();

        if (isVisible || showHiddenFiles) {
            String fileTitle = file.getTitle(), fileName = file.getName();

            if (filter.accept(fileName, isDirectory, (isVisible || showHiddenFiles)) == false) {
                continue;
            }// w ww  .j ava2  s  .c om

            TreeItem childTreeItem = new TreeItem();
            // TODO There is no concept of filename and a localized filename in the repository. Do we need this ?
            if (showLocalizedFileNames) {
                childTreeItem.setText(fileTitle);
                childTreeItem.setTitle(fileTitle);
            } else {
                childTreeItem.setText(fileTitle);
                childTreeItem.setTitle(fileTitle);
            }

            // ElementUtils.preventTextSelection(childTreeItem.getElement());

            childTreeItem.setUserObject(repositoryFileTree);

            // find the spot in the parentTreeItem to insert the node (based on showLocalizedFileNames)
            if (parentTreeItem.getChildCount() == 0) {
                parentTreeItem.addItem(childTreeItem);
            } else {
                // this does sorting
                boolean inserted = false;
                for (int j = 0; j < parentTreeItem.getChildCount(); j++) {
                    TreeItem kid = (TreeItem) parentTreeItem.getChild(j);
                    if (showLocalizedFileNames) {
                        if (childTreeItem.getText().compareTo(kid.getText()) <= 0) {
                            // leave all items ahead of the insert point
                            // remove all items between the insert point and the end
                            // add the new item
                            // add back all removed items
                            List<TreeItem> removedItems = new ArrayList<TreeItem>();
                            for (int x = j; x < parentTreeItem.getChildCount(); x++) {
                                TreeItem removedItem = (TreeItem) parentTreeItem.getChild(x);
                                removedItems.add(removedItem);
                            }
                            for (TreeItem removedItem : removedItems) {
                                parentTreeItem.removeItem(removedItem);
                            }
                            parentTreeItem.addItem(childTreeItem);
                            inserted = true;
                            for (TreeItem removedItem : removedItems) {
                                parentTreeItem.addItem(removedItem);
                            }
                            break;
                        }
                    } else {
                        parentTreeItem.addItem(childTreeItem);
                    }
                }
                if (!inserted) {
                    parentTreeItem.addItem(childTreeItem);
                }
            }

            if (isDirectory) {
                buildSolutionTree(childTreeItem, repositoryFileTree, showHiddenFiles, showLocalizedFileNames,
                        filter);
            }
        }
    }
}

From source file:org.pentaho.mantle.client.dialogs.folderchooser.FolderTree.java

License:Open Source License

private TreeItem findSelectedItem(TreeItem item, int x, int y) {
    if (item == null) {
        for (int i = 0; i < getItemCount(); i++) {
            TreeItem selected = findSelectedItem(getItem(i), x, y);
            if (selected != null) {
                return selected;
            }/*from   w w  w .j  ava 2s  . c o m*/
        }
        return null;
    }

    for (int i = 0; i < item.getChildCount(); i++) {
        TreeItem selected = findSelectedItem(item.getChild(i), x, y);
        if (selected != null) {
            return selected;
        }
    }

    if (x >= item.getAbsoluteLeft() && x <= item.getAbsoluteLeft() + item.getOffsetWidth()
            && y >= item.getAbsoluteTop() && y <= item.getAbsoluteTop() + item.getOffsetHeight()) {
        return item;
    }
    return null;
}

From source file:org.pentaho.mantle.client.dialogs.folderchooser.FolderTree.java

License:Open Source License

private void selectFromList(List<TreeItem> parents) {
    TreeItem pathDown = null;
    for (int i = 0; i < parents.size(); i++) {
        TreeItem parent = parents.get(i);
        if (pathDown == null) {
            for (int j = 0; j < getItemCount(); j++) {
                TreeItem possibleItem = getItem(j);
                if ((possibleItem instanceof FolderTreeItem) && (parent instanceof FolderTreeItem)
                        && ((FolderTreeItem) parent).getFileName()
                                .equals(((FolderTreeItem) possibleItem).getFileName())) {
                    pathDown = possibleItem;
                    pathDown.setState(true, true);
                    pathDown.setSelected(true);
                    break;
                }//  w ww  .  j a  v a2 s . c  om
            }
        } else {
            for (int j = 0; j < pathDown.getChildCount(); j++) {
                TreeItem possibleItem = pathDown.getChild(j);
                if ((possibleItem instanceof FolderTreeItem) && (parent instanceof FolderTreeItem)
                        && ((FolderTreeItem) parent).getFileName()
                                .equals(((FolderTreeItem) possibleItem).getFileName())) {
                    pathDown = possibleItem;
                    pathDown.setState(true, true);
                    break;
                }
            }
        }
    }
    if (pathDown != null) {
        setSelectedItem(pathDown);
        pathDown.setState(true, true);
    }
}

From source file:org.pentaho.mantle.client.solutionbrowser.tree.SolutionTree.java

License:Open Source License

private void selectFromList(ArrayList<TreeItem> parents) {
    TreeItem pathDown = null;
    for (int i = 0; i < parents.size(); i++) {
        TreeItem parent = parents.get(i);
        if (pathDown == null) {
            for (int j = 0; j < getItemCount(); j++) {
                TreeItem possibleItem = getItem(j);
                if ((possibleItem instanceof FileTreeItem) && (parent instanceof FileTreeItem)
                        && ((FileTreeItem) parent).getFileName()
                                .equals(((FileTreeItem) possibleItem).getFileName())) {
                    pathDown = possibleItem;
                    pathDown.setState(true, true);
                    pathDown.setSelected(true);
                    break;
                }/*from   ww w . j  a v a  2 s .  c  o m*/
            }
        } else {
            for (int j = 0; j < pathDown.getChildCount(); j++) {
                TreeItem possibleItem = pathDown.getChild(j);
                if ((possibleItem instanceof FileTreeItem) && (parent instanceof FileTreeItem)
                        && ((FileTreeItem) parent).getFileName()
                                .equals(((FileTreeItem) possibleItem).getFileName())) {
                    pathDown = possibleItem;
                    pathDown.setState(true, true);
                    break;
                }
            }
        }
    }
    if (pathDown != null) {
        setSelectedItem(pathDown);
        pathDown.setState(true, true);
    }
}

From source file:org.pentaho.pat.client.ui.panels.windows.DimensionMenu.java

License:Open Source License

private final void searchTreeItems(final TreeItem item, final MemberSelectionLabel source, final int mode) {

    if (Arrays.equals(getFullPath(item), source.getFullPath())) {
        ((MemberSelectionLabel) item.getWidget()).setSelectionMode(mode);
    }/* ww w. j  a  v  a2s .com*/
    for (int i = 0; i < item.getChildCount(); i++) {
        searchTreeItems(item.getChild(i), source, mode);
    }
}

From source file:org.primordion.xholon.io.XholonGuiClassic.java

License:Open Source License

protected TreeItem getGuiItemRecurse(String nodeName, TreeItem ti) {
    if (nodeName.equals(ti.getText())) {
        return ti;
    }/* ww  w .  j av a2  s .c  om*/
    for (int i = 0; i < ti.getChildCount(); i++) {
        TreeItem tiChild = getGuiItemRecurse(nodeName, ti.getChild(i));
        if (tiChild != null) {
            return tiChild;
        }
    }
    return null;
}

From source file:org.primordion.xholon.io.XholonGuiClassicTree.java

License:Open Source License

/**
 * Get the TreeItem at the location where the user clicked.
 * This is a recursive method that searches the tree top-down.
 * @param ti The current TreeItem being checked.
 * @param clickY The Y coordinate (in pixels) where the user clicked.
 *///  ww  w.j  a v a  2  s . co  m
protected TreeItem getTreeItemAt(TreeItem ti, int clickY) {
    int top = ti.getAbsoluteTop();
    if (top == 0) {
        return null;
    } // the TreeItem is not visible
    if ((top >= 0) && (clickY >= top) && (clickY < top + TI_HEIGHT)) {
        return ti;
    }
    for (int i = 0; i < ti.getChildCount(); i++) {
        TreeItem childTi = getTreeItemAt(ti.getChild(i), clickY);
        if (childTi != null) {
            return childTi;
        }
    }
    return null;
}

From source file:org.sonar.plugins.design.ui.libraries.client.ProjectPanel.java

License:Open Source License

private void openItem(TreeItem item, boolean open) {
    item.setState(open);//from  w  w w  .  j  av  a2 s.co  m
    for (int i = 0; i < item.getChildCount(); i++) {
        openItem(item.getChild(i), open);
    }
}

From source file:org.uberfire.client.editors.fileexplorer.FileExplorerView.java

License:Apache License

private boolean needsLoading(TreeItem item) {
    return item.getChildCount() == 1 && LAZY_LOAD.equals(item.getChild(0).getText());
}

From source file:org.unitime.timetable.gwt.client.page.UniTimeMobileMenu.java

License:Apache License

private void openedNodes(List<String> ret, TreeItem item, String prefix) {
    if (item.getState())
        ret.add((prefix == null ? "" : prefix + " ") + item.getText());
    for (int i = 0; i < item.getChildCount(); i++)
        openedNodes(ret, item.getChild(i), (prefix == null ? "" : prefix + " ") + item.getText());
}