List of usage examples for com.google.gwt.user.client.ui TreeItem getChildCount
public int getChildCount()
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 w w 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 ww. jav a2 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; }/* w w w .j a va 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); }/* w w w . j av 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));/*from w w w . ja va 2 s . co 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 w w . j a v a 2 s . co 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:com.arondor.common.reflection.gwt.client.view.AbstractTreeNodeView.java
License:Apache License
private void addItemToParent(UIObject parentNode) { if (parentNode instanceof Tree) { ((Tree) parentNode).addItem(this); } else if (parentNode instanceof TreeItem) { TreeItem parentNodeItem = (TreeItem) parentNode; int childCount = parentNodeItem.getChildCount(); int nodeDepth = 0; for (TreeItem ancestor = parentNodeItem; ancestor != null; ancestor = ancestor.getParentItem()) { nodeDepth++;//w ww . j a v a 2 s . co m } parentNodeItem.addItem(this); String colors[] = { "#F5F5F2", "#DBDAD8", "#F9F8F6", "#E7E7E3" }; int colorIndex = ((nodeDepth % 2) + (childCount % 2)) % 2; getElement().getStyle().setBackgroundColor(colors[colorIndex]); } }
From source file:com.audata.client.search.SearchPanel.java
License:Open Source License
public void onTreeItemSelected(TreeItem ti) { if (ti.getChildCount() < 1) { // we have a field selected this.fieldName.setText(ti.getText()); HashMap user = (HashMap) ti.getUserObject(); String caption = (String) user.get("FieldName"); Integer type = (Integer) user.get("Type"); Boolean isUDF = (Boolean) user.get("isUDF"); String kwh = (String) user.get("KeywordHierarchy"); this.setField(caption, type.intValue(), isUDF.booleanValue(), kwh); this.currentField = (HashMap) ti.getUserObject(); } else {// ww w. jav a 2 s . c o m if (ti.getState()) { // this.closeAll(); ti.setState(false); } else { this.closeAll(); ti.setState(true); } } }
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 ww w .j a v a 2 s .c om }); // 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(); }/*from w w w.j av a 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); }