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

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

Introduction

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

Prototype

public void setState(boolean open) 

Source Link

Document

Sets whether this item's children are displayed.

Usage

From source file:cc.alcina.framework.gwt.client.ide.widget.FilterableTree.java

License:Apache License

public void collapseToFirstLevel() {
    TreeItem item = getSelectedItem();/*from   ww  w  .  j  a  v  a  2 s  . c  o m*/
    new TreeNodeWalker().walk(this, new Callback<TreeItem>() {
        public void apply(TreeItem target) {
            boolean open = target.getParentItem() == null;
            if (shouldExpandCallback != null && !shouldExpandCallback.allow(target)) {
                open = false;
            }
            target.setState(open);
        }
    });
    if (item != null) {
        setSelectedItem(item, false);
        ensureSelectedItemVisible();
    }
}

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. j  ava2s . com
    }
    ti.setState(true);
    if (depth > 0) {
        for (int i = 0; i < ti.getChildCount(); i++) {
            expandAll(ti.getChild(i), depth - 1);
        }
    }
}

From source file:com.audata.client.classification.ClassBrowser.java

License:Open Source License

public void addClass(String name, String uuid, TreeItem parent, boolean hasChildren) {
    //this.sp.setWidget(this.classes);
    CaptionButton i = new CaptionButton();
    i.setCaptionText(name);/* w  w  w .j  a  v a2 s  .  c  o  m*/
    if (hasChildren) {
        //i = new CaptionButton("images/16x16/treeclass.gif", name, CaptionButton.CAPTION_EAST);
        i.setImageUrl("images/16x16/treeclass.gif");

    } else {
        i.setImageUrl("images/16x16/treeclassb.gif");
    }
    i.setCaptionStyleName("tree-text");
    TreeItem c = new TreeItem(i);
    c.setUserObject(new TreeNodeType("class", uuid, name, hasChildren));
    if (parent == null) {
        this.classes.addItem(c);
    } else {
        parent.addItem(c);
        parent.setState(true);
    }
}

From source file:com.audata.client.Keyword.KeywordBrowser.java

License:Open Source License

public void addClass(String name, String uuid, TreeItem parent, boolean hasChildren, String path) {
    this.sp.setWidget(this.keywords);
    CaptionButton i = new CaptionButton();
    i.setCaptionText(name);//from   w w  w  .  j ava 2s .c om
    if (hasChildren) {
        i.setImageUrl("images/16x16/treeclass.gif");
    } else {
        i.setImageUrl("images/16x16/treeclassb.gif");
    }
    i.setCaptionStyleName("tree-text");
    TreeItem c = new TreeItem(i);
    HashMap uObj = new HashMap();
    uObj.put("uuid", uuid);
    uObj.put("name", name);
    uObj.put("path", path);
    uObj.put("hasChildren", new Boolean(hasChildren));
    //c.setUserObject(new TreeNodeType("class", uuid, name, hasChildren));
    c.setUserObject(uObj);
    if (parent == null) {
        this.keywords.addItem(c);
    } else {
        parent.addItem(c);
        parent.setState(true);
    }
}

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 {//from   w  w  w  .j  av  a  2  s  .co  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  w  ww.  j av 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

/**
 * /*from  w ww  .  j a v a2 s. c o m*/
 * 
 * @param parent
 * @param node
 */
private void addSubTreeNode(TreeItem parent, final MenuNode node) {

    TreeItem item = new TreeItem();
    Grid grid = new Grid(1, 2);
    //      if (node.getValue().getIcon() != null) {
    //   //      grid.setWidget(0, 0, node.getValue().getIcon());
    //      } else {
    //         // default menu icon
    //   //      grid.setWidget(0, 0, new Image(resources.getDefaultMenuIcon()));
    //      }

    // setup handler to fire menu click event
    Label text = new Label(node.getValue().getTitle());
    text.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent paramClickEvent) {
            eventBus.fireEvent(new MenuClickEvent(node.getValue()));
        }
    });
    grid.setWidget(0, 1, text);

    // make it visible
    item.setWidget(grid);
    item.setVisible(true);
    item.setState(true);
    parent.addItem(item);

    // continue processing child menus if any.
    for (MenuNode i : node.getChildren()) {
        addSubTreeNode(item, i);
    }
}

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 www  .j a  va  2s.  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("");
    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

/**
 * This method creates tree view of batch class configuration for selected batch class.
 * /*  w ww  .jav  a  2 s . c  om*/
 * @param uiConfigList List<Node>
 */
public void getbatchFolderListView(List<Node> uiConfigList) {
    batchClassFolderView.removeItems();
    if (uncFolderList.getItemCount() > 0) {
        importBatchClassUserOptionDTO.setUncFolder(uncFolderList.getValue(0));
    }
    if (uiConfigList != null && !uiConfigList.isEmpty()) {
        importBatchClassUserOptionDTO.getUiConfigRoot().getChildren().clear();

        for (Node rootNode : uiConfigList) {
            Node node = new Node();
            node.getLabel().setDisplayName(rootNode.getLabel().getDisplayName());
            node.getLabel().setKey(rootNode.getLabel().getKey());
            node.setParent(rootNode.getParent());
            CheckBox checkBox = new CheckBox();
            checkBox.setText(rootNode.getLabel().getDisplayName().trim());
            TreeItem treeItem = new TreeItem(checkBox);
            createUI(rootNode.getLabel().isMandatory(), checkBox, node, treeItem);
            node.setParent(importBatchClassUserOptionDTO.getUiConfigRoot());
            importBatchClassUserOptionDTO.getUiConfigRoot().getChildren().add(node);
            if (rootNode.getChildren() != null && !rootNode.getChildren().isEmpty()) {
                setImportFolderUI(treeItem, rootNode, node);
            }
            batchClassFolderView.addItem(treeItem);
            treeItem.setState(Boolean.TRUE);
        }

    }
}

From source file:com.ephesoft.dcma.gwt.rv.client.view.DocumentTree.java

License:Open Source License

/**
 * @param docBean//from   ww  w .jav  a 2  s . c  o m
 * @param docTitleLabel
 * @param docType
 * @param icon
 * @param docItem
 */
private void addDocDisplayItemsAndHandlers(final Document docBean, Label docTitleLabel, Label docType,
        Label icon, final TreeItem docItem) {
    String docDisplayProperty = getDocDisplayProperty(docBean, presenter.batchDTO.getDocDisplayName());
    DocumentTreeItem documentTreeItem = new DocumentTreeItem(docItem, docBean, icon, docDisplayProperty);
    addDocTreeItem(documentTreeItem);

    docItem.setTitle(documentTreeItem.documentTitle);
    docTitleLabel.setText(documentTreeItem.documentTitle);
    docType.setText(documentTreeItem.displayName);
    docTitleLabel.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            if (docItem.getState()) {
                docItem.setState(Boolean.FALSE);
            } else {
                OpenEvent.fire(docTree, docItem);
            }
        }
    });
}