Example usage for com.google.gwt.widgetideas.client HasFastTreeItems addItem

List of usage examples for com.google.gwt.widgetideas.client HasFastTreeItems addItem

Introduction

In this page you can find the example usage for com.google.gwt.widgetideas.client HasFastTreeItems addItem.

Prototype

FastTreeItem addItem(Widget widget);

Source Link

Document

Adds a child tree item containing the specified widget.

Usage

From source file:com.google.gwt.demos.fasttree.client.FastTreeDemo.java

License:Apache License

private void lazyCreateChild(final HasFastTreeItems parent, final int index, final int children) {

    FastTreeItem item = new FastTreeItem("child" + index + " (" + children + " children)") {
        public void ensureChildren() {
            for (int i = 0; i < children; i++) {
                lazyCreateChild(this, i, children + (i * 10));
            }//ww  w.  ja  va  2  s .  com
        }
    };
    item.becomeInteriorNode();
    parent.addItem(item);
}

From source file:com.google.gwt.demos.fasttree.client.FastTreeDemo.java

License:Apache License

private void verboseTreeItem(HasFastTreeItems parent, int children) {
    for (int i = 0; i < children; i++) {
        final int index = i;

        FastTreeItem item = new ListeningFastTreeItem("child " + i) {

            public void beforeClose() {
                Window.alert("Close item" + index);
            }/*from  w w w  .ja va2s. c o  m*/

            public void beforeOpen() {
                Window.alert("Open item " + index);
            }

            protected boolean beforeSelectionLost() {
                return DOMHelper.confirm("Are you sure you want to leave me?");
            }

            protected void ensureChildren() {
                Window.alert("You are about to open my children for the first time");
            }

            protected void onSelected() {
                Window.alert("You selected item " + index);
            }
        };
        parent.addItem(item);
        verboseTreeItem(item, children - (i + 1));
    }
}