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

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

Introduction

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

Prototype

public String getText() 

Source Link

Usage

From source file:org.primordion.xholon.io.XholonGuiClassic.java

License:Open Source License

/**
  * Show the entire IXholon tree as a Tree.
  * @param node Node from which to start showing the tree.
  *///from ww w  . j  a  v a  2 s. com
public void showTree(IXholon node) {
    if (tiRoot != null) { // an existing model is already running
        //removeAll();
    }
    if (app == null) {
        app = node.getApp();
    }
    xhRoot = node;
    tiRoot = new TreeItem();
    createNode(xhRoot, tiRoot, null);
    tree = new XholonGuiClassicTree(this);
    tree.addItem(tiRoot);

    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem ti = event.getSelectedItem();
            handleNodeSelection(ti.getText(), ti, tree.isCtrlPressed());
        }
    });

    ScrollPanel scrollPanel = new ScrollPanel(tree);
    scrollPanel.setSize("500px", "500px");

    DockPanel panel = new DockPanel(); //this;
    panel.setStylePrimaryName("xhgui");

    panel.add(scrollPanel, DockPanel.CENTER);
    currentSelectionField = new TextBox();
    currentSelectionField.setVisibleLength(60); // 58
    currentSelectionField.setMaxLength(200);
    currentSelectionField.setText("Click on any node to show details");
    panel.add(currentSelectionField, DockPanel.SOUTH);

    // main menu at top of GUI
    MenuBar mainMenu = new MenuBar();
    mainMenu.setStylePrimaryName("mainMenu");

    // File
    MenuBar fileMenu = new MenuBar(true);
    MenuBar localStorageMenu = new MenuBar(true);
    boolean enableFileItems = true;
    //consoleLog(enableFileItems);
    //consoleLog(Window.Location.getParameter("src"));
    if ("gist".equals(Window.Location.getParameter("src"))) {
        //consoleLog("setting to false");
        enableFileItems = false;
    }
    //consoleLog(enableFileItems);
    localStorageMenu.addItem("Save", new Command() {
        @Override
        public void execute() {
            IApplication lsApp = new ApplicationNull();
            String configFileName = app.getConfigFileName();
            lsApp.setConfigFileName(configFileName);
            JavaApp2Workbook app2Wb = new JavaApp2Workbook();
            app2Wb.setWinName("_blank"); // open in new tab or window
            app2Wb.save(configFileName, lsApp);
        }
    }).setEnabled(enableFileItems);
    // save to localStorage using a new name
    /*localStorageMenu.addItem("Save as", new Command() {
      @Override
      public void execute() {
                
      }
    }).setEnabled(enableFileItems);*/
    localStorageMenu.addItem("Edit", new Command() {
        @Override
        public void execute() {
            IApplication lsApp = new ApplicationNull();
            String configFileName = app.getConfigFileName();
            lsApp.setConfigFileName(configFileName);
            JavaApp2Workbook app2Wb = new JavaApp2Workbook();
            app2Wb.setWinName("_blank"); // open in new tab or window
            app2Wb.edit(configFileName, lsApp);
        }
    }).setEnabled(enableFileItems);
    localStorageMenu.addItem("Restart from", new Command() {
        @Override
        public void execute() {
            // restart the current app by reloading the HTML page (equivalent to browser F5)
            // the reloaded app will automatically include the edited changes in localStorage
            Window.Location.reload();
        }
    }).setEnabled(enableFileItems);
    // remove from localStorage
    /*localStorageMenu.addItem("Remove from", new Command() {
      @Override
      public void execute() {
                
      }
    }).setEnabled(enableFileItems);*/
    fileMenu.addItem("localStorage", localStorageMenu);
    mainMenu.addItem("File", fileMenu);

    // Application
    mainMenu.addItem("Application", new Command() {
        @Override
        public void execute() {
            if (app == null) {
                //app.println("Application not yet loaded.");
            } else {
                app.about();
            }
        }
    });

    // Help
    MenuBar helpMenu = new MenuBar(true);
    helpMenu.addItem("About", new Command() {
        @Override
        public void execute() {
            if (app == null) {
                //app.println("Application not yet loaded.");
            } else {
                app.about();
            }
        }
    });
    helpMenu.addItem("Getting Started", new Command() {
        @Override
        public void execute() {
            gettingStarted("Getting Started with Xholon", splashText, 375, 475);
        }
    });
    helpMenu.addItem("Information", new Command() {
        @Override
        public void execute() {
            if (app == null) {
                //app.println("Application not yet loaded.");
            } else {
                app.information();
            }
        }
    });
    helpMenu.addItem("JavaScript API", new Command() {
        @Override
        public void execute() {
            Window.open(GwtEnvironment.gwtHostPageBaseURL + "jsapidoc/modules/XholonJsApi.html", "_blank", "");
        }
    });
    mainMenu.addItem("Help", helpMenu);
    HorizontalPanel mainMenuHp = new HorizontalPanel();
    mainMenuHp.setStylePrimaryName("mainMenu");
    mainMenuHp.add(mainMenu);

    // toolbar with Controller buttons just below main menu
    HorizontalPanel toolbar = new HorizontalPanel();
    toolbar.setStylePrimaryName("toolbar");
    IXholon controlNode = app.getControlRoot().getFirstChild();
    while (controlNode != null) {
        toolbar.add(makeToolbarWidget(controlNode));
        controlNode = controlNode.getNextSibling();
    }

    VerticalPanel topVp = new VerticalPanel();
    topVp.setStylePrimaryName("mainMenu");
    topVp.setWidth("500px"); // 474
    topVp.add(mainMenuHp);
    topVp.add(toolbar);
    panel.add(topVp, DockPanel.NORTH);

    RootPanel xhgui = RootPanel.get("xhgui");
    if (xhgui == null) {
        node.consoleLog("WARNING xhgui element does not exist");
    } else {
        xhgui.add(panel);
    }

    //((Application)app).clearConsole();
    // clear the contents of the xhconsole
    /*Element element = Document.get().getElementById("xhconsole").getFirstChildElement();
    if (element != null) {
        TextAreaElement textfield = element.cast();
        textfield.setValue("");
    }*/
}

