JComponentPack 1.5.0

com.zfqjava.swing.cell
Class AbstractCellEditor

java.lang.Object
  extended by com.zfqjava.swing.cell.AbstractCellEditor
All Implemented Interfaces:
ActionListener, FocusListener, EventListener, CellEditor, ComboBoxEditor, TableCellEditor, TreeCellEditor
Direct Known Subclasses:
ColorCellEditor, DefaultCellEditor, FontCellEditor, IconCellEditor, InetAddressCellEditor, LocaleCellEditor, ObjectCellEditor, StreamCellEditor

public abstract class AbstractCellEditor
extends Object
implements CellEditor, TableCellEditor, TreeCellEditor, ComboBoxEditor, ActionListener, FocusListener

AbstractCellEditor provides a abstract cell editor, can be used as JTable, JTree cell editor.


Field Summary
static int CANCEL_EDITING_ON_FOCUS_LOST
          Identifies when current editor's focus lost, cancel editing.
protected  ChangeEvent changeEvent
           
static int COMMIT
          Identifies when stop editing, commitEdit should be invoked.
static int COMMIT_OR_EDITING
          Identifies when stop editing, commitEdit should be invoked.
static int COMMIT_OR_REVERT
          Identifies when stop editing, commitEdit should be invoked.
static int DO_NOTHING_ON_FOCUS_LOST
          Identifies when current editor's focus lost, do nothing.
protected  EventListenerList listenerList
           
static int STOP_EDITING_ON_FOCUS_LOST
          Identifies when current editor's focus lost, stop editing.
protected  boolean useSelectionColor
          True use the selection color when the cell is selected.
 
Constructor Summary
AbstractCellEditor()
           
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addActionListener(ActionListener l)
           
 void addCellEditorListener(CellEditorListener l)
          Adds a CellEditorListener to the listener list.
 void cancelCellEditing()
          Calls fireEditingCanceled.
protected abstract  void commitEdit()
          Commits the editing.
protected  void fireEditingCanceled()
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireEditingStopped()
          Notifies all listeners that have registered interest for notification on this event type.
 void focusGained(FocusEvent e)
           
 void focusLost(FocusEvent e)
           
 Component getCellEditorComponent(Container host, Object value, boolean isSelected)
          Sets an initial value for the editor.
 CellEditorComponentType getCellEditorComponentType()
          Returns the cell editor component type.
 CellEditorListener[] getCellEditorListeners()
          Returns an array of all the CellEditorListeners added to this AbstractCellEditor with addCellEditorListener().
 Object getCellEditorValue()
          Returns the value contained in the editor.
 CellProvider getCellProvider()
          Returns the cell provider to add extra info for current editor.
 int getClickCountToStart()
          Returns the number of clicks needed to start editing.
abstract  Component getComponent()
          Returns the component for this editor.
 int getEditingStopBehavior()
          Returns the editing stop behavior.
protected  Object getEditingValue()
          Returns the current editing value for this editor
 Component getEditorComponent()
           
 int getFocusLostBehavior()
          Returns the focus lost behavior.
 Object getItem()
           
 Component getListCellEditorComponent(JList list, Object value, int index, boolean isSelected)
          Sets an initial value for the editor.
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
          Sets an initial value for the editor.
 Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
          Sets an initial value for the editor.
protected abstract  Object getValue()
          Returns the value for current editor
 boolean isCellEditable(EventObject e)
          Returns true.
 boolean isOpaque()
          Returns the opaque property.
 void removeActionListener(ActionListener l)
           
 void removeCellEditorListener(CellEditorListener l)
          Removes a CellEditorListener from the listener list.
 void selectAll()
           
 void setCellEditorComponentType(CellEditorComponentType cellEditorComponentType)
          Sets the cell editor component type.
 void setCellProvider(CellProvider provider)
          Sets the cell provider to add extra info for current editor.
 void setClickCountToStart(int count)
          Specifies the number of clicks needed to start editing.
 void setEditingStopBehavior(int editingStopBehavior)
          Sets the editing stop behavior.
 void setFocusLostBehavior(int focusLostBehavior)
          Sets the focus lost behavior.
 void setItem(Object anObject)
           
 void setOpaque(boolean opaque)
          Sets the opaque property.
protected abstract  void setValue(Object value)
          Sets the value for current editor.
protected  void setValue(Object value, boolean isSelected)
          Sets the value.
 boolean shouldSelectCell(EventObject anEvent)
          Returns true.
 boolean stopCellEditing()
          Calls fireEditingStopped and returns true.
 void updateUI()
          Updates UI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMIT

public static final int COMMIT
Identifies when stop editing, commitEdit should be invoked. If in commiting the new value a ParseException is thrown, the invalid value will remain, the editing cannot be stoped.

