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

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

Introduction

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

Prototype

TreeItem(boolean isRoot) 

Source Link

Document

Creates an empty tree item.

Usage

From source file:com.fullmetalgalaxy.client.game.tabmenu.WgtGameLogs.java

License:Open Source License

private void addParallelHiddenEvent() {
    EbRegistration myRegistration = GameEngine.model().getMyRegistration();
    if (myRegistration != null
            && !myRegistration.getTeam(GameEngine.model().getGame()).getMyEvents().isEmpty()) {
        TreeItem turnTreeItem = new TreeItem(SafeHtmlUtils.fromString(myRegistration.getAccount().getPseudo()));
        m_tree.addItem(turnTreeItem);/*  www .  j  a  v a 2s .  c  om*/
        for (AnEvent event : myRegistration.getTeam(GameEngine.model().getGame()).getMyEvents()) {
            turnTreeItem.addItem(new TreeItemEvent(event));
        }
    }
}

From source file:com.fullmetalgalaxy.client.game.tabmenu.WgtGameLogs.java

License:Open Source License

private void buildTree4Tbt() {
    int currentTurn = 0;
    Iterator<AnEvent> iterator = GameEngine.model().getGame().getLogs().iterator();
    TreeItem turnTreeItem = null;//from   w  w w .  j  a va  2  s. c o m
    if (GameEngine.model().getGame().getAdditionalEventCount() > 0) {
        turnTreeItem = new TreeItem(SafeHtmlUtils.fromString("tour ?"));
    } else {
        turnTreeItem = new TreeItem(SafeHtmlUtils.fromString("inscriptions"));
        m_tree.addItem(turnTreeItem);

        // game starting
        while (iterator.hasNext()) {
            AnEvent event = iterator.next();
            turnTreeItem.addItem(new TreeItemEvent(event));
            if (event instanceof EbEvtChangePlayerOrder) {
                currentTurn++;
                turnTreeItem = new TreeItem(SafeHtmlUtils.fromString("tour " + currentTurn));
                m_tree.addItem(turnTreeItem);
                break;
            }
        }
    }
    // game turn
    int evtPlayerTurnCount = 0;
    int playerCount = GameEngine.model().getGame().getCurrentNumberOfRegiteredPlayer();
    TreeItem playerTreeItem = null;
    while (iterator.hasNext()) {
        AnEvent event = iterator.next();
        if (playerTreeItem == null) {
            EbRegistration registration = null;
            String playerPseudo = null;
            if (event instanceof AnEventPlay) {
                registration = GameEngine.model().getGame()
                        .getRegistrationByIdAccount(((AnEventPlay) event).getAccountId());
            } else if (event instanceof EbEvtPlayerTurn && !event.isAuto()) {
                registration = GameEngine.model().getGame()
                        .getRegistrationByIdAccount(((EbEvtPlayerTurn) event).getAccountId());
            }
            if (registration != null) {
                playerPseudo = registration.getAccount().getPseudo();
            }
            if (playerPseudo != null) {
                playerTreeItem = new TreeItemEvent(event);
                playerTreeItem.setText(playerPseudo);
                turnTreeItem.addItem(playerTreeItem);
            }
        }
        if (playerTreeItem != null) {
            playerTreeItem.addItem(new TreeItemEvent(event));
        } else {
            turnTreeItem.addItem(new TreeItemEvent(event));
        }
        if (event instanceof EbEvtPlayerTurn) {
            playerTreeItem = null;
            evtPlayerTurnCount++;
            if (evtPlayerTurnCount >= playerCount) {
                // its probably a new turn
                evtPlayerTurnCount = 0;
                currentTurn++;
                turnTreeItem = new TreeItemEvent(event);
                turnTreeItem.setText("tour " + currentTurn);
                m_tree.addItem(turnTreeItem);
            }
        }
        if (event instanceof EbEvtControlFreighter) {
            if (((EbEvtControlFreighter) event).getOldRegistration(GameEngine.model().getGame()) != null
                    && ((EbEvtControlFreighter) event).getOldRegistration(GameEngine.model().getGame())
                            .getColor() == EnuColor.None) {
                playerCount--;
            }
        }
    }
}

From source file:com.fullmetalgalaxy.client.game.tabmenu.WgtGameLogs.java

License:Open Source License

