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
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
ConstructorsConstructorDescriptionCreates the default DateCellEditor that does not move the selection on committing the value by pressing enter.DateCellEditor(boolean moveSelectionOnEnter) Creates a DateCellEditor. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.eclipse.swt.widgets.ControlactivateCell(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.voidclose()Close/dispose the containedControlorg.eclipse.swt.widgets.DateTimecreateEditorControl(org.eclipse.swt.widgets.Composite parent) Creates the editor control that is wrapped by this ICellEditor.Converts the current value in this editor using the configuredIDisplayConverter.org.eclipse.swt.widgets.DateTimeReturns the current value in this editor prior to conversion.voidsetCanonicalValue(Object canonicalValue) Sets the given canonical value to the wrapped editor control.voidsetEditorValue(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 Details
-
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 Details
-
getEditorValue
Description copied from interface:ICellEditorReturns 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
Description copied from interface:ICellEditorSets 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
Description copied from class:AbstractCellEditorConverts the current value in this editor using the configuredIDisplayConverter. If there is noIDisplayConverterregistered for this editor, the value itself will be returned.- Specified by:
getCanonicalValuein interfaceICellEditor- Overrides:
getCanonicalValuein classAbstractCellEditor- Returns:
- The canonical value after converting the current value or the
value itself if no
IDisplayConverteris configured. - See Also:
-
setCanonicalValue
Description copied from interface:ICellEditorSets 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:
setCanonicalValuein interfaceICellEditor- Overrides:
setCanonicalValuein 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:ICellEditorCreates 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:AbstractCellEditorThis 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:
activateCellin 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
Controlto be used for capturing the new cell value.
-
close
public void close()Description copied from interface:ICellEditorClose/dispose the containedControl- Specified by:
closein interfaceICellEditor- Overrides:
closein classAbstractCellEditor
-