Since:
JDataGrid 1.6.0
See Also:
Constant Field Values

COMMIT_OR_REVERT

public static final int COMMIT_OR_REVERT
Identifies when stop editing, commitEdit should be invoked. If in commiting the new value a ParseException is thrown, the value will be reverted, the editing will be stoped.

Since:
JDataGrid 1.6.0
See Also:
Constant Field Values

COMMIT_OR_EDITING

public static final int COMMIT_OR_EDITING
Identifies when stop editing, commitEdit should be invoked. If in commiting the new value a ParseException is thrown, the value will be the current editing value, the editing will be stoped.

Since:
JDataGrid 1.6.0
See Also:
Constant Field Values

DO_NOTHING_ON_FOCUS_LOST

public static final int DO_NOTHING_ON_FOCUS_LOST
Identifies when current editor's focus lost, do nothing. This is the default focus load behavior.

See Also:
Constant Field Values

STOP_EDITING_ON_FOCUS_LOST

public static final int STOP_EDITING_ON_FOCUS_LOST
Identifies when current editor's focus lost, stop editing.

See Also:
Constant Field Values

CANCEL_EDITING_ON_FOCUS_LOST

public static final int CANCEL_EDITING_ON_FOCUS_LOST
Identifies when current editor's focus lost, cancel editing.

See Also:
Constant Field Values

useSelectionColor

protected boolean useSelectionColor
True use the selection color when the cell is selected. The default is false.


listenerList

protected EventListenerList listenerList

changeEvent

protected transient ChangeEvent changeEvent
Constructor Detail

AbstractCellEditor

public AbstractCellEditor()
Method Detail

getCellEditorComponent

public Component getCellEditorComponent(Container host,
                                        Object value,
                                        boolean isSelected)
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called.

Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Parameters:
host - the editor component container
value - the value
isSelected - True if the specified cell was selected
Returns:
the component for editing
Since:
JFlowChart 1.0

getListCellEditorComponent

public Component getListCellEditorComponent(JList list,
                                            Object value,
                                            int index,
                                            boolean isSelected)
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called.

Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Parameters:
list - the JList that is asking the editor to edit; can be null The JList we're painting.
value - The value returned by list.getModel().getElementAt(index).
index - The cells index.
isSelected - True if the specified cell was selected.
Returns:
the component for editing

getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called.

Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Specified by:
getTableCellEditorComponent in interface TableCellEditor
Parameters:
table - the JTable that is asking the editor to edit; can be null
value - the value of the cell to be edited; it is up to the specific editor to interpret and draw the value. For example, if value is the string "true", it could be rendered as a string or it could be rendered as a check box that is checked. null is a valid value
isSelected - true if the cell is to be rendered with highlighting
row - the row of the cell being edited
column - the column of the cell being edited
Returns:
the component for editing

getTreeCellEditorComponent

public Component getTreeCellEditorComponent(JTree tree,
                                            Object value,
                                            boolean isSelected,
                                            boolean expanded,
                                            boolean leaf,
                                            int row)
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called.

Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Specified by:
getTreeCellEditorComponent in interface TreeCellEditor
Parameters:
tree - the JTree that is asking the editor to edit; this parameter can be null
value - the value of the cell to be edited
isSelected - true is the cell is to be renderer with selection highlighting
expanded - true if the node is expanded
leaf - true if the node is a leaf node
row - the row index of the node being edited
Returns:
the component for editing

updateUI

public void updateUI()
Updates UI.


setOpaque

public void setOpaque(boolean opaque)
Sets the opaque property.

Parameters:
opaque - the opaque property

isOpaque

public boolean isOpaque()
Returns the opaque property.

Returns:
the opaque property

setCellProvider

public void setCellProvider(CellProvider provider)
Sets the cell provider to add extra info for current editor.

Parameters:
provider - the cell provider
See Also:
getCellProvider()

getCellProvider

public CellProvider getCellProvider()
Returns the cell provider to add extra info for current editor.

Returns:
the cell provider to add extra info for current editor
See Also:
setCellProvider(com.zfqjava.swing.cell.CellProvider)

setValue

protected void setValue(Object value,
                        boolean isSelected)
Sets the value.

Parameters:
value - the value
isSelected - the select state

getComponent

public abstract Component getComponent()
Returns the component for this editor.

Returns:
the component for this editor

setValue

protected abstract void setValue(Object value)
Sets the value for current editor.

Parameters:
value - the value to editor

getValue

protected abstract Object getValue()
Returns the value for current editor

Returns:
the value for current editor

getEditingValue

protected Object getEditingValue()
Returns the current editing value for this editor

Returns:
the current editing value for this editor
Since:
JDataGrid 1.6.0

commitEdit

protected abstract void commitEdit()
                            throws ParseException
