Package org.jdesktop.swingx.table
Class DatePickerCellEditor
- java.lang.Object
-
- javax.swing.AbstractCellEditor
-
- org.jdesktop.swingx.table.DatePickerCellEditor
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.CellEditor
,javax.swing.table.TableCellEditor
,javax.swing.tree.TreeCellEditor
public class DatePickerCellEditor extends javax.swing.AbstractCellEditor implements javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor
A CellEditor using a JXDatePicker as editor component.NOTE: this class will be moved!
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
clickCountToStart
protected java.text.DateFormat
dateFormat
protected JXDatePicker
datePicker
protected boolean
ignoreAction
-
Constructor Summary
Constructors Constructor Description DatePickerCellEditor()
Instantiates a editor with the default dateFormat.DatePickerCellEditor(java.text.DateFormat dateFormat)
Instantiates an editor with the given dateFormat.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
commitChange()
Commits any pending edits and returns a boolean indicating whether the commit was successful.protected java.awt.event.ActionListener
createPickerActionListener()
Creates and returns the ActionListener for the Picker.java.util.Date
getCellEditorValue()
Returns the pickers date.int
getClickCountToStart()
Returns the number of clicks needed to start editing.java.text.DateFormat[]
getFormats()
protected java.awt.event.ActionListener
getPickerActionListener()
Returns the ActionListener to add to the datePicker.java.awt.Component
getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
java.awt.Component
getTreeCellEditorComponent(javax.swing.JTree tree, java.lang.Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
protected java.util.Date
getValueAsDate(java.lang.Object value)
Returns the given value as Date.protected void
handleParseException(java.text.ParseException e)
boolean
isCellEditable(java.util.EventObject anEvent)
protected boolean
isEmpty(java.lang.Object value)
void
setClickCountToStart(int count)
Specifies the number of clicks needed to start editing.void
setFormats(java.text.DateFormat... formats)
boolean
stopCellEditing()
-
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener, shouldSelectCell
-
-
-
-
Field Detail
-
datePicker
protected JXDatePicker datePicker
-
dateFormat
protected java.text.DateFormat dateFormat
-
clickCountToStart
protected int clickCountToStart
-
ignoreAction
protected boolean ignoreAction
-
-
Constructor Detail
-
DatePickerCellEditor
public DatePickerCellEditor()
Instantiates a editor with the default dateFormat. PENDING: always override default from DatePicker?
-
DatePickerCellEditor
public DatePickerCellEditor(java.text.DateFormat dateFormat)
Instantiates an editor with the given dateFormat. If null, the datePickers default is used.- Parameters:
dateFormat
-
-
-
Method Detail
-
getCellEditorValue
public java.util.Date getCellEditorValue()
Returns the pickers date. Note: the date is only meaningful after a stopEditing and before the next call to getTableCellEditorComponent.- Specified by:
getCellEditorValue
in interfacejavax.swing.CellEditor
-
isCellEditable
public boolean isCellEditable(java.util.EventObject anEvent)
- Specified by:
isCellEditable
in interfacejavax.swing.CellEditor
- Overrides:
isCellEditable
in classjavax.swing.AbstractCellEditor
-
stopCellEditing
public boolean stopCellEditing()
Overridden to commit pending edits. If commit successful, returns super, else returns false.
- Specified by:
stopCellEditing
in interfacejavax.swing.CellEditor
- Overrides:
stopCellEditing
in classjavax.swing.AbstractCellEditor
-
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- 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
-
getTableCellEditorComponent
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
- Specified by:
getTableCellEditorComponent
in interfacejavax.swing.table.TableCellEditor
-
getTreeCellEditorComponent
public java.awt.Component getTreeCellEditorComponent(javax.swing.JTree tree, java.lang.Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
- Specified by:
getTreeCellEditorComponent
in interfacejavax.swing.tree.TreeCellEditor
-
getValueAsDate
protected java.util.Date getValueAsDate(java.lang.Object value)
Returns the given value as Date. PENDING: abstract into something pluggable (like StringValue in ComponentProvider?)- Parameters:
value
- the value to map as Date- Returns:
- the value as Date or null, if not successful.
-
handleParseException
protected void handleParseException(java.text.ParseException e)
- Parameters:
e
-
-
isEmpty
protected boolean isEmpty(java.lang.Object value)
-
commitChange
protected boolean commitChange()
Commits any pending edits and returns a boolean indicating whether the commit was successful.- Returns:
- true if the edit was valid, false otherwise.
-
getFormats
public java.text.DateFormat[] getFormats()
- Returns:
- the DatePicker's formats.
-
setFormats
public void setFormats(java.text.DateFormat... formats)
- Parameters:
formats
- the formats to use in the datepicker.- See Also:
JXDatePicker.setFormats(DateFormat...)
-
getPickerActionListener
protected java.awt.event.ActionListener getPickerActionListener()
Returns the ActionListener to add to the datePicker.- Returns:
- the action listener to listen for datePicker's action events.
-
createPickerActionListener
protected java.awt.event.ActionListener createPickerActionListener()
Creates and returns the ActionListener for the Picker.- Returns:
- the ActionListener to listen for Picker's action events.
-
-