Class DateCellEditor
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor
-
- org.eclipse.nebula.widgets.nattable.edit.editor.DateCellEditor
-
- All Implemented Interfaces:
ICellEditor
public class DateCellEditor extends AbstractCellEditor
ICellEditor implementation that uses a DateTime control for editing. It supports objects of type Date and Calendar aswell.Introduces the contract that the editor control value is of type Calendar. Therefore the methods to deal with the canonical values need to be overriden too, to avoid conversion of the canonical value to display value by using the IDisplayConverter that is registered together with this editor.
Note: This is an example implementation for a Date editor. As the SWT DateTime control has some serious issues like it is not nullable, has issues on setting the focus programmatically and it is not possible to open the dropdown programmatically, we suggest to rather use some Nebula widget or a custom widget for date editing.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor
AbstractCellEditor.InlineFocusListener, AbstractCellEditor.InlineTraverseListener
-
-
Field Summary
-
Fields inherited from class org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor
cellStyle, configRegistry, conversionEditErrorHandler, dataValidator, displayConverter, editMode, focusListener, labelStack, layerCell, parent, traverseListener, validationEditErrorHandler
-
-
Constructor Summary
Constructors Constructor Description DateCellEditor()
Creates the default DateCellEditor that does not move the selection on committing the value by pressing enter.DateCellEditor(boolean moveSelectionOnEnter)
Creates a DateCellEditor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.eclipse.swt.widgets.Control
activateCell(org.eclipse.swt.widgets.Composite parent, Object originalCanonicalValue)
This method will be called byAbstractCellEditor.activateCell(Composite, Object, EditModeEnum, ICellEditHandler, ILayerCell, IConfigRegistry)
after initializing the activation values and before adding the default listeners.void
close()
Close/dispose the containedControl
org.eclipse.swt.widgets.DateTime
createEditorControl(org.eclipse.swt.widgets.Composite parent)
Creates the editor control that is wrapped by this ICellEditor.Object
getCanonicalValue()
Converts the current value in this editor using the configuredIDisplayConverter
.org.eclipse.swt.widgets.DateTime
getEditorControl()
Object
getEditorValue()
Returns the current value in this editor prior to conversion.void
setCanonicalValue(Object canonicalValue)
Sets the given canonical value to the wrapped editor control.void
setEditorValue(Object value)
Sets the given value to editor control.-
Methods inherited from class org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor
activateAtAnyPosition, activateCell, activateOnTraversal, addEditorControlListeners, calculateControlBounds, commit, commit, commit, getCanonicalValue, getColumnIndex, getColumnPosition, getRowIndex, getRowPosition, handleConversion, isClosed, openAdjacentEditor, openInline, openMultiEditDialog, removeEditorControlListeners, setDataValidator, supportMultiEdit, validateCanonicalValue, validateCanonicalValue
-
-
-
-
Constructor Detail
-
DateCellEditor
public DateCellEditor()
Creates the default DateCellEditor that does not move the selection on committing the value by pressing enter.
-
DateCellEditor
public DateCellEditor(boolean moveSelectionOnEnter)
Creates a DateCellEditor.- Parameters:
moveSelectionOnEnter
- Flag to configure whether the selection should move after a value was committed after pressing enter.
-
-
Method Detail
-
getEditorValue
public Object getEditorValue()
Description copied from interface:ICellEditor
Returns the current value in this editor prior to conversion. For a text editor that is used to edit integer values, this would mean it returns the text value instead of the converted integer value. This method is only intended to be used internally .- Returns:
- The current value in this editor prior to conversion.
-
setEditorValue
public void setEditorValue(Object value)
Description copied from interface:ICellEditor
Sets the given value to editor control. This method is used to put the display values to the wrapped editor.- Parameters:
value
- The display value to set to the wrapped editor control.
-
getCanonicalValue
public Object getCanonicalValue()
Description copied from class:AbstractCellEditor
Converts the current value in this editor using the configuredIDisplayConverter
. If there is noIDisplayConverter
registered for this editor, the value itself will be returned.- Specified by:
getCanonicalValue
in interfaceICellEditor
- Overrides:
getCanonicalValue
in classAbstractCellEditor
- Returns:
- The canonical value after converting the current value or the
value itself if no
IDisplayConverter
is configured. - See Also:
IDisplayConverter
-
setCanonicalValue
public void setCanonicalValue(Object canonicalValue)
Description copied from interface:ICellEditor
Sets the given canonical value to the wrapped editor control. Prior to setting the value it needs to be converted to the display value, using the configuredIDisplayConverter
.- Specified by:
setCanonicalValue
in interfaceICellEditor
- Overrides:
setCanonicalValue
in classAbstractCellEditor
- Parameters:
canonicalValue
- The canonical value to be set to the wrapped editor control.
-
getEditorControl
public org.eclipse.swt.widgets.DateTime getEditorControl()
- Returns:
- The editor control that is wrapped by this ICellEditor.
-
createEditorControl
public org.eclipse.swt.widgets.DateTime createEditorControl(org.eclipse.swt.widgets.Composite parent)
Description copied from interface:ICellEditor
Creates the editor control that is wrapped by this ICellEditor. Will use the style configurations in ConfigRegistry for styling the control.- Parameters:
parent
- The Composite that will be the parent of the new editor control. Can not benull
- Returns:
- The created editor control that is wrapped by this ICellEditor.
-
activateCell
protected org.eclipse.swt.widgets.Control activateCell(org.eclipse.swt.widgets.Composite parent, Object originalCanonicalValue)
Description copied from class:AbstractCellEditor
This method will be called byAbstractCellEditor.activateCell(Composite, Object, EditModeEnum, ICellEditHandler, ILayerCell, IConfigRegistry)
after initializing the activation values and before adding the default listeners. In this method the underlying editor control should be created and initialized, hiding default configuration from editor implementors.- Specified by:
activateCell
in classAbstractCellEditor
- Parameters:
parent
- The parent Composite, needed for the creation of the editor control.originalCanonicalValue
- The value that should be put to the activated editor control.- Returns:
- The SWT
Control
to be used for capturing the new cell value.
-
close
public void close()
Description copied from interface:ICellEditor
Close/dispose the containedControl
- Specified by:
close
in interfaceICellEditor
- Overrides:
close
in classAbstractCellEditor
-
-