Package org.jdesktop.swingx.table
Class DatePickerCellEditor
java.lang.Object
javax.swing.AbstractCellEditor
org.jdesktop.swingx.table.DatePickerCellEditor
- All Implemented Interfaces:
Serializable,CellEditor,TableCellEditor,TreeCellEditor
public class DatePickerCellEditor
extends AbstractCellEditor
implements TableCellEditor, TreeCellEditor
A CellEditor using a JXDatePicker as editor component.
NOTE: this class will be moved!
- Author:
- Richard Osbald, Jeanette Winzenburg
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected DateFormatprotected JXDatePickerprotected booleanFields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a editor with the default dateFormat.DatePickerCellEditor(DateFormat dateFormat) Instantiates an editor with the given dateFormat. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanCommits any pending edits and returns a boolean indicating whether the commit was successful.protected ActionListenerCreates and returns the ActionListener for the Picker.Returns the pickers date.intReturns the number of clicks needed to start editing.protected ActionListenerReturns the ActionListener to add to the datePicker.getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) protected DategetValueAsDate(Object value) Returns the given value as Date.protected voidbooleanisCellEditable(EventObject anEvent) protected booleanempty checkvoidsetClickCountToStart(int count) Specifies the number of clicks needed to start editing.voidsetFormats(DateFormat... formats) booleanMethods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener, shouldSelectCellMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, removeCellEditorListener, shouldSelectCell
-
Field Details
-
datePicker
-
dateFormat
-
clickCountToStart
protected int clickCountToStart -
ignoreAction
protected boolean ignoreAction
-
-
Constructor Details
-
DatePickerCellEditor
public DatePickerCellEditor()Instantiates a editor with the default dateFormat. PENDING: always override default from DatePicker? -
DatePickerCellEditor
Instantiates an editor with the given dateFormat. If null, the datePickers default is used.- Parameters:
dateFormat- DateFormat
-
-
Method Details
-
getCellEditorValue
Returns the pickers date. Note: the date is only meaningful after a stopEditing and before the next call to getTableCellEditorComponent.- Specified by:
getCellEditorValuein interfaceCellEditor
-
isCellEditable
- Specified by:
isCellEditablein interfaceCellEditor- Overrides:
isCellEditablein classAbstractCellEditor
-
stopCellEditing
public boolean stopCellEditing()Overridden to commit pending edits. If commit successful, returns super, else returns false.
- Specified by:
stopCellEditingin interfaceCellEditor- Overrides:
stopCellEditingin classAbstractCellEditor
-
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
public int getClickCountToStart()Returns the number of clicks needed to start editing.- Returns:
- the number of clicks needed to start editing
-
getTableCellEditorComponent
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) - Specified by:
getTableCellEditorComponentin interfaceTableCellEditor
-
getTreeCellEditorComponent
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) - Specified by:
getTreeCellEditorComponentin interfaceTreeCellEditor
-
getValueAsDate
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
- Parameters:
e- ParseException
-
isEmpty
empty check- Parameters:
value- Object- Returns:
- value is empty
-
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
- Returns:
- the DatePicker's formats.
- See Also:
-
setFormats
- Parameters:
formats- the formats to use in the datepicker.- See Also:
-
getPickerActionListener
Returns the ActionListener to add to the datePicker.- Returns:
- the action listener to listen for datePicker's action events.
-
createPickerActionListener
Creates and returns the ActionListener for the Picker.- Returns:
- the ActionListener to listen for Picker's action events.
-