use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class IncrementalTreeBuilderTest method testCreatePaths_NullKeyLookupRow.
@Test
public void testCreatePaths_NullKeyLookupRow() {
final Map<Long, ILookupRow<Long>> lookupRowsMap = new HashMap<>();
lookupRowsMap.put(1L, new LookupRow<Long>(1L, "A"));
lookupRowsMap.put(2L, new LookupRow<Long>(2L, "A-B").withParentKey(1L));
lookupRowsMap.put(null, new LookupRow<Long>(null, "(none)"));
Collection<ILookupRow<Long>> rows = lookupRowsMap.values();
IKeyLookupProvider<Long> provider = new IKeyLookupProvider<Long>() {
@Override
public ILookupRow<Long> getLookupRow(Long key) {
return lookupRowsMap.get(key);
}
};
ITree tree = createTestTree();
IncrementalTreeBuilder<Long> builder = new IncrementalTreeBuilder<Long>(provider);
List<List<ILookupRow<Long>>> paths = builder.createPaths(rows, tree);
assertEquals(3, paths.size());
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class SmartFieldTest method testHierarchicalOpenProposal.
@Test
public void testHierarchicalOpenProposal() {
StyleField f = m_styleField;
f.setBrowseHierarchy(true);
f.setValue(10L);
f.getUIFacade().openProposalChooserFromUI("Red", false, true);
waitForProposalResult(IProposalChooser.PROP_SEARCH_RESULT);
// single result
assertTrue(m_styleField.isProposalChooserRegistered());
assertEquals("Red", m_styleField.getDisplayText());
// verifies tree is loaded containing a single node
@SuppressWarnings("unchecked") TreeProposalChooser<Long> treeProposalChooser = (TreeProposalChooser<Long>) f.getProposalChooser();
ITree tree = treeProposalChooser.getModel();
ITreeNode rootNode = tree.getRootNode();
assertEquals(5, rootNode.getChildNodes().size());
assertEquals("Red", rootNode.getChildNode(0).getCell().getText());
// current value should be selected
assertTrue(rootNode.getChildNode(0).isSelectedNode());
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class TreeBoxTest method testAutoSelectBehavior.
/**
* Select a parent node in a tree box with auto check child nodes activated, and check whether this node and all child
* nodes are selected. {@link AbstractTreeBox#getConfiguredAutoCheckChildNodes} returns true on the
* {@link AutoSelectTreeBox}. Bug 368107 - Check child nodes when parent node is checked
*/
@Test
public void testAutoSelectBehavior() throws Exception {
AutoSelectTreeBox treeBox = new AutoSelectTreeBox();
treeBox.initField();
ITree tree = treeBox.getTree();
// A
ITreeNode node = tree.findNode(1L);
assertNotNull(node);
tree.setNodeChecked(node, true);
Set<Long> valueSet = new HashSet<Long>(treeBox.getValue());
// parent node and 3 childs nodes selected
assertEquals(4, valueSet.size());
// and the selected ones are correct
// A
assertEquals(true, valueSet.contains(1L));
// A-A
assertEquals(true, valueSet.contains(5L));
// A-B
assertEquals(true, valueSet.contains(6L));
// A-C
assertEquals(true, valueSet.contains(7L));
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class TreeBoxTest method testDefaultBehavior.
/**
* Select a parent node in a tree box and check whether only this node is selected..
* {@link AbstractTreeBox#getConfiguredAutoCheckChildNodes} returns false on the {@link SimpleTreeBox}. Bug 368107 -
* Check child nodes when parent node is checked
*/
@Test
public void testDefaultBehavior() throws Exception {
SimpleTreeBox treeBox = createSimpleTreeBox();
ITree tree = treeBox.getTree();
// A
ITreeNode node = tree.findNode(1L);
assertNotNull(node);
tree.setNodeChecked(node, true);
Set<Long> valueSet = new HashSet<Long>(treeBox.getValue());
// only one node selected
assertEquals(1, valueSet.size());
// and the selected one is the node explicitly set before
// A
assertEquals(true, valueSet.contains(1L));
}
use of org.eclipse.scout.rt.client.ui.basic.tree.ITree in project scout.rt by eclipse.
the class AbstractPage method setTreeInternal.
@Override
public void setTreeInternal(ITree tree, boolean includeSubtree) {
ITree oldTree = getTree();
if (oldTree != null) {
oldTree.removeTreeListener(m_treeListener);
}
super.setTreeInternal(tree, includeSubtree);
if (tree == null) {
return;
}
tree.addTreeListener(m_treeListener, TreeEvent.TYPE_NODES_UPDATED);
}
Aggregations