@Override protected int getIndent(TreeNodeData treeNodeData, boolean showExpanderForEmptyParent) { return super.getIndent(treeNodeData, showExpanderForEmptyParent) + indent; }
/** * Decorate the component returned from the <code>delegate</code> with * extra components that display the tree node's location within the tree. * If <code>delegate</code> is <tt>null</tt> then a * {@link DefaultTableCellRenderer} will be used as the delegate. * * @param delegate the renderer that produces the data for the tree node * @param treeList the data structure that answers questions about the tree * node and the tree that contains it */ public TreeTableCellRenderer(TableCellRenderer delegate, TreeList treeList) { this.delegate = delegate == null ? createDelegateRenderer() : delegate; this.treeList = treeList; }
/** * Returns the <code>renderer</code> responsible for rendering the data * associated with each tree node in the hierarchy column. */ public TableCellRenderer getDelegateRenderer() { return treeTableCellRenderer.getDelegate(); }
/** * 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; }
/** * Use the given <code>treeTableCellRenderer</code> when rendering the * hierarchy column of the tree table. */ public void setRenderer(TreeTableCellRenderer treeTableCellRenderer) { checkAccessThread(); // ensure we can find the view column index of the hierarchical column final int viewColumnIndex = table.convertColumnIndexToView(hierarchyColumnModelIndex); if (viewColumnIndex == -1) throw new IllegalArgumentException("Unable to locate a view index for the given model index: " + hierarchyColumnModelIndex); // look up the hierarchical TableColumn final TableColumn viewColumn = table.getColumnModel().getColumn(viewColumnIndex); // dispose the old renderer this.treeTableCellRenderer.dispose(); // install the new renderer this.treeTableCellRenderer = treeTableCellRenderer; treeTableCellRenderer.setShowExpanderForEmptyParent(showExpanderForEmptyParent); viewColumn.setCellRenderer(treeTableCellRenderer); }
/** * Use the given <code>renderer</code> as the new delegate renderer of the * {@link TreeTableCellRenderer} which is responsible for rendering the * data associated with each tree node in the hierarchy column. */ public void setDelegateRenderer(TableCellRenderer renderer) { checkAccessThread(); treeTableCellRenderer.setDelegate(renderer); }
/** * Sets whether the expander is displayed for nodes that do not contain * children but are allowed to contain children, and thus may accumulate * children in the future. If this property is <tt>true</tt> then empty * nodes that may contain children in the future are displayed with a * visible expander; otherwise they are displayed without the expander. * A node signals that it may contain children in the future by returning * <tt>true</tt> from {@link TreeList.Format#allowsChildren(Object)}. */ public void setShowExpanderForEmptyParent(boolean showExpanderForEmptyParent) { checkAccessThread(); if (this.showExpanderForEmptyParent == showExpanderForEmptyParent) return; this.showExpanderForEmptyParent = showExpanderForEmptyParent; // indicate the new property value to the renderer and editor treeTableCellRenderer.setShowExpanderForEmptyParent(showExpanderForEmptyParent); treeTableCellEditor.setShowExpanderForEmptyParent(showExpanderForEmptyParent); // repaint the table so the display is updated table.repaint(); }
this.treeTableCellRenderer = new TreeTableCellRenderer(originalRenderer, treeList); viewColumn.setCellRenderer(treeTableCellRenderer);
viewColumn.setCellEditor(originalEditor); treeTableCellRenderer.dispose(); treeTableCellEditor.dispose();
/** * 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; }
/** * Use the given <code>treeTableCellRenderer</code> when rendering the * hierarchy column of the tree table. */ public void setRenderer(TreeTableCellRenderer treeTableCellRenderer) { checkAccessThread(); // ensure we can find the view column index of the hierarchical column final int viewColumnIndex = table.convertColumnIndexToView(hierarchyColumnModelIndex); if (viewColumnIndex == -1) throw new IllegalArgumentException("Unable to locate a view index for the given model index: " + hierarchyColumnModelIndex); // look up the hierarchical TableColumn final TableColumn viewColumn = table.getColumnModel().getColumn(viewColumnIndex); // dispose the old renderer this.treeTableCellRenderer.dispose(); // install the new renderer this.treeTableCellRenderer = treeTableCellRenderer; treeTableCellRenderer.setShowExpanderForEmptyParent(showExpanderForEmptyParent); viewColumn.setCellRenderer(treeTableCellRenderer); }
/** * Use the given <code>renderer</code> as the new delegate renderer of the * {@link TreeTableCellRenderer} which is responsible for rendering the * data associated with each tree node in the hierarchy column. */ public void setDelegateRenderer(TableCellRenderer renderer) { checkAccessThread(); treeTableCellRenderer.setDelegate(renderer); }
/** * Sets whether the expander is displayed for nodes that do not contain * children but are allowed to contain children, and thus may accumulate * children in the future. If this property is <tt>true</tt> then empty * nodes that may contain children in the future are displayed with a * visible expander; otherwise they are displayed without the expander. * A node signals that it may contain children in the future by returning * <tt>true</tt> from {@link ca.odell.glazedlists.TreeList.Format#allowsChildren(Object)}. */ public void setShowExpanderForEmptyParent(boolean showExpanderForEmptyParent) { checkAccessThread(); if (this.showExpanderForEmptyParent == showExpanderForEmptyParent) { return; } this.showExpanderForEmptyParent = showExpanderForEmptyParent; // indicate the new property value to the renderer and editor treeTableCellRenderer.setShowExpanderForEmptyParent(showExpanderForEmptyParent); treeTableCellEditor.setShowExpanderForEmptyParent(showExpanderForEmptyParent); // repaint the table so the display is updated table.repaint(); }
this.treeTableCellRenderer = new TreeTableCellRenderer(originalRenderer, treeList); viewColumn.setCellRenderer(treeTableCellRenderer);
treeTableCellRenderer.dispose(); treeTableCellEditor.dispose();
/** * 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; }
/** * Use the given <code>treeTableCellRenderer</code> when rendering the * hierarchy column of the tree table. */ public void setRenderer(TreeTableCellRenderer treeTableCellRenderer) { checkAccessThread(); // ensure we can find the view column index of the hierarchical column final int viewColumnIndex = table.convertColumnIndexToView(hierarchyColumnModelIndex); if (viewColumnIndex == -1) { throw new IllegalArgumentException("Unable to locate a view index for the given model index: " + hierarchyColumnModelIndex); } // look up the hierarchical TableColumn final TableColumn viewColumn = table.getColumnModel().getColumn(viewColumnIndex); // dispose the old renderer this.treeTableCellRenderer.dispose(); // install the new renderer this.treeTableCellRenderer = treeTableCellRenderer; treeTableCellRenderer.setShowExpanderForEmptyParent(showExpanderForEmptyParent); viewColumn.setCellRenderer(treeTableCellRenderer); }
/** * Use the given <code>renderer</code> as the new delegate renderer of the * {@link TreeTableCellRenderer} which is responsible for rendering the * data associated with each tree node in the hierarchy column. */ public void setDelegateRenderer(TableCellRenderer renderer) { checkAccessThread(); treeTableCellRenderer.setDelegate(renderer); }
/** * Returns the <code>renderer</code> responsible for rendering the data * associated with each tree node in the hierarchy column. */ public TableCellRenderer getDelegateRenderer() { return treeTableCellRenderer.getDelegate(); }
/** * Decorate the component returned from the <code>delegate</code> with * extra components that display the tree node's location within the tree. * If <code>delegate</code> is <tt>null</tt> then a * {@link DefaultTableCellRenderer} will be used as the delegate. * * @param delegate the renderer that produces the data for the tree node * @param treeList the data structure that answers questions about the tree * node and the tree that contains it */ public TreeTableCellRenderer(TableCellRenderer delegate, TreeList treeList) { this.delegate = delegate == null ? createDelegateRenderer() : delegate; this.treeList = treeList; }