WebObjects 5.4.2

com.webobjects.eointerface.swing
Class EOColumnEditor

java.lang.Object
  extended by com.webobjects.eointerface.swing.EOColumnEditor
All Implemented Interfaces:
CellEditor, TableCellEditor
Direct Known Subclasses:
EOTextColumnEditor

public abstract class EOColumnEditor
extends Object
implements TableCellEditor

EOColumnEditor is an abstract class that implements generalized cell editing management for javax.swing.JTables. Swing specifies that JTable cell editing is performed by an object implementing the javax.swing.table.TableCellEditor interface. EOColumnEditor implements this interface in a generalized way, and concrete subclasses such as EOTextColumnEditor perform component-specific instantiation and event communication.

EOColumnEditor is used together with EOTableColumnAssociation to allow editing of values displayed in tables. The most important function of an EOColumnEditor instance is mediating between its Component and the EOTableColumnAssociation that's bound to the edited column. This mediation enables the validation of edited values that associations are required to perform.

Create a subclass of EOColumnEditor if you want to use a Component for JTable editing for which no EOColumnEditor is implemented.

See Also:
EOTextColumnEditor

Constructor Summary
EOColumnEditor()
          Constructs a new EOColumnEditor.
 
Method Summary
 void addCellEditorListener(CellEditorListener listener)
          EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to add a listener to the list that's notified when the editor starts, stops or cancels editing.
protected  void beginEditing()
          Invoked from shouldSelectCell and getTableCellEditorComponent to inform the receiver that it should begin editing.
 void cancelCellEditing()
          EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to cancel editing.
protected abstract  Component createEditorComponent()
          Creates and returns a Component to perform the editing -- a JTextField or JComboBox, for example.
 EOTableColumnAssociation editingTableColumnAssociation()
          Returns the EOTableColumnAssociation that's bound to the column being edited (the column is cached in EOColumnEditor's implementation of shouldSelectCell and getTableCellEditorComponent).
 Component editorComponent()
          Returns the receiver's editor Component -- a user interface control that implements the editing mechanism.
protected  void endEditing()
          Invoked from cancelCellEditing and stopCellEditing to inform the receiver that it should end editing.
protected  void fireEditingCanceled()
          Sends editingCanceled to all cell editor listeners registered with the column editor.
protected  void fireEditingStopped()
          Sends editingStopped to all cell editor listeners registered with the column editor.
 Object getCellEditorValue()
          EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to return the current value in the editor.
 Component getTableCellEditorComponent(JTable table, Object initialValue, boolean isSelected, int rowIndex, int columnIndex)
          EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to set an inital value for the editor.
 boolean isCellEditable(EventObject event)
          EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to determine whether a cell can start editing.
 void removeCellEditorListener(CellEditorListener listener)
          EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to remove a listener from the list that's notified when the editor starts, stops or cancels editing.
protected abstract  void setCellEditorValue(Object value)
          Invoked from getTableCellEditorComponent to assign value as the inital editor value.
 void setEditorComponent(Component editorComponent)
          Sets the receiver's editor component to editorComponent.
 boolean shouldSelectCell(EventObject event)
          EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to determine whether a cell should be selected when edited or not.
 boolean stopCellEditing()
          EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to finish and accept editing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EOColumnEditor

public EOColumnEditor()
Constructs a new EOColumnEditor.

Method Detail

createEditorComponent

protected abstract Component createEditorComponent()
Creates and returns a Component to perform the editing -- a JTextField or JComboBox, for example. Invoked in EOColumnEditor's constructor, this method must be overridden by every subclass in order to create and return the Component it manages.

Returns:
the editor component

setCellEditorValue

protected abstract void setCellEditorValue(Object value)
Invoked from getTableCellEditorComponent to assign value as the inital editor value. Subclasses must override this method.

Parameters:
value - the editor value
See Also:
EOColumnEditor.getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int)

setEditorComponent

public void setEditorComponent(Component editorComponent)
Sets the receiver's editor component to editorComponent. Invoked in EOColumnEditor's constructor.

Parameters:
editorComponent - the Component returned from createEditorComponent
See Also:
EOColumnEditor.createEditorComponent()

editorComponent

public Component editorComponent()
Returns the receiver's editor Component -- a user interface control that implements the editing mechanism. EOColumnEditor creates the component in the constructor (through createEditorComponent).