Commits the editing. This invoke by stopCellEditing(), if cannot commit current editing, should throws exception.

Throws:
ParseException - if cannot commit the editing

setEditingStopBehavior

public void setEditingStopBehavior(int editingStopBehavior)
Sets the editing stop behavior.

One of 3 legal values:

Parameters:
editingStopBehavior - the editing stop behavior
Since:
JDataGrid 1.6.0
See Also:
getEditingStopBehavior()

getEditingStopBehavior

public int getEditingStopBehavior()
Returns the editing stop behavior.

One of 3 legal values:

Returns:
the editing stop behavior
Since:
JDataGrid 1.6.0
See Also:
setEditingStopBehavior(int)

getCellEditorValue

public Object getCellEditorValue()
Returns the value contained in the editor.

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

setClickCountToStart

public void setClickCountToStart(int count)
Specifies the number of clicks needed to start editing.

Parameters:
count - an int specifying the number of clicks needed to start editing
Since:
JDataGrid 1.7.0
See Also:
getClickCountToStart()

getClickCountToStart

public int getClickCountToStart()
Returns the number of clicks needed to start editing.

Returns:
the number of clicks needed to start editing
Since:
JDataGrid 1.7.0

isCellEditable

public boolean isCellEditable(EventObject e)
Returns true.

Specified by:
isCellEditable in interface CellEditor
Parameters:
e - an event object
Returns:
true

shouldSelectCell

public boolean shouldSelectCell(EventObject anEvent)
Returns true.

Specified by:
shouldSelectCell in interface CellEditor
Parameters:
anEvent - an event object
Returns:
true

stopCellEditing

public boolean stopCellEditing()
Calls fireEditingStopped and returns true.

Specified by:
stopCellEditing in interface CellEditor
Returns:
true

cancelCellEditing

public void cancelCellEditing()
Calls fireEditingCanceled.

Specified by:
cancelCellEditing in interface CellEditor

getEditorComponent

public Component getEditorComponent()
Specified by:
getEditorComponent in interface ComboBoxEditor

setItem

public void setItem(Object anObject)
Specified by:
setItem in interface ComboBoxEditor

getItem

public Object getItem()
Specified by:
getItem in interface ComboBoxEditor

selectAll

public void selectAll()
Specified by:
selectAll in interface ComboBoxEditor

addActionListener

public void addActionListener(ActionListener l)
Specified by:
addActionListener in interface ComboBoxEditor

removeActionListener

public void removeActionListener(ActionListener l)
Specified by:
removeActionListener in interface ComboBoxEditor

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

addCellEditorListener

public void addCellEditorListener(CellEditorListener l)
Adds a CellEditorListener to the listener list.

Specified by:
addCellEditorListener in interface CellEditor
Parameters:
l - the new listener to be added

removeCellEditorListener

public void removeCellEditorListener(CellEditorListener l)
Removes a CellEditorListener from the listener list.

Specified by:
removeCellEditorListener in interface CellEditor
Parameters:
l - the listener to be removed

getCellEditorListeners

public CellEditorListener[] getCellEditorListeners()
Returns an array of all the CellEditorListeners added to this AbstractCellEditor with addCellEditorListener().

Returns:
all of the CellEditorListeners added or an empty array if no listeners have been added

fireEditingStopped

protected void fireEditingStopped()
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.

See Also:
EventListenerList

fireEditingCanceled

protected void fireEditingCanceled()
Notifies all listeners that have registered interest for notification on this event type. The event instance is created lazily.

See Also:
EventListenerList

getFocusLostBehavior

public int getFocusLostBehavior()
Returns the focus lost behavior.

One of 3 legal values:

Returns:
the focus lost behavior in use
Since:
JDataGrid 2.0.1
See Also:
setFocusLostBehavior(int)

setFocusLostBehavior

public void setFocusLostBehavior(int focusLostBehavior)
Sets the focus lost behavior.

One of 3 legal values:

Parameters:
focusLostBehavior - the focus lost behavior
Since:
JDataGrid 2.0.1
See Also:
getFocusLostBehavior()

focusGained

public void focusGained(FocusEvent e)
Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent e)
Specified by:
focusLost in interface FocusListener

getCellEditorComponentType

public CellEditorComponentType getCellEditorComponentType()
Returns the cell editor component type.

Returns:
the cell editor component type
Since:
JComponentPack 1.3

setCellEditorComponentType

public void setCellEditorComponentType(CellEditorComponentType cellEditorComponentType)
Sets the cell editor component type.

Parameters:
cellEditorComponentType - the cell editor component type
Since:
JComponentPack 1.3

JComponentPack 1.5.0

Send your Feedback
JComponentPack 1.5.0
Copyright © 2001-2007 Extreme Component, Inc. All rights reserved.