ca.odell.glazedlists.swing
Class TreeTableCellEditor

java.lang.Object
  extended by javax.swing.AbstractCellEditor
      extended by ca.odell.glazedlists.swing.TreeTableCellEditor
All Implemented Interfaces:
Serializable, CellEditor, TableCellEditor

public class TreeTableCellEditor
extends AbstractCellEditor
implements TableCellEditor

This editor removes some of the burden of producing an appropriate looking component for the hierarchy column of a tree table. Specifically, it takes care of adding components to a panel that render a node location within the tree, but leaves the rendering of the data of the node to a delegate TableCellEditor that is supplied in the constructor.

For example, in the following tree representation, the spacing and +/- icons would be added to each tree node by this editor, while the data text would be added by the component returned from the delegate TableCellEditor.

 - Cars
   + BMW
   - Ford
       Taurus
       Focus
   - Lexus
       ES 300
       LS 600h L
 

Author:
James Lemieux
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
TreeTableCellEditor(TableCellEditor delegate, TreeList treeList)
          Decorate the component returned from the delegate with extra components that display the tree nodes location within the tree.
 
Method Summary
protected  TableCellEditor createDelegateEditor()
          Build the delegate TableCellEditor that handles editing the data of each tree node.
 void dispose()
          Cleanup the data within this editor as it is no longer being used and must be prepared for garbage collection.
 Object getCellEditorValue()
           
 TableCellEditor getDelegate()
          Returns the delegate TableCellEditor being decorated.
protected  int getIndent(TreeNodeData treeNodeData, boolean showExpanderForEmptyParent)
          Returns the number of pixels to indent the contents of the editor.
protected  int getSpacer(TreeNodeData treeNodeData, boolean showExpanderForEmptyParent)
          Returns the number of pixels of space between the expand/collapse button and the node component.
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
          Return a decorated form of the component returned by the data TableCellEditor.
 boolean isCellEditable(EventObject event)
          This method checks if the event is a MouseEvent and determines if it occurred overtop of the component created by the delegate TableCellEditor.
 boolean shouldSelectCell(EventObject anEvent)
           
 
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener, stopCellEditing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, removeCellEditorListener, stopCellEditing
 

Constructor Detail

TreeTableCellEditor

public TreeTableCellEditor(TableCellEditor delegate,
                           TreeList treeList)
Decorate the component returned from the delegate with extra components that display the tree nodes location within the tree. If delegate is null then a DefaultCellEditor using a JTextField will be used as the delegate.

Parameters:
delegate - the editor that produces the data for the tree node
treeList - the data structure that answers questions about the tree node and the tree that contains it
Method Detail

createDelegateEditor

protected TableCellEditor createDelegateEditor()
Build the delegate TableCellEditor that handles editing the data of each tree node.


getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
Return a decorated form of the component returned by the data TableCellEditor.

Specified by:
getTableCellEditorComponent in interface TableCellEditor

getIndent

protected int getIndent(TreeNodeData treeNodeData,
                        boolean showExpanderForEmptyParent)
Returns the number of pixels to indent the contents of the editor.

Parameters:
treeNodeData - hierarhical information about the node within the tree
showExpanderForEmptyParent - true indicates the expander button should always be present, even when no children yet exist

getSpacer

protected int getSpacer(TreeNodeData treeNodeData,
                        boolean showExpanderForEmptyParent)
Returns the number of pixels of space between the expand/collapse button and the node component.

Parameters:
treeNodeData - hierarhical information about the node within the tree
showExpanderForEmptyParent - true indicates the expander button should always be present, even when no children yet exist

isCellEditable

public boolean isCellEditable(EventObject event)
This method checks if the event is a MouseEvent and determines if it occurred overtop of the component created by the delegate TableCellEditor. If so, it translates the coordinates of the event so they are relative to that component and then asks the delegate TableCellEditor if it believes supports cell editing. Effectively, this implies that clicks overtop of other areas of the editor component are ignored. In truth, they are handled elsewhere (a MouseListener on the JTable installed within TreeTableSupport).

Specified by:
isCellEditable in interface CellEditor
Overrides:
isCellEditable in class AbstractCellEditor
Parameters:
event - the event attempting to begin a cell edit
Returns:
true if cell is ready for editing, false otherwise

shouldSelectCell

public boolean shouldSelectCell(EventObject anEvent)
Specified by:
shouldSelectCell in interface CellEditor
Overrides:
shouldSelectCell in class AbstractCellEditor

getCellEditorValue

public Object getCellEditorValue()
Specified by:
getCellEditorValue in interface CellEditor

getDelegate

public TableCellEditor getDelegate()
Returns the delegate TableCellEditor being decorated.


dispose

public void dispose()
Cleanup the data within this editor as it is no longer being used and must be prepared for garbage collection.



Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by hbrands at 2015-02-16 14:02