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.ednovo.gooru.client.mvp.shelf.list.ShelfListView.java

License:Open Source License

public TreeItem getSecondLevelTreeWidget(TreeItem widget, String gooruOid) {
    for (int i = 0; i < widget.getChildCount(); i++) {
        TreeItem item = widget.getChild(i);
        ShelfCollection selectedItem = (ShelfCollection) item.getWidget();
        if (selectedItem.getCollectionDo().getGooruOid().equalsIgnoreCase(gooruOid)) {
            return item;
        }/*from   w  w w .  ja v a  2  s  . c  om*/
    }
    return null;
}

From source file:org.ednovo.gooru.client.mvp.shelf.list.ShelfListView.java

License:Open Source License

public void adjustChildTreeItemsStyle(TreeItem treeItem) {
    int treeItemsCount = treeItem.getChildCount();
    if (treeItem != null && treeItemsCount > 0) {
        for (int i = 0; i < treeItemsCount; i++) {
            TreeItem childTreeItem = treeItem.getChild(i);
            Widget shelfWidget = childTreeItem.getWidget();
            if (shelfWidget instanceof ShelfCollection) {
                adjustChildTreeItemsStyle(childTreeItem);
            }/*  w  w w.  j av a2s  . c  o m*/
            correctStyle(childTreeItem);
        }
    }
}

From source file:org.gatein.management.gadget.client.Application.java

License:Open Source License

/**
 * @return the openHandler//from  w  w w.  j  a v  a 2  s.c o  m
 */
private OpenHandler<TreeItem> getOpenHandler() {
    OpenHandler<TreeItem> openHandler = new OpenHandler<TreeItem>() {

        public void onOpen(OpenEvent<TreeItem> event) {

            final TreeItem target = event.getTarget();
            final TreeNode tn = (TreeNode) target.getUserObject();
            String text = target.getText();
            target.setText("Loading items");

            if (target.getChildCount() > 0) {
                TreeItem it = target.getChild(0);
                if (it instanceof PendingItem) {
                    target.removeItem(it);
                }
            }

            if (target.getChildCount() == 0) {
                gtnService.updateItem(getPortalContainerName(), tn, new AsyncCallback<TreeNode>() {

                    public void onFailure(Throwable caught) {
                        Window.alert("Fail to update the tree items <br />" + caught);
                        Application.this.details.setHTML("Failed to load sub-tree");
                    }

                    public void onSuccess(TreeNode result) {

                        for (TreeNode tnChild : result.getChildren()) {
                            TreeItem it = Application.this.createItem(tnChild);
                            if (!tnChild.getChildren().isEmpty()) {
                                it.addItem(new PendingItem());
                            }
                            target.addItem(it);
                        }
                    }
                });
            }

            target.setText(text);
        }
    };

    return openHandler;
}

From source file:org.gatein.management.gadget.mop.exportimport.client.Application.java

License:Open Source License

private OpenHandler<TreeItem> createOpenHandler() {
    return new OpenHandler<TreeItem>() {
        @Override/*  w w w  . j a va  2 s  .c  om*/
        public void onOpen(OpenEvent<TreeItem> event) {
            final TreeItem target = event.getTarget();
            final TreeNode tn = (TreeNode) target.getUserObject();
            String text = target.getText();
            target.setText("Loading items");

            if (target.getChildCount() > 0) {
                TreeItem it = target.getChild(0);
                if (it instanceof PendingItem) {
                    target.removeItem(it);
                }
            }

            if (target.getChildCount() == 0) {
                gtnService.updateItem(getPortalContainerName(), tn, new AsyncCallback<TreeNode>() {

                    public void onFailure(Throwable caught) {
                        Window.alert("Failed to update tree items.  See server log for more details.");
                        Application.this.details.setHTML("Failed to load sub-tree");
                    }

                    public void onSuccess(TreeNode result) {

                        for (TreeNode tnChild : result.getChildren()) {
                            TreeItem it = Application.this.createItem(tnChild);
                            if (!tnChild.getChildren().isEmpty()) {
                                it.addItem(new PendingItem());
                            }
                            target.addItem(it);
                        }
                    }
                });
            }

            target.setText(text);
        }
    };
}

From source file:org.iucn.sis.client.ui.TreeTable.java

License:Apache License

private TreeItem findDeepestOpenChild(TreeItem item) {
    if (!item.getState()) {
        return item;
    }//from  www.  j  a  va2  s  . c om
    return findDeepestOpenChild(item.getChild(item.getChildCount() - 1));
}

From source file:org.iucn.sis.client.ui.TreeTable.java

License:Apache License

private TreeItem findItemByElement(TreeItem item, Element elem) {
    if (DOM.compare(item.getElement(), elem)) {
        return item;
    }//www . ja  va 2s  . co m
    for (int i = 0, n = item.getChildCount(); i < n; ++i) {
        TreeItem child = item.getChild(i);
        child = findItemByElement(child, elem);
        if (child != null) {
            return child;
        }
    }
    return null;
}

From source file:org.iucn.sis.client.ui.TreeTable.java

License:Apache License

protected TreeItem getNextSibling(TreeItem item) {
    TreeItem p = item.getParentItem();
    if (p == null) {
        int idx = root.getChildIndex(item) + 1;
        if (idx < root.getChildCount()) {
            // Gets the next sibling
            return root.getChild(idx);
        }/* w ww  .  jav a  2s .c  o  m*/
    } else {
        int idx = p.getChildIndex(item) + 1;
        if (idx < p.getChildCount()) {
            // Gets the next sibling
            return p.getChild(idx);
        }
    }
    return null;
}

From source file:org.iucn.sis.client.ui.TreeTable.java

License:Apache License

/**
 * Moves to the next item, going into children as if dig is enabled.
 *//*  w  ww.jav a  2 s .c o  m*/
private void moveSelectionDown(TreeItem sel, boolean dig) {
    if (sel == root) {
        return;
    }

    TreeItem parent = sel.getParentItem();
    if (parent == null) {
        parent = root;
    }
    int idx = parent.getChildIndex(sel);

    if (!dig || !sel.getState()) {
        if (idx < parent.getChildCount() - 1) {
            onSelection(parent.getChild(idx + 1), true);
        } else {
            moveSelectionDown(parent, false);
        }
    } else if (sel.getChildCount() > 0) {
        onSelection(sel.getChild(0), true);
    }
}

From source file:org.iucn.sis.client.ui.TreeTable.java

License:Apache License

/**
 * Moves the selected item up one./*from w w w .  j  a v  a  2 s . c om*/
 */
private void moveSelectionUp(TreeItem sel) {
    TreeItem parent = sel.getParentItem();
    if (parent == null) {
        parent = root;
    }
    int idx = parent.getChildIndex(sel);

    if (idx > 0) {
        TreeItem sibling = parent.getChild(idx - 1);
        onSelection(findDeepestOpenChild(sibling), true);
    } else {
        onSelection(parent, true);
    }
}

From source file:org.iucn.sis.client.ui.TreeTable.java

License:Apache License

/**
 * Renders TreeItems recursively.//w  w  w .  j  a v a 2  s .c  o  m
 * 
 * @param item
 */
public void render(TreeItem item) {
    getRenderer().renderTreeItem(this, item, item.getRow());
    if (item.getParentItem() != null) {
        updateVisibility(item.getParentItem());
    }

    for (int i = 0, s = item.getChildCount(); i < s; i++) {
        TreeItem child = item.getChild(i);
        render(child);
    }
}