use of com.github.bordertech.wcomponents.TreeItemIdNode in project wcomponents by BorderTech.
the class WTreeExample method applyOptions.
/**
* Set options for the WTree based on user input in the options field(s).
*/
private void applyOptions() {
tree.reset();
tree.setType(cbMakeHTree.isSelected() ? WTree.Type.HORIZONTAL : WTree.Type.VERTICAL);
tree.setSelectMode(cbUseMultiSelect.isSelected() ? WTree.SelectMode.MULTIPLE : WTree.SelectMode.SINGLE);
tree.setExpandMode((WTree.ExpandMode) ddExpMode.getSelected());
control.setVisible(cbAjaxTrigger.isSelected());
// This model holds the data so would be included on the user session.
ExampleTreeModel data = new ExampleTreeModel(ExampleDataUtil.createExampleData(), cbUseDocuments.isSelected(), cbUseImage.isSelected());
tree.setTreeModel(data);
if (cbCustomTree.isSelected()) {
TreeItemIdNode custom = new TreeItemIdNode(null);
if (cbUseDocuments.isSelected()) {
// Put all documents under Tom Smith (ID16)
TreeItemIdNode node = new TreeItemIdNode("ID16");
node.addChild(new TreeItemIdNode("11122"));
node.addChild(new TreeItemIdNode("23456"));
node.addChild(new TreeItemIdNode("78901"));
node.addChild(new TreeItemIdNode("23457"));
// Put 3 people in the custom tree
custom.addChild(new TreeItemIdNode("ID4"));
custom.addChild(node);
custom.addChild(new TreeItemIdNode("ID1"));
} else {
// Put people under Tom SMith
TreeItemIdNode itemID2 = new TreeItemIdNode("ID2");
itemID2.setHasChildren(true);
TreeItemIdNode itemID1 = new TreeItemIdNode("ID1");
itemID1.setHasChildren(true);
TreeItemIdNode node = new TreeItemIdNode("ID16");
node.addChild(itemID2);
node.addChild(new TreeItemIdNode("ID3"));
node.addChild(new TreeItemIdNode("ID6"));
node.addChild(new TreeItemIdNode("ID5"));
// Take some nodes from other nodes
node.addChild(new TreeItemIdNode("2A"));
node.addChild(new TreeItemIdNode("1B1"));
// Put 3 people at top level
custom.addChild(new TreeItemIdNode("ID4"));
custom.addChild(node);
custom.addChild(itemID1);
}
tree.setCustomTree(custom);
}
}
use of com.github.bordertech.wcomponents.TreeItemIdNode in project wcomponents by BorderTech.
the class TreeItemUtil method copyTreeNode.
/**
* @param node the node to copy
* @return a copy of the node
*/
public static TreeItemIdNode copyTreeNode(final TreeItemIdNode node) {
TreeItemIdNode copy = new TreeItemIdNode(node.getItemId());
copy.setHasChildren(node.hasChildren());
for (TreeItemIdNode childItem : node.getChildren()) {
TreeItemIdNode childCopy = copyTreeNode(childItem);
copy.addChild(childCopy);
}
return copy;
}
Aggregations