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