use of com.github.bordertech.wcomponents.WTree in project wcomponents by BorderTech.
the class WTreeRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WTree tree = new WTree();
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(tree) instanceof WTreeRenderer);
}
use of com.github.bordertech.wcomponents.WTree 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.WTree in project wcomponents by BorderTech.
the class SelectExampleAction method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final ActionEvent event) {
ExampleData data = (ExampleData) event.getActionObject();
WComponent source = (WComponent) event.getSource();
TreePicker picker = WebUtilities.getAncestorOfClass(TreePicker.class, source);
picker.selectExample(data);
MenuPanel panel = WebUtilities.getAncestorOfClass(MenuPanel.class, source);
if (panel != null) {
WTree tree = panel.getTree();
if (tree != null) {
// null);
tree.setSelectedRows(new HashSet<String>());
}
}
}
use of com.github.bordertech.wcomponents.WTree in project wcomponents by BorderTech.
the class WTreeRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
List<MockTreeItemData.MyBean> data = new ArrayList<>();
// Invalid chars
data.add(new MockTreeItemData.MyBean(getInvalidCharSequence(), "X"));
// Malicious
data.add(new MockTreeItemData.MyBean(getMaliciousContent(), "Y"));
MockTreeItemData.MyTestModel model = new MockTreeItemData.MyTestModel(data);
WTree tree = new WTree();
tree.setTreeModel(model);
assertSafeContent(tree);
}
use of com.github.bordertech.wcomponents.WTree in project wcomponents by BorderTech.
the class WTreeRenderer_Test method testDoPaintWhenEmpty.
@Test
public void testDoPaintWhenEmpty() throws IOException, SAXException, XpathException {
WTree tree = new WTree();
setActiveContext(createUIContext());
assertSchemaMatch(tree);
}
Aggregations