From source file:org.primordion.xholon.io.XholonGuiClassic.java

License:Open Source License

protected String getGuiItemName(final Object guiItem) {
    final TreeItem ti = (TreeItem) guiItem;
    return (String) ti.getText();
}

From source file:org.primordion.xholon.io.XholonGuiClassic.java

License:Open Source License

protected TreeItem getGuiItemRecurse(String nodeName, TreeItem ti) {
    if (nodeName.equals(ti.getText())) {
        return ti;
    }/*  w  w  w. j  av  a  2  s  . c o m*/
    for (int i = 0; i < ti.getChildCount(); i++) {
        TreeItem tiChild = getGuiItemRecurse(nodeName, ti.getChild(i));
        if (tiChild != null) {
            return tiChild;
        }
    }
    return null;
}

From source file:org.primordion.xholon.io.XholonGuiClassic.java

License:Open Source License

protected boolean isInInheritanceHierarchy(Object guiItem) {
    TreeItem treeItem = (TreeItem) guiItem;
    while (treeItem != null) {
        if (treeItem.getText().equals("InheritanceHierarchy")) {
            return true;
        }//from   w w  w.  jav  a2 s  .  co  m
        treeItem = treeItem.getParentItem();
    }
    return false;
}

From source file:org.primordion.xholon.io.XholonGuiClassic.java

License:Open Source License

protected boolean isInMechanismHierarchy(Object guiItem) {
    TreeItem treeItem = (TreeItem) guiItem;
    while (treeItem != null) {
        if (treeItem.getText().equals("MechanismHierarchy")) {
            return true;
        }/*  www  .j a  v a2  s .c  o m*/
        treeItem = treeItem.getParentItem();
    }
    return false;
}

From source file:org.raccoon.filemanager.client.ui.FileSystemTreeWidget.java

License:Apache License

private String findPath(TreeItem item) {
    TreeItem parent = item.getParentItem();

    if (parent == null) {
        return "/";
    } else {/*ww w  .j  av  a  2 s  . c om*/
        return findPath(parent) + "/" + item.getText();
    }
}

From source file:org.unitime.timetable.gwt.client.page.UniTimeMobileMenu.java

License:Apache License

private void openedNodes(List<String> ret, TreeItem item, String prefix) {
    if (item.getState())
        ret.add((prefix == null ? "" : prefix + " ") + item.getText());
    for (int i = 0; i < item.getChildCount(); i++)
        openedNodes(ret, item.getChild(i), (prefix == null ? "" : prefix + " ") + item.getText());
}

From source file:org.unitime.timetable.gwt.client.page.UniTimeMobileMenu.java

License:Apache License

private void openNodes(Set<String> nodes, TreeItem item, String prefix) {
    if (nodes.contains((prefix == null ? "" : prefix + " ") + item.getText()))
        item.setState(true);/*www.  ja  va  2 s  . c o  m*/
    for (int i = 0; i < item.getChildCount(); i++)
        openNodes(nodes, item.getChild(i), (prefix == null ? "" : prefix + " ") + item.getText());
}