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

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

Introduction

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

Prototype

public String getText() 

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  .  ja  va2  s . c om*/
    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;
}