/** * 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)); }
/** * A convenience method to expand the row if it is currently collapsed or * vice versa. */ public void toggleExpanded(int visibleIndex) { setExpanded(visibleIndex, !isExpanded(visibleIndex)); }
@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)); } } }
final boolean expanded = treeList.isExpanded(row); if ((expanded && isLeftArrowKey) || (!expanded && isRightArrowKey)) TreeTableUtilities.toggleExpansion(table, treeList, row).run();
final boolean expanded = treeList.isExpanded(row); if ((expanded && isLeftArrowKey) || (!expanded && isRightArrowKey)) TreeTableUtilities.toggleExpansion(table, treeList, row).run();
final boolean expanded = treeList.isExpanded(row); if ((expanded && isLeftArrowKey) || (!expanded && isRightArrowKey)) { TreeTableUtilities.toggleExpansion(table, treeList, row).run();
/** * Return a decorated form of the component returned by the data * {@link TableCellRenderer}. */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { treeList.getReadWriteLock().readLock().lock(); try { // read information about the tree node from the TreeList treeNodeData.setDepth(treeList.depth(row)); treeNodeData.setExpanded(treeList.isExpanded(row)); treeNodeData.setHasChildren(treeList.hasChildren(row)); treeNodeData.setAllowsChildren(treeList.getAllowsChildren(row)); } finally { treeList.getReadWriteLock().readLock().unlock(); } // if the delegate renderer accepts TreeNodeData, give it if (delegate instanceof TreeTableNodeDataRenderer) ((TreeTableNodeDataRenderer) delegate).setTreeNodeData(treeNodeData); // ask the delegate renderer to produce the data component final Component c = delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); // fetch the number of pixels to indent final int indent = getIndent(treeNodeData, showExpanderForEmptyParent); // fetch the number of pixels to space over final int spacer = getSpacer(treeNodeData, showExpanderForEmptyParent); // ask our special component to configure itself for this tree node component.configure(treeNodeData, showExpanderForEmptyParent, c, hasFocus, indent, spacer); return component; }
/** * Return a decorated form of the component returned by the data * {@link TableCellRenderer}. */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { treeList.getReadWriteLock().readLock().lock(); try { // read information about the tree node from the TreeList treeNodeData.setDepth(treeList.depth(row)); treeNodeData.setExpanded(treeList.isExpanded(row)); treeNodeData.setHasChildren(treeList.hasChildren(row)); treeNodeData.setAllowsChildren(treeList.getAllowsChildren(row)); } finally { treeList.getReadWriteLock().readLock().unlock(); } // if the delegate renderer accepts TreeNodeData, give it if (delegate instanceof TreeTableNodeDataRenderer) ((TreeTableNodeDataRenderer) delegate).setTreeNodeData(treeNodeData); // ask the delegate renderer to produce the data component final Component c = delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); // fetch the number of pixels to indent final int indent = getIndent(treeNodeData, showExpanderForEmptyParent); // fetch the number of pixels to space over final int spacer = getSpacer(treeNodeData, showExpanderForEmptyParent); // ask our special component to configure itself for this tree node component.configure(treeNodeData, showExpanderForEmptyParent, c, hasFocus, indent, spacer); return component; }
/** * Return a decorated form of the component returned by the data * {@link TableCellRenderer}. */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { treeList.getReadWriteLock().readLock().lock(); try { // read information about the tree node from the TreeList treeNodeData.setDepth(treeList.depth(row)); treeNodeData.setExpanded(treeList.isExpanded(row)); treeNodeData.setHasChildren(treeList.hasChildren(row)); treeNodeData.setAllowsChildren(treeList.getAllowsChildren(row)); } finally { treeList.getReadWriteLock().readLock().unlock(); } // if the delegate renderer accepts TreeNodeData, give it if (delegate instanceof TreeTableNodeDataRenderer) ((TreeTableNodeDataRenderer) delegate).setTreeNodeData(treeNodeData); // ask the delegate renderer to produce the data component final Component c = delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); // fetch the number of pixels to indent final int indent = getIndent(treeNodeData, showExpanderForEmptyParent); // fetch the number of pixels to space over final int spacer = getSpacer(treeNodeData, showExpanderForEmptyParent); // ask our special component to configure itself for this tree node component.configure(treeNodeData, showExpanderForEmptyParent, c, hasFocus, indent, spacer); return component; }
/** * Return a decorated form of the component returned by the data * {@link TableCellEditor}. */ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { treeList.getReadWriteLock().readLock().lock(); try { // read information about the tree node from the TreeList treeNodeData.setDepth(treeList.depth(row)); treeNodeData.setExpanded(treeList.isExpanded(row)); treeNodeData.setHasChildren(treeList.hasChildren(row)); treeNodeData.setAllowsChildren(treeList.getAllowsChildren(row)); } finally { treeList.getReadWriteLock().readLock().unlock(); } // if the delegate editor accepts TreeNodeData, give it if (delegate instanceof TreeTableNodeDataEditor) ((TreeTableNodeDataEditor) delegate).setTreeNodeData(treeNodeData); // ask the delegate editor to produce the data component final Component c = delegate.getTableCellEditorComponent(table, value, isSelected, row, column); // fetch the number of pixels to indent final int indent = getIndent(treeNodeData, showExpanderForEmptyParent); // fetch the number of pixels to space over final int spacer = getSpacer(treeNodeData, showExpanderForEmptyParent); // ask our special component to configure itself for this tree node component.configure(treeNodeData, showExpanderForEmptyParent, c, false, indent, spacer); return component; }
/** * Return a decorated form of the component returned by the data * {@link TableCellEditor}. */ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { treeList.getReadWriteLock().readLock().lock(); try { // read information about the tree node from the TreeList treeNodeData.setDepth(treeList.depth(row)); treeNodeData.setExpanded(treeList.isExpanded(row)); treeNodeData.setHasChildren(treeList.hasChildren(row)); treeNodeData.setAllowsChildren(treeList.getAllowsChildren(row)); } finally { treeList.getReadWriteLock().readLock().unlock(); } // if the delegate editor accepts TreeNodeData, give it if (delegate instanceof TreeTableNodeDataEditor) ((TreeTableNodeDataEditor) delegate).setTreeNodeData(treeNodeData); // ask the delegate editor to produce the data component final Component c = delegate.getTableCellEditorComponent(table, value, isSelected, row, column); // fetch the number of pixels to indent final int indent = getIndent(treeNodeData, showExpanderForEmptyParent); // fetch the number of pixels to space over final int spacer = getSpacer(treeNodeData, showExpanderForEmptyParent); // ask our special component to configure itself for this tree node component.configure(treeNodeData, showExpanderForEmptyParent, c, false, indent, spacer); return component; }
/** * Return a decorated form of the component returned by the data * {@link TableCellEditor}. */ @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { treeList.getReadWriteLock().readLock().lock(); try { // read information about the tree node from the TreeList treeNodeData.setDepth(treeList.depth(row)); treeNodeData.setExpanded(treeList.isExpanded(row)); treeNodeData.setHasChildren(treeList.hasChildren(row)); treeNodeData.setAllowsChildren(treeList.getAllowsChildren(row)); } finally { treeList.getReadWriteLock().readLock().unlock(); } // if the delegate editor accepts TreeNodeData, give it if (delegate instanceof TreeTableNodeDataEditor) ((TreeTableNodeDataEditor) delegate).setTreeNodeData(treeNodeData); // ask the delegate editor to produce the data component final Component c = delegate.getTableCellEditorComponent(table, value, isSelected, row, column); // fetch the number of pixels to indent final int indent = getIndent(treeNodeData, showExpanderForEmptyParent); // fetch the number of pixels to space over final int spacer = getSpacer(treeNodeData, showExpanderForEmptyParent); // ask our special component to configure itself for this tree node component.configure(treeNodeData, showExpanderForEmptyParent, c, false, indent, spacer); return component; }