protected boolean shouldVisitNode(TreeNode node) { return (node.isExpanded() || node.getParent() == null); }
private void eraseParent(TreeNode node) { TreeNode parentNode = node.getParent(); if (parentNode != null) { parentNode.getChildren().remove(node); node.setParent(null); } }
private void eraseParent(TreeNode node) { TreeNode parentNode = node.getParent(); if (parentNode != null) { parentNode.getChildren().remove(node); node.setParent(null); } }
@Override protected boolean shouldVisitNode(TreeNode node) { return isDynamic() ? (node.isExpanded() || node.getParent() == null) : true; }
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 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); } } } }
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); } } }
/** * Optimized set implementation to be used in sorting * * @param index index of the element to replace * @param node node to be stored at the specified position * @return the node previously at the specified position */ @Override public TreeNode setSibling(int index, TreeNode node) { if (node == null) { throw new NullPointerException(); } else if ((index < 0) || (index >= size())) { throw new IndexOutOfBoundsException(); } else { if (!parent.equals(node.getParent())) { eraseParent(node); } TreeNode previous = get(index); super.set(index, node); node.setParent(parent); updateRowKeys(parent); return previous; } }
@Override public TreeNode set(int index, TreeNode node) { if (node == null) { throw new NullPointerException(); } else if ((index < 0) || (index >= size())) { throw new IndexOutOfBoundsException(); } else { if (!parent.equals(node.getParent())) { eraseParent(node); } TreeNode previous = get(index); super.set(index, node); previous.setParent(null); node.setParent(parent); updateRowKeys(parent); return previous; } }
/** * Optimized set implementation to be used in sorting * * @param index index of the element to replace * @param node node to be stored at the specified position * @return the node previously at the specified position */ @Override public TreeNode setSibling(int index, TreeNode node) { if (node == null) { throw new NullPointerException(); } else if ((index < 0) || (index >= size())) { throw new IndexOutOfBoundsException(); } else { if (!parent.equals(node.getParent())) { eraseParent(node); } TreeNode previous = get(index); super.set(index, node); node.setParent(parent); updateRowKeys(parent); updateSelectionState(parent); return previous; } }
@Override public TreeNode set(int index, TreeNode node) { if (node == null) { throw new NullPointerException(); } else if ((index < 0) || (index >= size())) { throw new IndexOutOfBoundsException(); } else { if (!parent.equals(node.getParent())) { eraseParent(node); } TreeNode previous = get(index); super.set(index, node); previous.setParent(null); node.setParent(parent); updateRowKeys(parent); updateSelectionState(parent); return previous; } }
private void updateSelectionState(TreeNode node) { boolean allChildrenSelected = true; boolean partialSelected = false; for (int i = 0; i < node.getChildren().size(); i++) { TreeNode childNode = node.getChildren().get(i); boolean childSelected = childNode.isSelected(); boolean childPartialSelected = childNode.isPartialSelected(); allChildrenSelected = allChildrenSelected && childSelected; partialSelected = partialSelected || childSelected || childPartialSelected; } ((CheckboxTreeNode) node).setSelected(allChildrenSelected, false); if (allChildrenSelected) { node.setPartialSelected(false); } else { node.setPartialSelected(partialSelected); } TreeNode parentNode = node.getParent(); if (parentNode != null) { updateSelectionState(parentNode); } } }
public void filter(FacesContext context, TreeTable tt, List<FilterMeta> filterMetadata, String globalFilterValue) throws IOException { Locale filterLocale = context.getViewRoot().getLocale(); TreeNode root = tt.getValue(); TreeNode filteredNode = null; tt.getFilteredRowKeys().clear(); findFilteredRowKeys(context, tt, root, filterMetadata, filterLocale, globalFilterValue); filteredNode = createNewNode(root, root.getParent()); List<String> filteredRowKeys = tt.getFilteredRowKeys(); createFilteredNodeFromRowKeys(tt, root, filteredNode, filteredRowKeys); tt.updateFilteredNode(context, filteredNode); tt.setValue(filteredNode); tt.setRowKey(null); //Metadata for callback if (tt.isPaginator()) { PrimeFaces.current().ajax().addCallbackParam("totalRecords", filteredNode.getChildren().size()); } if (tt.getSelectedRowKeysAsString() != null) { PrimeFaces.current().ajax().addCallbackParam("selection", tt.getSelectedRowKeysAsString()); } }
protected void encodeNode(FacesContext context, TreeTable tt, TreeNode treeNode) throws IOException { ResponseWriter writer = context.getResponseWriter(); String rowKey = treeNode.getRowKey(); String parentRowKey = treeNode.getParent().getRowKey(); tt.setRowKey(rowKey); String icon = treeNode.isExpanded() ? TreeTable.COLLAPSE_ICON : TreeTable.EXPAND_ICON;
private void eraseParent(TreeNode node) { TreeNode parentNode = node.getParent(); if (parentNode != null) { parentNode.getChildren().remove(node); node.setParent(null); } }
private void eraseParent(TreeNode node) { TreeNode parentNode = node.getParent(); if (parentNode != null) { parentNode.getChildren().remove(node); node.setParent(null); } }
/** * @param node */ private void eraseParent(TreeNode node) { TreeNode parentNode = node.getParent(); if (parentNode != null) { parentNode.getChildren().remove(node); node.setParent(null); } }
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); } } } }