/** * A convenience method to expand the row if it is currently collapsed or * vice versa. */ public void toggleExpanded(int visibleIndex) { setExpanded(visibleIndex, !isExpanded(visibleIndex)); }
private Node<E> deleteVirtualAncestryRootDown(Node<E> previous, Node<E> parent) { Node<E> replacementLastSibling = previous.ancestorWithPathLength(parent.pathLength() + 1); assert(replacementLastSibling.siblingAfter == null); Node<E> replacement = replacementLastSibling.parent; // merge expand/collapse state first if(replacement.expanded && !parent.expanded) { setExpanded(parent, true); } else if(parent.expanded && !replacement.expanded) { setExpanded(replacement, true); } // link the children of the two parents as siblings Node<E> parentFirstChild = parent.firstChild(); assert(parentFirstChild == null || parentFirstChild.siblingBefore == null); replacementLastSibling.siblingAfter = parentFirstChild; if(parentFirstChild != null) parentFirstChild.siblingBefore = replacementLastSibling; // point all children at the new parent for(Node<E> child = parentFirstChild; child != null; child = child.siblingAfter) { child.parent = replacement; } // remove the parent itself deleteNode(parent); // next up for potential deletion is the child of this parent return parentFirstChild; }
/** * A convenience method to expand the row if it is currently collapsed or * vice versa. */ public void toggleExpanded(int visibleIndex) { setExpanded(visibleIndex, !isExpanded(visibleIndex)); }
/** * A convenience method to expand the row if it is currently collapsed or * vice versa. */ public void toggleExpanded(int visibleIndex) { setExpanded(visibleIndex, !isExpanded(visibleIndex)); }
private Node<E> deleteVirtualAncestryRootDown(Node<E> previous, Node<E> parent) { Node<E> replacementLastSibling = previous.ancestorWithPathLength(parent.pathLength() + 1); assert(replacementLastSibling.siblingAfter == null); Node<E> replacement = replacementLastSibling.parent; // merge expand/collapse state first if(replacement.expanded && !parent.expanded) { setExpanded(parent, true); } else if(parent.expanded && !replacement.expanded) { setExpanded(replacement, true); } // link the children of the two parents as siblings Node<E> parentFirstChild = parent.firstChild(); assert(parentFirstChild == null || parentFirstChild.siblingBefore == null); replacementLastSibling.siblingAfter = parentFirstChild; if(parentFirstChild != null) parentFirstChild.siblingBefore = replacementLastSibling; // point all children at the new parent for(Node<E> child = parentFirstChild; child != null; child = child.siblingAfter) { child.parent = replacement; } // remove the parent itself deleteNode(parent); // next up for potential deletion is the child of this parent return parentFirstChild; }
private Node<E> deleteVirtualAncestryRootDown(Node<E> previous, Node<E> parent) { Node<E> replacementLastSibling = previous.ancestorWithPathLength(parent.pathLength() + 1); assert(replacementLastSibling.siblingAfter == null); Node<E> replacement = replacementLastSibling.parent; // merge expand/collapse state first if(replacement.expanded && !parent.expanded) { setExpanded(parent, true); } else if(parent.expanded && !replacement.expanded) { setExpanded(replacement, true); } // link the children of the two parents as siblings Node<E> parentFirstChild = parent.firstChild(); assert(parentFirstChild == null || parentFirstChild.siblingBefore == null); replacementLastSibling.siblingAfter = parentFirstChild; if(parentFirstChild != null) parentFirstChild.siblingBefore = replacementLastSibling; // point all children at the new parent for(Node<E> child = parentFirstChild; child != null; child = child.siblingAfter) { child.parent = replacement; } // remove the parent itself deleteNode(parent); // next up for potential deletion is the child of this parent return parentFirstChild; }
@Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() % 2 == 0) { int row = jTable.rowAtPoint(e.getPoint()); int depth = treeList.depth(row); final int min = INDENT + (depth * WIDTH); final int max = min + WIDTH; if (e.getPoint().x < min || e.getPoint().x > max) { treeList.setExpanded(row, !treeList.isExpanded(row)); } } }
/** * Control whether the child elements of the specified node are visible. * * @param expanded <code>true</code> to expand the node, <code>false</code> * to collapse it. */ public void setExpanded(int visibleIndex, boolean expanded) { Node<E> toExpand = data.get(visibleIndex, VISIBLE_NODES).get(); expansionModel.setExpanded(toExpand.getElement(), toExpand.path, expanded); setExpanded(toExpand, expanded); assert(isValid()); }
/** * Control whether the child elements of the specified node are visible. * * @param expanded <code>true</code> to expand the node, <code>false</code> * to collapse it. */ public void setExpanded(int visibleIndex, boolean expanded) { Node<E> toExpand = data.get(visibleIndex, VISIBLE_NODES).get(); expansionModel.setExpanded(toExpand.getElement(), toExpand.path, expanded); setExpanded(toExpand, expanded); assert(isValid()); }
/** * Control whether the child elements of the specified node are visible. * * @param expanded <code>true</code> to expand the node, <code>false</code> * to collapse it. */ public void setExpanded(int visibleIndex, boolean expanded) { Node<E> toExpand = data.get(visibleIndex, VISIBLE_NODES).get(); expansionModel.setExpanded(toExpand.getElement(), toExpand.path, expanded); setExpanded(toExpand, expanded); assert(isValid()); }