Example usage for com.google.gwt.gen2.complexpanel.client FastTreeItem becomeLeaf

List of usage examples for com.google.gwt.gen2.complexpanel.client FastTreeItem becomeLeaf

Introduction

In this page you can find the example usage for com.google.gwt.gen2.complexpanel.client FastTreeItem becomeLeaf.

Prototype

public void becomeLeaf() 

Source Link

Usage

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

License:Apache License

private Widget dynamicTree() {
    FlowPanel container = new FlowPanel();

    // Add Tree/*from  w ww.j  av  a  2  s .c o m*/
    final FastTree topTree = new FastTree();
    FastTreeItem firstBranch = topTree.addItem("Inbox (3)");
    firstBranch.addItem("Urgent");
    FastTreeItem familyBranch = firstBranch.addItem("Family");
    familyBranch.becomeInteriorNode();
    familyBranch.addItem("Mom");
    familyBranch.addItem("Brosef");
    FastTreeItem secondBranch = firstBranch.addItem("Calendar");
    secondBranch.addItem("Important Meetings");
    container.add(topTree);

    final Button btnAdd = new Button("Add to Family Branch", new ClickHandler() {

        public void onClick(ClickEvent event) {
            FastTreeItem selectedItem = topTree.getChild(0).getChild(1);
            Window.alert("Adding new " + selectedItem.getText() + " Child Nodes");
            selectedItem.addItem("Dad");
            selectedItem.addItem("Sissef");
        }
    });

    final Button btnKill = new Button("Disown Family Branch", new ClickHandler() {

        public void onClick(ClickEvent event) {
            FastTreeItem selectedItem = topTree.getChild(0).getChild(1);
            Window.alert("Disowning " + selectedItem.getText() + " Child Nodes");
            selectedItem.becomeLeaf();
            btnAdd.setVisible(true);
        }
    });

    topTree.addBeforeCloseHandler(new BeforeCloseHandler<FastTreeItem>() {
        public void onBeforeClose(BeforeCloseEvent<FastTreeItem> event) {
            btnKill.setVisible(event.getTarget().getText().equals("Family"));
        }
    });
    btnKill.setVisible(false);
    btnAdd.setVisible(false);

    container.add(btnKill);
    container.add(btnAdd);

    return container;
}

From source file:org.pentaho.pat.client.ui.widgets.DimensionTreeWidget.java

License:Open Source License

private FastTreeItem createChildLabel(String name, String caption, ObjectType objecttype, boolean isuniquename,
        SimplePanelDragControllerImpl controller, boolean draggable) {

    FastTreeItem fti = new FastTreeItem();

    MeasureLabel label = new MeasureLabel(name, caption, objecttype, fti, isuniquename);

    label.setDragController(controller);

    if (draggable) {
        label.makeDraggable();//from   w  w w.j av a 2s. c om
    }
    if (objecttype.equals(ObjectType.MEASURE) || objecttype.equals(ObjectType.MEMBER)) {
        fti.becomeLeaf();
    } else {
        fti.becomeInteriorNode();
    }
    fti.setWidget(label);
    return fti;

}