@Override public boolean addAll(int index, Collection<? extends TreeNode> collection) { Iterator<TreeNode> elements = (new ArrayList<TreeNode>(collection)).iterator(); boolean changed = false; while (elements.hasNext()) { TreeNode node = elements.next(); if (node == null) { throw new NullPointerException(); } else { eraseParent(node); super.add(index++, node); node.setParent(parent); changed = true; } } if (changed) { updateRowKeys(parent); updateSelectionState(parent); } return (changed); }
@Override public boolean addAll(Collection<? extends TreeNode> collection) { Iterator<TreeNode> elements = (new ArrayList<TreeNode>(collection)).iterator(); boolean changed = false; while (elements.hasNext()) { TreeNode node = elements.next(); if (node == null) { throw new NullPointerException(); } else { eraseParent(node); super.add(node); node.setParent(parent); changed = true; } } if (changed) { updateRowKeys(parent); updateSelectionState(parent); } return (changed); }
@Override public boolean add(TreeNode node) { if (node == null) { throw new NullPointerException(); } else { eraseParent(node); boolean result = super.add(node); node.setParent(parent); updateRowKeys(parent); updateSelectionState(parent); return result; } }
@Override public boolean remove(Object object) { TreeNode node = (TreeNode) object; if (node == null) { throw new NullPointerException(); } if (super.indexOf(node) != -1) { node.clearParent(); } if (super.remove(node)) { updateRowKeys(parent); updateSelectionState(parent); return true; } else { return false; } }
@Override public void add(int index, TreeNode node) { if (node == null) { throw new NullPointerException(); } else if ((index < 0) || (index > size())) { throw new IndexOutOfBoundsException(); } else { eraseParent(node); super.add(index, node); node.setParent(parent); updateRowKeys(parent); updateSelectionState(parent); } }
@Override public TreeNode remove(int index) { TreeNode node = get(index); node.setParent(null); super.remove(index); updateRowKeys(parent); updateSelectionState(parent); return node; }
/** * 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); } } }
@Override public boolean addAll(Collection<? extends TreeNode> collection) { Iterator<TreeNode> elements = (new ArrayList<TreeNode>(collection)).iterator(); boolean changed = false; while (elements.hasNext()) { TreeNode node = elements.next(); if (node == null) { throw new NullPointerException(); } else { eraseParent(node); super.add(node); node.setParent(parent); changed = true; } } if (changed) { updateRowKeys(parent); updateSelectionState(parent); } return (changed); }
@Override public boolean addAll(int index, Collection<? extends TreeNode> collection) { Iterator<TreeNode> elements = (new ArrayList<TreeNode>(collection)).iterator(); boolean changed = false; while (elements.hasNext()) { TreeNode node = elements.next(); if (node == null) { throw new NullPointerException(); } else { eraseParent(node); super.add(index++, node); node.setParent(parent); changed = true; } } if (changed) { updateRowKeys(parent); updateSelectionState(parent); } return (changed); }
@Override public boolean add(TreeNode node) { if (node == null) { throw new NullPointerException(); } else { eraseParent(node); boolean result = super.add(node); node.setParent(parent); updateRowKeys(parent); updateSelectionState(parent); return result; } }
@Override public void add(int index, TreeNode node) { if (node == null) { throw new NullPointerException(); } else if ((index < 0) || (index > size())) { throw new IndexOutOfBoundsException(); } else { eraseParent(node); super.add(index, node); node.setParent(parent); updateRowKeys(parent); updateSelectionState(parent); } }
@Override public boolean remove(Object object) { TreeNode node = (TreeNode) object; if (node == null) { throw new NullPointerException(); } if (super.indexOf(node) != -1) { node.clearParent(); } if (super.remove(node)) { updateRowKeys(parent); updateSelectionState(parent); return true; } else { return false; } }
@Override public TreeNode remove(int index) { TreeNode node = get(index); node.setParent(null); super.remove(index); updateRowKeys(parent); updateSelectionState(parent); return node; }
/** * 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 */ 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); } } }