Returns:
the editor component
See Also:
EOColumnEditor.createEditorComponent()

getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object initialValue,
                                             boolean isSelected,
                                             int rowIndex,
                                             int columnIndex)
EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to set an inital value for the editor. Sets the initial editor value through setCellEditorValue and invokes beginEditing. EOColumnEditor creates the component in the constructor (through the method createEditorComponent).

Specified by:
getTableCellEditorComponent in interface TableCellEditor
Parameters:
table - the JTable asking the editor to edit
initialValue - the value of the cell to be edited
isSelected - true if the cell is to be rendered with highlighting
rowIndex - the row of the cell being edited
columnIndex - the column of the cell being edited
Returns:
the editor component
See Also:
EOColumnEditor.setCellEditorValue(java.lang.Object), EOColumnEditor.beginEditing(), EOColumnEditor.createEditorComponent()

getCellEditorValue

public Object getCellEditorValue()
EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to return the current value in the editor. Simply returns null, so subclasses should override this method.

Specified by:
getCellEditorValue in interface CellEditor
Returns:
the editor value

shouldSelectCell

public boolean shouldSelectCell(EventObject event)
EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to determine whether a cell should be selected when edited or not. Invokes beginEditing and returns true so that by default all EOColumnEditors select the cell.

Specified by:
shouldSelectCell in interface CellEditor
Parameters:
event - the event the editor should use to start editing
Returns:
true so that the editing cell is selected
See Also:
EOColumnEditor.beginEditing()

isCellEditable

public boolean isCellEditable(EventObject event)
EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to determine whether a cell can start editing. Returns false so that by default all EOColumnEditors do not start editing.

Specified by:
isCellEditable in interface CellEditor
Parameters:
event - the event to be used by the editor to consider whether editing can start or not
Returns:
true if editing can be started

editingTableColumnAssociation

public EOTableColumnAssociation editingTableColumnAssociation()
Returns the EOTableColumnAssociation that's bound to the column being edited (the column is cached in EOColumnEditor's implementation of shouldSelectCell and getTableCellEditorComponent).

Returns:
the table column association
See Also:
EOColumnEditor.shouldSelectCell(java.util.EventObject), EOColumnEditor.getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int)

beginEditing

protected void beginEditing()
Invoked from shouldSelectCell and getTableCellEditorComponent to inform the receiver that it should begin editing. EOColumnEditor's implementation sends widgetDidBeginEditing to the EOTableColumnAssociation that's bound to the receiver's TableColumn.

Subclasses should invoke super's implementation after activating their editor Component.

See Also:
EOColumnEditor.shouldSelectCell(java.util.EventObject), EOColumnEditor.getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int)

endEditing

protected void endEditing()
Invoked from cancelCellEditing and stopCellEditing to inform the receiver that it should end editing. EOColumnEditor's implementation sends widgetDidEndEditing to the EOTableColumnAssociation that's bound to the receiver's TableColumn. Subclasses should invoke super's implementation after deactivating their editor Component.

See Also:
EOColumnEditor.cancelCellEditing(), EOColumnEditor.stopCellEditing()

cancelCellEditing

public void cancelCellEditing()
EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to cancel editing.

Specified by:
cancelCellEditing in interface CellEditor

stopCellEditing

public boolean stopCellEditing()
EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to finish and accept editing.

Specified by:
stopCellEditing in interface CellEditor
Returns:
true if the editing was stopped

addCellEditorListener

public void addCellEditorListener(CellEditorListener listener)
EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to add a listener to the list that's notified when the editor starts, stops or cancels editing.

Specified by:
addCellEditorListener in interface CellEditor
Parameters:
listener -

removeCellEditorListener

public void removeCellEditorListener(CellEditorListener listener)
EOColumnEditor's implementation of the javax.swing.table.TableCellEditor method to remove a listener from the list that's notified when the editor starts, stops or cancels editing.

Specified by:
removeCellEditorListener in interface CellEditor
Parameters:
listener -

fireEditingCanceled

protected void fireEditingCanceled()
Sends editingCanceled to all cell editor listeners registered with the column editor.


fireEditingStopped

protected void fireEditingStopped()
Sends editingStopped to all cell editor listeners registered with the column editor.


Last updated June 2008

Copyright © 2000-2008 Apple Inc.