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.

  • 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

      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 configured IDisplayConverter. If there is no IDisplayConverter registered for this editor, the value itself will be returned.
      Specified by:
      getCanonicalValue in interface ICellEditor
      Overrides:
      getCanonicalValue in class AbstractCellEditor
      Returns:
      The canonical value after converting the current value or the value itself if no IDisplayConverter is configured.
      See Also:
    • 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 configured IDisplayConverter.
      Specified by:
      setCanonicalValue in interface ICellEditor
      Overrides:
      setCanonicalValue in class AbstractCellEditor
      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 be null
      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 by AbstractCellEditor.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 class AbstractCellEditor
      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 contained Control
      Specified by:
      close in interface ICellEditor
      Overrides:
      close in class AbstractCellEditor