Search in sources :

Example 1 with Tree

use of com.google.gwt.user.client.ui.Tree in project che by eclipse.

the class PreviewViewImpl method setTreeOfChanges.

/** {@inheritDoc} */
@Override
public void setTreeOfChanges(final RefactoringPreview changes) {
    showDiffPanel(false);
    final SelectionModel<RefactoringPreview> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            RefactoringPreview selectedNode = (RefactoringPreview) ((SingleSelectionModel) selectionModel).getSelectedObject();
            delegate.onSelectionChanged(selectedNode);
        }
    });
    Tree tree = new Tree();
    tree.getElement().setId("tree-of-changes");
    for (RefactoringPreview parentChange : changes.getChildrens()) {
        TreeItem treeItem = new TreeItem();
        containerChanges.put(treeItem, parentChange);
        createTreeElement(treeItem, parentChange.getText(), parentChange.getChildrens());
        tree.addItem(treeItem);
    }
    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {

        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            if (selectedElement != null) {
                selectedElement.getStyle().setProperty("background", "transparent");
            }
            selectedElement = event.getSelectedItem().getWidget().getElement();
            selectedElement.getStyle().setProperty("background", getEditorSelectionColor());
        }
    });
    treePanel.add(tree);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) TreeItem(com.google.gwt.user.client.ui.TreeItem) Tree(com.google.gwt.user.client.ui.Tree) RefactoringPreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 2 with Tree

use of com.google.gwt.user.client.ui.Tree in project pentaho-platform by pentaho.

the class MantleXul method enableUsersRolesTreeItem.

public void enableUsersRolesTreeItem(final boolean enabled) {
    Timer t = new Timer() {

        public void run() {
            if (container != null) {
                cancel();
                String usersRolesLabel = Messages.getString("users") + "/" + Messages.getString("roles");
                GwtTree adminCatTree = (GwtTree) container.getDocumentRoot().getElementById("adminCatTree");
                TreeItem usersRolesTreeItem = null;
                Tree adminTree = adminCatTree.getTree();
                Iterator<TreeItem> adminTreeItr = adminTree.treeItemIterator();
                while (adminTreeItr.hasNext()) {
                    usersRolesTreeItem = adminTreeItr.next();
                    if (usersRolesTreeItem.getText().equals(usersRolesLabel)) {
                        usersRolesTreeItem.setVisible(enabled);
                        break;
                    }
                }
            }
        }
    };
    t.scheduleRepeating(250);
}
Also used : Timer(com.google.gwt.user.client.Timer) TreeItem(com.google.gwt.user.client.ui.TreeItem) GwtTree(org.pentaho.ui.xul.gwt.tags.GwtTree) Tree(com.google.gwt.user.client.ui.Tree) GwtTree(org.pentaho.ui.xul.gwt.tags.GwtTree)

Example 3 with Tree

use of com.google.gwt.user.client.ui.Tree in project pentaho-platform by pentaho.

the class MantleXul method selectAdminCatTreeTreeItem.

public void selectAdminCatTreeTreeItem(final String treeLabel) {
    GwtTree adminCatTree = (GwtTree) container.getDocumentRoot().getElementById("adminCatTree");
    Tree adminTree = adminCatTree.getTree();
    adminTree.setSelectedItem(null, true);
    Iterator<TreeItem> adminTreeItr = adminTree.treeItemIterator();
    while (adminTreeItr.hasNext()) {
        TreeItem treeItem = adminTreeItr.next();
        if (treeItem.getText().equals(treeLabel)) {
            adminTree.setSelectedItem(treeItem, true);
            break;
        }
    }
}
Also used : TreeItem(com.google.gwt.user.client.ui.TreeItem) GwtTree(org.pentaho.ui.xul.gwt.tags.GwtTree) Tree(com.google.gwt.user.client.ui.Tree) GwtTree(org.pentaho.ui.xul.gwt.tags.GwtTree)

Example 4 with Tree

use of com.google.gwt.user.client.ui.Tree in project ovirt-engine by oVirt.

the class AbstractSanStorageList method createSanStorageListWidget.

protected void createSanStorageListWidget() {
    tree = new Tree();
    treeContainer.add(tree);
}
Also used : Tree(com.google.gwt.user.client.ui.Tree)

Example 5 with Tree

use of com.google.gwt.user.client.ui.Tree in project gwt-test-utils by gwt-test-utils.

the class TreeTest method beforeTreeTest.

@Before
public void beforeTreeTest() {
    // Create a tree with a few items in it.
    parent = new TreeItem(new SafeHtmlBuilder().appendEscaped("parent").toSafeHtml());
    item0 = parent.addItem(new SafeHtmlBuilder().appendEscaped("item0").toSafeHtml());
    item1 = parent.addItem(new SafeHtmlBuilder().appendEscaped("item1").toSafeHtml());
    // Add a CheckBox to the tree
    item2 = new TreeItem(new CheckBox("item2"));
    parent.addItem(item2);
    tree = new Tree();
    tree.addItem(parent);
    // Add it to the root panel.
    RootPanel.get().add(tree);
    assertThat(tree.isVisible()).isTrue();
    clickedTreeItem = null;
}
Also used : TreeItem(com.google.gwt.user.client.ui.TreeItem) CheckBox(com.google.gwt.user.client.ui.CheckBox) Tree(com.google.gwt.user.client.ui.Tree) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Before(org.junit.Before)

Aggregations

Tree (com.google.gwt.user.client.ui.Tree)5 TreeItem (com.google.gwt.user.client.ui.TreeItem)4 GwtTree (org.pentaho.ui.xul.gwt.tags.GwtTree)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 Timer (com.google.gwt.user.client.Timer)1 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)1 SingleSelectionModel (com.google.gwt.view.client.SingleSelectionModel)1 RefactoringPreview (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview)1 Before (org.junit.Before)1