List of usage examples for com.google.gwt.user.client.ui TreeItem getChild
public TreeItem getChild(int index)
From source file:cc.alcina.framework.gwt.client.ide.widget.FilterableTree.java
License:Apache License
public TreeItem getNextNode(TreeItem item, boolean ignoreChildAxis, int direction) { if (item == null) { return null; }//from ww w. j a v a 2 s . co m TreeOrItem parent = TreeOrItemTree.create(item).getParent(); if (direction == 1) { if (!ignoreChildAxis && item.getState() && item.getChildCount() > 0) { return item.getChild(0); } int childIndex = parent.getChildIndex(item); if (childIndex < parent.getChildCount() - 1) { return parent.getChild(childIndex + 1); } if (item.getParentItem() == null) { return null; } return getNextNode(item.getParentItem(), true, direction); } else { int childIndex = parent.getChildIndex(item); if (childIndex > 0) { return findDeepestOpenChild(parent.getChild(childIndex - 1)); } return item.getParentItem(); } }
From source file:cc.alcina.framework.gwt.client.ide.widget.FilterableTree.java
License:Apache License
private void expandAll(TreeItem ti, int depth) { if (shouldExpandCallback != null && !shouldExpandCallback.allow(ti)) { return;//from w w w . j a v a 2 s. c o m } ti.setState(true); if (depth > 0) { for (int i = 0; i < ti.getChildCount(); i++) { expandAll(ti.getChild(i), depth - 1); } } }
From source file:cc.alcina.framework.gwt.client.ide.widget.FilterableTree.java
License:Apache License
private TreeItem findDeepestOpenChild(TreeItem item) { if (!item.getState() || item.getChildCount() == 0) { return item; }//from w w w .j av a 2 s .c o m return findDeepestOpenChild(item.getChild(item.getChildCount() - 1)); }
From source file:cc.alcina.framework.gwt.client.ide.widget.FilterableTree.java
License:Apache License
private boolean selectVisibleChild(TreeItem item) { for (int i = 0; i < item.getChildCount(); i++) { TreeItem child = item.getChild(i); if (child.isVisible()) { return selectVisibleChild(child); }/*from w ww. ja v a2 s .c o m*/ } setSelectedItem(item); setFocus(true); return true; }
From source file:cc.alcina.framework.gwt.client.widget.TreeNodeWalker.java
License:Apache License
public void walk(Tree tree, Callback callback) { Stack<TreeItem> items = new Stack<TreeItem>(); int itemCount = tree.getItemCount(); for (int i = 0; i < itemCount; i++) { items.push(tree.getItem(i));/* w w w .j av a 2s . c o m*/ } while (!items.isEmpty()) { TreeItem pop = items.pop(); callback.apply(pop); for (int i = 0; i < pop.getChildCount(); i++) { items.push(pop.getChild(i)); } } }
From source file:cc.alcina.framework.gwt.client.widget.TreeNodeWalker.java
License:Apache License
public void walk(TreeItem item, Callback callback) { Stack<TreeItem> items = new Stack<TreeItem>(); items.push(item);/*from w ww .j av a2 s . c om*/ while (!items.isEmpty()) { TreeItem pop = items.pop(); callback.apply(pop); for (int i = 0; i < pop.getChildCount(); i++) { items.push(pop.getChild(i)); } } }
From source file:com.chinarewards.gwt.license.client.core.ui.impl.SimpleMenuProcessor.java
public void render(Panel container) { // organize tree // sort according to menuID string length Collections.sort(items, new Comparator<MenuItem>() { public int compare(MenuItem paramT1, MenuItem paramT2) { return paramT1.getMenuId().length() - paramT2.getMenuId().length(); }/*from w w w . j a v a 2 s . c o m*/ }); // pack into the MenuNode structure for (MenuItem m : items) { // append children recursively root.appendChild(new MenuNode(m)); } Tree tree = new Tree(); tree.addStyleName("hihi"); TreeItem rootItem = new TreeItem("HR SYSTEM"); for (MenuNode n : root.getChildren()) { addSubTreeNode(rootItem, n); } boolean addToRoot = true; if (addToRoot) { // re-root child elements to the root of tree while (rootItem.getChildCount() > 0) { //for (int i = 0; i < rootItem.getChildCount(); i++) { TreeItem item = rootItem.getChild(0); tree.addItem(item); item.setState(true); } } else { for (int i = 0; i < rootItem.getChildCount(); i++) { TreeItem item = rootItem.getChild(i); item.setState(true); // tree.addItem(item); } rootItem.setState(true); tree.addItem(rootItem); } ScrollPanel menuWrapper = new ScrollPanel(tree); container.add(menuWrapper); }
From source file:com.chinarewards.gwt.license.client.core.ui.impl.SimpleMenuProcessor.java
public void initrender(Panel container, String name) { Collections.sort(items, new Comparator<MenuItem>() { public int compare(MenuItem paramT1, MenuItem paramT2) { return paramT1.getMenuId().length() - paramT2.getMenuId().length(); }// w w w. ja va 2s .c o m }); // // pack into the MenuNode structure // for (MenuItem m : items) { // // append children recursively // root.appendChild(new MenuNode(m)); // } Tree tree = new Tree(); tree.addStyleName("hihi"); TreeItem rootItem = new TreeItem(""); for (MenuNode n : root.getChildren()) { System.out.println(n.getValue().getTitle()); addSubTreeNode(rootItem, n); } // re-root child elements to the root of tree while (rootItem.getChildCount() > 0) { //for (int i = 0; i < rootItem.getChildCount(); i++) { TreeItem item = rootItem.getChild(0); tree.addItem(item); item.setState(true); } ScrollPanel menuWrapper = new ScrollPanel(tree); container.clear(); container.add(menuWrapper); }
From source file:com.ephesoft.dcma.gwt.admin.bm.client.view.batch.ImportBatchClassView.java
License:Open Source License
private void setChildItemsUI(final TreeItem childTree, final boolean checked, final Node parentNode) { List<Node> childList = parentNode.getChildren(); if (childTree.getChildCount() > 0) { for (int index = 0; index < childTree.getChildCount(); index++) { CheckBox checkBox = (CheckBox) childTree.getChild(index).getWidget(); if (checkBox.isEnabled()) { checkBox.setValue(checked); childList.get(index).getLabel().setMandatory(checked); }/*from w ww .j a v a 2 s. c om*/ setChildItemsUI(childTree.getChild(index), checked, childList.get(index)); } } }
From source file:com.google.gwt.sample.kitchensink.client.Trees.java
License:Apache License
public void onTreeItemStateChanged(TreeItem item) { TreeItem child = item.getChild(0); if (child instanceof PendingItem) { item.removeItem(child);//from ww w .j a v a 2 s . c om Proto proto = (Proto) item.getUserObject(); for (int i = 0; i < proto.children.length; ++i) { createItem(proto.children[i]); item.addItem(proto.children[i].item); } } }