public DefaultTreeNode(String type, Object data, TreeNode parent) { this.type = type; this.data = data; this.children = new TreeNodeChildren(this); if (parent != null) { parent.getChildren().add(this); } }
@Override public int getRowCount() { TreeNode root = getValue(); if (root == null) { return (-1); } else { List<TreeNode> children = root.getChildren(); return children == null ? -1 : children.size(); } }
public CheckboxTreeNode(Object data, TreeNode parent) { this.type = DEFAULT_TYPE; this.data = data; this.children = new CheckboxTreeNodeChildren(this); if (parent != null) { parent.getChildren().add(this); } }
public CheckboxTreeNode(String type, Object data, TreeNode parent) { this.type = type; this.data = data; this.children = new CheckboxTreeNodeChildren(this); if (parent != null) { parent.getChildren().add(this); } }
public DefaultTreeNode(Object data, TreeNode parent) { this.type = DEFAULT_TYPE; this.data = data; this.children = new TreeNodeChildren(this); if (parent != null) { parent.getChildren().add(this); } }
private void eraseParent(TreeNode node) { TreeNode parentNode = node.getParent(); if (parentNode != null) { parentNode.getChildren().remove(node); node.setParent(null); } }
protected void processNode(FacesContext context, PhaseId phaseId, TreeNode treeNode, String rowKey) { processColumnChildren(context, phaseId, rowKey); //process child nodes if node is expanded or node itself is the root if (shouldVisitNode(treeNode)) { int childIndex = 0; for (Iterator<TreeNode> iterator = treeNode.getChildren().iterator(); iterator.hasNext(); ) { String childRowKey = rowKey == null ? String.valueOf(childIndex) : rowKey + SEPARATOR + childIndex; processNode(context, phaseId, iterator.next(), childRowKey); childIndex++; } } }
private void eraseParent(TreeNode node) { TreeNode parentNode = node.getParent(); if (parentNode != null) { parentNode.getChildren().remove(node); node.setParent(null); } }
protected void encodeNodeChildren(FacesContext context, TreeTable tt, TreeNode treeNode, int first, int size) throws IOException { if (size > 0) { List<TreeNode> children = treeNode.getChildren(); int childCount = treeNode.getChildCount(); int last = (first + size); if (last > childCount) { last = childCount; } for (int i = first; i < last; i++) { encodeNode(context, tt, children.get(i)); } } }
public void populateRowKeys(TreeNode node, List<String> keys) { if (node != null) { int childCount = node.getChildCount(); if (childCount > 0) { for (int i = 0; i < childCount; i++) { TreeNode childNode = node.getChildren().get(i); keys.add(childNode.getRowKey()); populateRowKeys(childNode, keys); } } } }
protected boolean visitNode(VisitContext context, VisitCallback callback, TreeNode treeNode, String rowKey) { if (visitColumns(context, callback, rowKey)) { return true; } //visit child nodes if node is expanded or node itself is the root if (shouldVisitNode(treeNode)) { int childIndex = 0; for (Iterator<TreeNode> iterator = treeNode.getChildren().iterator(); iterator.hasNext(); ) { String childRowKey = rowKey == null ? String.valueOf(childIndex) : rowKey + SEPARATOR + childIndex; if (visitNode(context, callback, iterator.next(), childRowKey)) { return true; } childIndex++; } } return false; }
public void encodeTreeNodeChildren(FacesContext context, Tree tree, TreeNode node, String clientId, boolean dynamic, boolean checkbox, boolean droppable) throws IOException { int childCount = node.getChildCount(); if (childCount > 0) { for (int i = 0; i < childCount; i++) { if (i == 0 && droppable) { encodeDropTarget(context, tree); } encodeTreeNode(context, tree, node.getChildren().get(i), clientId, dynamic, checkbox, droppable); } } }
private void createFilteredNodeFromRowKeys(TreeTable tt, TreeNode node, TreeNode filteredNode, List<String> filteredRowKeys) { int childCount = node.getChildCount(); for (int i = 0; i < childCount; i++) { TreeNode childNode = node.getChildren().get(i); String rowKeyOfChildNode = childNode.getRowKey(); for (String rk : filteredRowKeys) { if (rk.equals(rowKeyOfChildNode) || rk.startsWith(rowKeyOfChildNode + "_") || rowKeyOfChildNode.startsWith(rk + "_")) { TreeNode newNode = createNewNode(childNode, filteredNode); if (rk.startsWith(rowKeyOfChildNode + "_")) { newNode.setExpanded(true); } createFilteredNodeFromRowKeys(tt, childNode, newNode, filteredRowKeys); break; } } } }
public void updateRowKeys(TreeNode node) { int childCount = node.getChildCount(); if (childCount > 0) { for (int i = 0; i < childCount; i++) { TreeNode childNode = node.getChildren().get(i); String childRowKey = (node.getParent() == null) ? String.valueOf(i) : node.getRowKey() + "_" + i; childNode.setRowKey(childRowKey); updateRowKeys(childNode); } } }
private void updateRowKeys(TreeNode node) { int childCount = node.getChildCount(); if (childCount > 0) { for (int i = 0; i < childCount; i++) { TreeNode childNode = node.getChildren().get(i); String childRowKey = (node.getParent() == null) ? String.valueOf(i) : node.getRowKey() + "_" + i; childNode.setRowKey(childRowKey); updateRowKeys(childNode); } } } }
private void updateSelectedNodes(TreeNode node) { int childCount = node.getChildCount(); if (childCount > 0) { for (int i = 0; i < childCount; i++) { TreeNode childNode = node.getChildren().get(i); if (childNode.isSelected()) { addToPreselection(childNode); } updateSelectedNodes(childNode); } } }
private void updateRowKeys(TreeNode node) { int childCount = node.getChildCount(); if (childCount > 0) { for (int i = 0; i < childCount; i++) { TreeNode childNode = node.getChildren().get(i); String childRowKey = (node.getParent() == null) ? String.valueOf(i) : node.getRowKey() + "_" + i; childNode.setRowKey(childRowKey); updateRowKeys(childNode); } } }
public void buildRowKeys(TreeNode node) { int childCount = node.getChildCount(); if (childCount > 0) { for (int i = 0; i < childCount; i++) { TreeNode childNode = node.getChildren().get(i); if (childNode.isSelected()) { addToPreselection(childNode); } String childRowKey = (node.getParent() == null) ? String.valueOf(i) : node.getRowKey() + "_" + i; childNode.setRowKey(childRowKey); buildRowKeys(childNode); } } }
public TreeNode createCopyOfTreeNode(TreeNode node) { TreeNode newNode; if (node instanceof CheckboxTreeNode) { newNode = new CheckboxTreeNode(node.getData()); } else { newNode = new DefaultTreeNode(node.getData()); } newNode.setSelectable(node.isSelectable()); newNode.setExpanded(node.isExpanded()); for (TreeNode childNode : node.getChildren()) { newNode.getChildren().add(createCopyOfTreeNode(childNode)); } return newNode; }
protected void encodeFilteredNodes(FacesContext context, Tree tree, TreeNode node, String filteredValue, Locale filterLocale) throws IOException { int childCount = node.getChildCount(); if (childCount > 0) { String var = tree.getVar(); Map<String, Object> requestMap = context.getExternalContext().getRequestMap(); ValueExpression filterByVE = tree.getValueExpression(Tree.PropertyKeys.filterBy.toString()); FilterConstraint filterConstraint = getFilterConstraint(tree); for (int i = 0; i < childCount; i++) { TreeNode childNode = node.getChildren().get(i); requestMap.put(var, childNode.getData()); if (filterConstraint.applies(filterByVE.getValue(context.getELContext()), filteredValue, filterLocale)) { tree.getFilteredRowKeys().add(childNode.getRowKey()); } encodeFilteredNodes(context, tree, childNode, filteredValue, filterLocale); } requestMap.remove(var); } }