private void buildTree4Parallel() {
    Iterator<AnEvent> iterator = GameEngine.model().getGame().getLogs().iterator();
    if (GameEngine.model().getGame().getAdditionalEventCount() == 0) {
        TreeItem turnTreeItem = new TreeItem(SafeHtmlUtils.fromString("inscriptions"));
        m_tree.addItem(turnTreeItem);// ww  w .ja v  a2  s.c  o  m

        // game starting
        while (iterator.hasNext()) {
            AnEvent event = iterator.next();
            turnTreeItem.addItem(new TreeItemEvent(event));
            if (event instanceof EbAdminTimePlay) {
                break;
            }
        }
    }
    // game time step
    TreeItemEvent dateTreeItem = null;
    while (iterator.hasNext()) {
        AnEvent event = iterator.next();
        if (dateTreeItem == null
                || event.getLastUpdate().getDate() != dateTreeItem.getEvent().getLastUpdate().getDate()) {
            dateTreeItem = new TreeItemEvent(event);
            dateTreeItem.setHTML("<img src='/images/css/calendar.png'/> " + EventPresenter.getDate(event));
            m_tree.addItem(dateTreeItem);
        }
        dateTreeItem.addItem(new TreeItemEvent(event));
    }
}

From source file:com.gmail.cjbooms.thesis.pythonappengine.client.filebrowser.FileSystemTreeWidget.java

License:Open Source License

/**
 * Create Empty Tree/*  w w  w . j ava 2 s .  com*/
 * @return
 */
private Tree createFileSystemTree() {
    tree = new Tree();
    tree.setAnimationEnabled(true);
    TreeItem tItem = new TreeItem(new TreeItemWidget(FileType.DIR, "Available Projects"));
    tItem.addItem("Loading...");
    tree.addOpenHandler(getOpenHandler());
    tree.addSelectionHandler(getSelectionHandler());
    tree.addItem(tItem);
    //tree.setSelectedItem(tItem, true);
    return tree;
}

From source file:com.gmail.cjbooms.thesis.pythonappengine.client.filebrowser.FileSystemTreeWidget.java

License:Open Source License

/**
 * Handle Tree Expansion. Add new branch nodes if directory, otherwise add as leaf nodes
 * @param father/*from   w  w  w  . jav a 2  s  . c o m*/
 * @param files
 */
private void expandTreeItem(TreeItem father, FileWrapper[] files) {
    father.removeItems();
    for (FileWrapper file : files) {
        TreeItemWidget fileTreeNode = new TreeItemWidget(file.getKind(), file.getName());
        // Add new branch node
        if (file.getKind() == FileType.DIR) {
            TreeItem newItem = new TreeItem(fileTreeNode);
            father.addItem(newItem);
            newItem.addItem("Loading...");
        }
        // Add Leaf
        else {
            father.addItem(fileTreeNode);
        }
    }
}

From source file:com.google.appinventor.client.editor.simple.components.MockComponent.java

License:Open Source License

/**
 * Constructs a tree item for the component which will be displayed in the
 * source structure explorer./*from  w  ww  . j  a  v a  2s .c o m*/
 *
 * @return  tree item for this component
 */
protected TreeItem buildTree() {
    // Instantiate new tree item for this component
    // Note: We create a ClippedImagePrototype because we need something that can be
    // used to get HTML for the iconImage. AbstractImagePrototype requires
    // an ImageResource, which we don't necessarily have.
    String imageHTML = new ClippedImagePrototype(iconImage.getUrl(), iconImage.getOriginLeft(),
            iconImage.getOriginTop(), ICON_IMAGE_WIDTH, ICON_IMAGE_HEIGHT).getHTML();
    TreeItem itemNode = new TreeItem(new HTML("<span>" + imageHTML + getName() + "</span>"));
    itemNode.setUserObject(sourceStructureExplorerItem);
    return itemNode;
}

From source file:com.google.appinventor.client.explorer.youngandroid.AssetList.java

License:Open Source License

private void refreshAssetList() {
    OdeLog.log("AssetList: refreshing for project " + projectId);
    assetList.clear();/*ww w . j a  va 2  s .c  o  m*/

    if (assetsFolder != null) {
        for (ProjectNode node : assetsFolder.getChildren()) {
            // Add the name to the tree. We need to enclose it in a span
            // because the CSS style for selection specifies a span.
            String nodeName = node.getName();
            if (nodeName.length() > 20)
                nodeName = nodeName.substring(0, 8) + "..."
                        + nodeName.substring(nodeName.length() - 9, nodeName.length());
            TreeItem treeItem = new TreeItem(new HTML("<span>" + nodeName + "</span>"));
            // keep a pointer from the tree item back to the actual node
            treeItem.setUserObject(node);
            assetList.addItem(treeItem);
        }
    }
}

