@Override protected int getIndent(TreeNodeData treeNodeData, boolean showExpanderForEmptyParent) { return super.getIndent(treeNodeData, showExpanderForEmptyParent) + indent; }
@Override public void editingCanceled(ChangeEvent e) { cancelCellEditing(); } @Override
/** * Returns the <code>editor</code> responsible for editing the data * associated with each tree node in the hierarchy column. */ public TableCellEditor getDelegateEditor() { return treeTableCellEditor.getDelegate(); }
/** * 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; }
/** * Use the given <code>treeTableCellEditor</code> when editing the * hierarchy column of the tree table. */ public void setEditor(TreeTableCellEditor treeTableCellEditor) { 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 editor this.treeTableCellEditor.dispose(); // install the new editor this.treeTableCellEditor = treeTableCellEditor; treeTableCellEditor.setShowExpanderForEmptyParent(showExpanderForEmptyParent); viewColumn.setCellEditor(treeTableCellEditor); }
/** * Use the given <code>editor</code> as the new delegate editor of the * {@link TreeTableCellEditor} which is responsible for editing the data * associated with each tree node in the hierarchy column. */ public void setDelegateEditor(TableCellEditor editor) { checkAccessThread(); treeTableCellEditor.setDelegate(editor); }
public void editingStopped(ChangeEvent e) { stopCellEditing(); } }
/** * Decorate the component returned from the <code>delegate</code> with * extra components that display the tree nodes location within the tree. * If <code>delegate</code> is <tt>null</tt> then a * {@link DefaultCellEditor} using a {@link JTextField} will be used as * the delegate. * * @param delegate the editor 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 TreeTableCellEditor(TableCellEditor delegate, TreeList treeList) { this.delegate = delegate == null ? createDelegateEditor() : delegate; this.delegate.addCellEditorListener(delegateListener); this.treeList = treeList; }
/** * 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(); }
treeTableCellEditor.dispose();
this.treeTableCellEditor = new TreeTableCellEditor(originalEditor, treeList); viewColumn.setCellEditor(treeTableCellEditor);
/** * 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; }
/** * Use the given <code>treeTableCellEditor</code> when editing the * hierarchy column of the tree table. */ public void setEditor(TreeTableCellEditor treeTableCellEditor) { 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 editor this.treeTableCellEditor.dispose(); // install the new editor this.treeTableCellEditor = treeTableCellEditor; treeTableCellEditor.setShowExpanderForEmptyParent(showExpanderForEmptyParent); viewColumn.setCellEditor(treeTableCellEditor); }
/** * Use the given <code>editor</code> as the new delegate editor of the * {@link TreeTableCellEditor} which is responsible for editing the data * associated with each tree node in the hierarchy column. */ public void setDelegateEditor(TableCellEditor editor) { checkAccessThread(); treeTableCellEditor.setDelegate(editor); }
public void editingStopped(ChangeEvent e) { stopCellEditing(); } }
/** * Decorate the component returned from the <code>delegate</code> with * extra components that display the tree nodes location within the tree. * If <code>delegate</code> is <tt>null</tt> then a * {@link DefaultCellEditor} using a {@link JTextField} will be used as * the delegate. * * @param delegate the editor 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 TreeTableCellEditor(TableCellEditor delegate, TreeList treeList) { this.delegate = delegate == null ? createDelegateEditor() : delegate; this.delegate.addCellEditorListener(delegateListener); this.treeList = treeList; }
/** * 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(); }
treeTableCellEditor.dispose();
this.treeTableCellEditor = new TreeTableCellEditor(originalEditor, treeList); viewColumn.setCellEditor(treeTableCellEditor);
/** * 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; }