Search in sources :

Example 16 with ITree

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

the class AbstractComposerField method initConfig.

@Override
protected void initConfig() {
    m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(new P_UIFacade(), ModelContext.copyCurrent());
    super.initConfig();
    m_dataModel = interceptCreateDataModel();
    // tree
    List<ITree> contributedTrees = m_contributionHolder.getContributionsByClass(ITree.class);
    m_tree = CollectionUtility.firstElement(contributedTrees);
    if (m_tree == null) {
        Class<? extends ITree> configuredTree = getConfiguredTree();
        if (configuredTree != null) {
            m_tree = ConfigurationUtility.newInnerInstance(this, configuredTree);
        }
    }
    if (m_tree != null) {
        RootNode rootNode = interceptCreateRootNode();
        rootNode.getCellForUpdate().setText(getLabel());
        m_tree.setRootNode(rootNode);
        m_tree.setNodeExpanded(rootNode, true);
        m_tree.setEnabled(isEnabled());
        m_tree.addTreeListener(new TreeAdapter() {

            @Override
            public void treeChanged(TreeEvent e) {
                switch(e.getType()) {
                    case TreeEvent.TYPE_NODES_DELETED:
                    case TreeEvent.TYPE_ALL_CHILD_NODES_DELETED:
                    case TreeEvent.TYPE_NODES_INSERTED:
                    case TreeEvent.TYPE_NODES_UPDATED:
                    case TreeEvent.TYPE_NODES_CHECKED:
                        {
                            checkSaveNeeded();
                            checkEmpty();
                            break;
                        }
                }
            }
        });
        // local enabled listener
        addPropertyChangeListener(PROP_ENABLED_COMPUTED, new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent e) {
                if (m_tree == null) {
                    return;
                }
                boolean newEnabled = ((Boolean) e.getNewValue()).booleanValue();
                m_tree.setEnabled(newEnabled);
            }
        });
    } else {
        LOG.warn("there is no inner class of type ITree in {}", getClass().getName());
    }
}
Also used : TreeEvent(org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent) RootNode(org.eclipse.scout.rt.client.ui.form.fields.composer.node.RootNode) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) TreeAdapter(org.eclipse.scout.rt.client.ui.basic.tree.TreeAdapter)

Example 17 with ITree

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

the class AbstractComposerField method loadFromXml.

@Override
public void loadFromXml(Element x) {
    super.loadFromXml(x);
    ITree tree = getTree();
    try {
        tree.setTreeChanging(true);
        // 
        getTree().removeAllChildNodes(getTree().getRootNode());
        loadXMLRec(x, getTree().getRootNode());
    } finally {
        tree.setTreeChanging(false);
    }
}
Also used : ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree)

Example 18 with ITree

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

the class FormFieldEnabledTest method testTreeInheritance.

@Test
public void testTreeInheritance() {
    P_BoxWithTree box = new P_BoxWithTree();
    TreeField treeField = box.getFieldByClass(TreeField.class);
    ITree tree = treeField.getTree();
    box.setEnabled(false);
    Assert.assertFalse(box.isEnabled());
    Assert.assertFalse(treeField.isEnabledIncludingParents());
    Assert.assertTrue(treeField.isEnabled());
    Assert.assertFalse(tree.isEnabled());
    Assert.assertFalse(tree.getMenus().get(0).isEnabled());
}
Also used : TreeField(org.eclipse.scout.rt.client.ui.form.fields.FormFieldEnabledTest.P_BoxWithTree.TreeField) AbstractTreeField(org.eclipse.scout.rt.client.ui.form.fields.treefield.AbstractTreeField) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) Test(org.junit.Test)

Example 19 with ITree

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

the class IncrementalTreeBuilderTest method testCreateParentMap_NonEmpty.

@Test
public void testCreateParentMap_NonEmpty() {
    ITree tree = createTestTree();
    tree.addChildNode(tree.getRootNode(), createNode(1L));
    Map<Long, ILookupRow<Long>> parentMap = new IncrementalTreeBuilder<Long>(null).createParentMap(tree);
    assertTrue(parentMap.size() == 1);
    assertTrue(parentMap.containsKey(1L));
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) Test(org.junit.Test)

Example 20 with ITree

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

the class IncrementalTreeBuilderTest method testCreatePaths_NonEmpty.

@Test
public void testCreatePaths_NonEmpty() {
    @SuppressWarnings("unchecked") IKeyLookupProvider<Long> mockProvider = Mockito.mock(IKeyLookupProvider.class);
    ITree tree = createTestTree();
    IncrementalTreeBuilder<Long> builder = new IncrementalTreeBuilder<Long>(mockProvider);
    ArrayList<ILookupRow<Long>> rows = new ArrayList<>();
    rows.add(new LookupRow<Long>(1L, ""));
    rows.add(new LookupRow<Long>(2L, "").withParentKey(1L));
    List<List<ILookupRow<Long>>> paths = builder.createPaths(rows, tree);
    assertTrue(paths.size() == 2);
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) LookupRow(org.eclipse.scout.rt.shared.services.lookup.LookupRow) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ArrayList(java.util.ArrayList) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)54 Test (org.junit.Test)40 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)30 ArrayList (java.util.ArrayList)17 TreeNode (org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeNode)13 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)11 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)6 JSONObject (org.json.JSONObject)5 List (java.util.List)4 TreeEvent (org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent)4 StyleField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 PropertyChangeListener (java.beans.PropertyChangeListener)3 HashSet (java.util.HashSet)3 ITreeNodeFilter (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNodeFilter)3 TreeAdapter (org.eclipse.scout.rt.client.ui.basic.tree.TreeAdapter)3 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)3 WeakReference (java.lang.ref.WeakReference)2 IAction (org.eclipse.scout.rt.client.ui.action.IAction)2 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)2