From source file:com.google.caja.demos.playground.client.ui.PlaygroundView.java

License:Apache License

private static TreeItem addExampleItem(Map<Example.Type, TreeItem> menu, Example eg) {
    if (!menu.containsKey(eg.type)) {
        TreeItem menuItem = new TreeItem(eg.type.description);
        menu.put(eg.type, menuItem);//from   w w w. jav a2  s  . c o m
    }
    TreeItem egItem = new TreeItem(eg.description);
    menu.get(eg.type).addItem(egItem);
    return egItem;
}

From source file:com.google.gwt.examples.TreeExample.java

License:Apache License

public void onModuleLoad() {
    // Create a tree with a few items in it.
    TreeItem root = new TreeItem("root");
    root.addItem("item0");
    root.addItem("item1");
    root.addItem("item2");

    // Add a CheckBox to the tree
    TreeItem item = new TreeItem(new CheckBox("item3"));
    root.addItem(item);/*from   w w w  .j  a  v a 2 s. c  o m*/

    Tree t = new Tree();
    t.addItem(root);

    // Add it to the root panel.
    RootPanel.get().add(t);
}

From source file:com.google.gwt.maps.sample.hellomaps.client.InfoWindowDemo.java

License:Apache License

/**
 * Display one of the info Window test cases.
 *///from   w w  w  . j av a2s . c  om
private void displayInfoWindow() {

    // pop down the existing info window.
    if (info != null) {
        info.close();
    }

    info = map.getInfoWindow();
    String selection = actionListBox.getItemText(actionListBox.getSelectedIndex());

    if (selection == null) {
        return;
    }

    InfoWindowContent content;

    if (selection.equals(TEST_MAX_CONTENT)) {

        // Demonstrate the use of the maxTitle and maxContent properties
        HTML htmlWidget = new HTML(
                "<h1>ATTENTION PLEASE</h1>" + "<p> I have a few things to say to you (click maximize.)</p>");
        content = new InfoWindowContent(htmlWidget);
        content.setMaxContent("<p>Now is the time for all good men to come to the"
                + " aid of their country because we hold these truths to be self"
                + " evident, that I have a dream, that one day our children and our"
                + " children's children will tear down this wall!</p>"
                + "<p>Now is the time for all good men to come to the"
                + " aid of their country because we hold these truths to be self"
                + " evident, that I have a dream, that one day our children and our"
                + " children's children will tear down this wall!</p>");
        content.setMaxTitle("ATTENTION PLEASE");

    } else if (selection.equals(TEST_IMAGE)) {

        // An image that isn't loaded yet doesn't work well sometimes
        // Specify the width and height to work around this.
        HTML htmlWidget = new HTML("<img src=\"boot.jpg\" width=\"235\" height=\"287\">");
        content = new InfoWindowContent(htmlWidget);
    } else if (selection.equals(TEST_NO_CLICK)) {

        // Demonstrates setting the info window to stay "sticky" and not
        // automatically close when the user clicks on the maps window.
        HTML htmlWidget = new HTML("<h1>STICKY INFO WINDOW</h1>"
                + "<p> Click if you must, you won't get rid of me that easily.</p>");
        content = new InfoWindowContent(htmlWidget);
        content.setNoCloseOnClick(true);
    } else if (selection.equals(TEST_TABS)) {

        // Display tabs in the InfoWindow
        content = displayInfoWindowTabs();
    } else if (selection.equals(TEST_MAX_TITLE_CONTENT_WIDGET)) {

        // Display the maximized content using widgets instead of strings.
        content = displayInfoWindowMaxWidget();
    } else if (selection.equals(TEST_MAP_BLOWUP)) {

        // Display a Map Blowup Window
        content = new InfoWindowContent.MapBlowupContent();
    } else {

        // The default case
        Tree tree = new Tree();
        TreeItem foo = new TreeItem("Foo");
        tree.addItem(foo);
        TreeItem bar = new TreeItem("bar");
        foo.addItem(bar);
        bar.addItem("baz");
        bar.addItem("gwt");
        // max-height must be set in advance so info window is sized appropriately
        tree.setSize("217px", "104px");
        content = new InfoWindowContent(tree);
    }

    info.open(map.getCenter(), content);
}