Search in sources :

Example 86 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class JsonTreeTest method testGetVsOpt.

@Test
public void testGetVsOpt() {
    List<ITreeNode> nodes = new ArrayList<ITreeNode>();
    nodes.add(new TreeNode());
    nodes.add(new TreeNode());
    nodes.add(new TreeNode());
    ITree tree = createTree(nodes);
    JsonTree<ITree> jsonTree = m_uiSession.createJsonAdapter(tree, null);
    String node0Id = jsonTree.getOrCreateNodeId(nodes.get(0));
    assertNotNull(node0Id);
    assertEquals(node0Id, jsonTree.optNodeId(nodes.get(0)));
    assertEquals(node0Id, jsonTree.getNodeId(nodes.get(0)));
    assertNotNull(jsonTree.optTreeNodeForNodeId(node0Id));
    assertNotNull(jsonTree.getTreeNodeForNodeId(node0Id));
    String nonExistingNodeId = "bla";
    ITreeNode nonExistingTreeNode = new TreeNode();
    assertNull(jsonTree.optNodeId(nonExistingTreeNode));
    try {
        jsonTree.getNodeId(nonExistingTreeNode);
        fail("Expected UiException");
    } catch (UiException e) {
    // ok
    }
    assertNull(jsonTree.optTreeNodeForNodeId(nonExistingNodeId));
    try {
        jsonTree.getTreeNodeForNodeId(nonExistingNodeId);
        fail("Expected UiException");
    } catch (UiException e) {
    // ok
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) TreeNode(org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeNode) ArrayList(java.util.ArrayList) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) UiException(org.eclipse.scout.rt.ui.html.UiException) Test(org.junit.Test)

Example 87 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class TreeWith3Levels method execInitTree.

@Override
protected void execInitTree() {
    super.execInitTree();
    ITreeNode node0 = new TreeNode();
    addChildNode(getRootNode(), node0);
    addChildNode(node0, new TreeNode());
    addChildNode(node0, new TreeNode());
    ITreeNode child1 = node0.getChildNodes().get(1);
    addChildNode(child1, new TreeNode());
    addChildNode(child1, new TreeNode());
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)

Example 88 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class AbstractTreeBox method syncValueToTree.

private void syncValueToTree() {
    if (m_valueTreeSyncActive) {
        return;
    }
    try {
        m_valueTreeSyncActive = true;
        getTree().setTreeChanging(true);
        // 
        Set<T> checkedKeys = getCheckedKeys();
        Collection<ITreeNode> checkedNodes = m_tree.findNodes(checkedKeys);
        getTree().visitTree(new ITreeVisitor() {

            @Override
            public boolean visit(ITreeNode node) {
                node.setChecked(false);
                return true;
            }
        });
        for (ITreeNode node : checkedNodes) {
            node.setChecked(true);
        }
        if (!getTree().isCheckable()) {
            getTree().selectNodes(checkedNodes, false);
        }
        getTree().applyNodeFilters();
    } finally {
        getTree().setTreeChanging(false);
        m_valueTreeSyncActive = false;
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Example 89 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class AbstractTreeField method execMarkSaved.

@Override
protected void execMarkSaved() {
    if (m_tree != null && !m_treeExternallyManaged) {
        try {
            m_tree.setTreeChanging(true);
            // 
            ITreeVisitor v = new ITreeVisitor() {

                @Override
                public boolean visit(ITreeNode node) {
                    if (!node.isStatusNonchanged()) {
                        node.setStatusInternal(ITreeNode.STATUS_NON_CHANGED);
                        m_tree.updateNode(node);
                    }
                    return true;
                }
            };
            m_tree.visitNode(m_tree.getRootNode(), v);
            m_tree.clearDeletedNodes();
        } finally {
            m_tree.setTreeChanging(false);
        }
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Example 90 with ITreeNode

use of org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode in project scout.rt by eclipse.

the class TreeProposalChooser method getNode.

/**
 * Node with a given key. Assumes the node is already loaded at this point
 */
private ITreeNode getNode(final LOOKUP_KEY key) {
    final Holder<ITreeNode> holder = new Holder<>(ITreeNode.class);
    m_model.visitTree(new ITreeVisitor() {

        @Override
        public boolean visit(ITreeNode node) {
            if (node.getCell().getValue() instanceof ILookupRow && ObjectUtility.equals(((ILookupRow) node.getCell().getValue()).getKey(), key)) {
                holder.setValue(node);
                return false;
            }
            return true;
        }
    });
    return holder.getValue();
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) Holder(org.eclipse.scout.rt.platform.holders.Holder) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Aggregations

ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)95 Test (org.junit.Test)34 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)29 ArrayList (java.util.ArrayList)23 ITreeVisitor (org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)16 JSONObject (org.json.JSONObject)14 TreeNode (org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeNode)12 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)11 JSONArray (org.json.JSONArray)10 HashSet (java.util.HashSet)9 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)6 EitherOrNode (org.eclipse.scout.rt.client.ui.form.fields.composer.node.EitherOrNode)6 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)5 TreeEvent (org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent)5 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)5 LinkedList (java.util.LinkedList)4 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)4 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)4 ITreeNodeFilter (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNodeFilter)3 StyleField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField)3