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());
}
}
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);
}
}
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());
}
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));
}
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);
}
Aggregations