Class TextCellEditor

java.lang.Object
org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor
org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor
All Implemented Interfaces:
ICellEditor
Direct Known Subclasses:
FilterRowTextCellEditor, MultiLineTextCellEditor, PasswordCellEditor

public class TextCellEditor extends AbstractCellEditor
ICellEditor implementation that wraps a SWT Text control to support text editing. This is also the default editor in NatTable if you didn't configure something else.
  • Field Details

    • decorationProvider

      protected final ControlDecorationProvider decorationProvider
      The ControlDecorationProvider responsible for adding a ControlDecoration to the wrapped editor control. Can be configured via convenience methods of this TextCellEditor.
    • commitOnEnter

      protected boolean commitOnEnter
      Flag to determine whether this editor should try to commit and close on pressing the ENTER key. The default is true. For a multi line text editor, the ENTER key might be used to insert a new line instead of committing the value when opened in a dialog. In that case the value should not be committed, as applying the dialog will trigger the commit. For inline editors setting commitWithCtrlKey to true might be interesting in combination with setting this value to true, which means that the commit operation is only performed if CTRL + ENTER is pressed.
    • controlContentAdapter

      protected org.eclipse.jface.fieldassist.IControlContentAdapter controlContentAdapter
      Since:
      1.4
      See Also:
      • ContentProposalAdapter(Control, IControlContentAdapter, IContentProposalProvider, KeyStroke, char[])
    • proposalProvider

      protected org.eclipse.jface.fieldassist.IContentProposalProvider proposalProvider
      Since:
      1.4
      See Also:
      • ContentProposalAdapter(Control, IControlContentAdapter, IContentProposalProvider, KeyStroke, char[])
    • keyStroke

      protected org.eclipse.jface.bindings.keys.KeyStroke keyStroke
      Since:
      1.4
      See Also:
      • ContentProposalAdapter(Control, IControlContentAdapter, IContentProposalProvider, KeyStroke, char[])
    • autoActivationCharacters

      protected char[] autoActivationCharacters
      Since:
      1.4
      See Also:
      • ContentProposalAdapter(Control, IControlContentAdapter, IContentProposalProvider, KeyStroke, char[])
    • proposalAcceptanceStyle

      protected int proposalAcceptanceStyle
      Since:
      2.0
      See Also:
      • ContentProposalAdapter.setProposalAcceptanceStyle(int)
    • autoActivationDelay

      protected int autoActivationDelay
      Since:
      2.0
      See Also:
      • ContentProposalAdapter.setAutoActivationDelay(int)
    • contentProposalAdapter

      protected org.eclipse.jface.fieldassist.ContentProposalAdapter contentProposalAdapter
      The active ContentProposalAdapter if supported.
      Since:
      2.0
  • Constructor Details

    • TextCellEditor

      public TextCellEditor()
      Creates the default TextCellEditor that does not commit on pressing the up/down arrow keys and will not move the selection on committing a value by pressing enter.
    • TextCellEditor

      public TextCellEditor(boolean commitOnUpDown)
      Creates a TextCellEditor that will not move the selection on committing a value by pressing enter.
      Parameters:
      commitOnUpDown - Flag to configure whether the editor should commit and move the selection in the corresponding way if the up or down key is pressed.
    • TextCellEditor

      public TextCellEditor(boolean commitOnUpDown, boolean moveSelectionOnEnter)
      Creates a TextCellEditor that will not move the selection on pressing the left or right arrow keys on the according edges.
      Parameters:
      commitOnUpDown - Flag to configure whether the editor should commit and move the selection in the corresponding way if the up or down key is pressed.
      moveSelectionOnEnter - Flag to configure whether the selection should move after a value was committed after pressing enter.
    • TextCellEditor

      public TextCellEditor(boolean commitOnUpDown, boolean moveSelectionOnEnter, boolean commitOnLeftRight)
      Creates a TextCellEditor.
      Parameters:
      commitOnUpDown - Flag to configure whether the editor should commit and move the selection in the corresponding way if the up or down key is pressed.
      moveSelectionOnEnter - Flag to configure whether the selection should move after a value was committed after pressing enter.
      commitOnLeftRight - Flag to configure whether the editor should commit and move the selection in the corresponding way if the left or right key is pressed on the according content edge.
      Since:
      1.4
  • Method Details

    • 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.
    • getEditorValue

      public String 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.
    • getEditorControl

      public org.eclipse.swt.widgets.Text getEditorControl()
      Returns:
      The editor control that is wrapped by this ICellEditor.
    • createEditorControl

      public org.eclipse.swt.widgets.Text 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.
    • createEditorControl

      protected org.eclipse.swt.widgets.Text createEditorControl(org.eclipse.swt.widgets.Composite parent, int style)
      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
      style - The SWT style of the text control to create.
      Returns:
      The created editor control that is wrapped by this ICellEditor.
    • getTextKeyListener

      protected org.eclipse.swt.events.KeyListener getTextKeyListener()
      Returns:
      The KeyListener that is added to the Text control to commit or close the editor for special key strokes and executes conversion/validation on input to the editor.
      Since:
      2.4
    • 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
    • isEditable

      public boolean isEditable()
      Returns:
      true if the wrapped Text control is editable, false if not.
    • setEditable

      public void setEditable(boolean editable)
      Parameters:
      editable - true if the wrapped Text control should be editable, false if not.
    • getSelectionMode

      public final EditorSelectionEnum getSelectionMode()
      Returns the current configured selection mode that is used on activating the wrapped text editor control. By default this is null which causes the following default behaviour. If the text editor control is activated with an initial value then the selection is set at the end of the containing text. If it is activated only specifying the original canonical value, the default behaviour is to select the whole text contained in the text editor control.
      Returns:
      The current configured selection mode, null for default behaviour.
    • setSelectionMode

      public final void setSelectionMode(EditorSelectionEnum selectionMode)
      Set the selection mode that should be used on the content of the wrapped text editor control when it gets activated. By setting a value explicitly you configure the selection mode for both cases, activating the wrapped text editor control with and without an initial value. Setting this value to null will reactivate the default behaviour like described here getSelectionMode().
      Parameters:
      selectionMode - The selection mode that should be used on the content of the wrapped text editor control when it gets activated.
    • getDecorationProvider

      public ControlDecorationProvider getDecorationProvider()
      Returns:
      The ControlDecorationProvider responsible for adding a ControlDecoration to the wrapped editor control.
    • setErrorDecorationEnabled

      public void setErrorDecorationEnabled(boolean enabled)
      Enables/disables the error decoration for the wrapped text control.
      Parameters:
      enabled - true if an error decoration should be added to the wrapped text control, false if not.
    • showErrorDecorationHover

      public void showErrorDecorationHover(String customErrorText)
      Force the error decoration hover to show immediately.
      Parameters:
      customErrorText - The text to show in the hover popup.
      See Also:
      • ControlDecoration.show()
      • ControlDecoration.showHoverText(String)
    • setFieldDecorationId

      public void setFieldDecorationId(String fieldDecorationId)
      Set the id of the FieldDecoration to be used by the local ControlDecorationProvider.
      Parameters:
      fieldDecorationId - The String to determine the FieldDecoration to use by the ControlDecoration that is provided by this ControlDecorationProvider.
      See Also:
      • FieldDecorationRegistry.getFieldDecoration(String)
    • setDecorationPositionOverride

      public void setDecorationPositionOverride(int decorationPositionOverride)
      Set the position of the control decoration relative to the control. It should include style bits describing both the vertical and horizontal orientation.
      Parameters:
      decorationPositionOverride - bit-wise or of position constants (SWT.TOP, SWT.BOTTOM, SWT.LEFT, SWT.RIGHT, and SWT.CENTER).
      See Also:
      • ControlDecoration(Control, int)
    • getInputConversionErrorHandler

      public IEditErrorHandler getInputConversionErrorHandler()
      Returns:
      The IEditErrorHandler that is used for showing conversion errors on typing into this editor. By default this is the RenderErrorHandling which will render the content in the editor red to indicate a conversion error.
    • setInputConversionErrorHandler

      public void setInputConversionErrorHandler(IEditErrorHandler inputConversionErrorHandler)
      Parameters:
      inputConversionErrorHandler - The IEditErrorHandler that is should be used for showing conversion errors on typing into this editor.
    • getInputValidationErrorHandler

      public IEditErrorHandler getInputValidationErrorHandler()
      Returns:
      The IEditErrorHandler that is used for showing validation errors on typing into this editor. By default this is the RenderErrorHandling which will render the content in the editor red to indicate a validation error.
    • setInputValidationErrorHandler

      public void setInputValidationErrorHandler(IEditErrorHandler inputValidationErrorHandler)
      Parameters:
      inputValidationErrorHandler - The IEditErrorHandler that is should used for showing validation errors on typing into this editor.
    • enableContentProposal

      public void enableContentProposal(org.eclipse.jface.fieldassist.IControlContentAdapter controlContentAdapter, org.eclipse.jface.fieldassist.IContentProposalProvider proposalProvider, org.eclipse.jface.bindings.keys.KeyStroke keyStroke, char[] autoActivationCharacters)
      Configure the parameters necessary to create the content proposal adapter on opening an editor.
      Parameters:
      controlContentAdapter - the IControlContentAdapter used to obtain and update the control's contents as proposals are accepted. May not be null.
      proposalProvider - the IContentProposalProvider used to obtain content proposals for this control, or null if no content proposal is available.
      keyStroke - the keystroke that will invoke the content proposal popup. If this value is null, then proposals will be activated automatically when any of the auto activation characters are typed.
      autoActivationCharacters - An array of characters that trigger auto-activation of content proposal. If specified, these characters will trigger auto-activation of the proposal popup, regardless of whether an explicit invocation keyStroke was specified. If this parameter is null, then only a specified keyStroke will invoke content proposal. If this parameter is null and the keyStroke parameter is null, then all alphanumeric characters will auto-activate content proposal.
      Since:
      1.4
      See Also:
      • ContentProposalAdapter
    • enableContentProposal

      public void enableContentProposal(org.eclipse.jface.fieldassist.IControlContentAdapter controlContentAdapter, org.eclipse.jface.fieldassist.IContentProposalProvider proposalProvider, org.eclipse.jface.bindings.keys.KeyStroke keyStroke, char[] autoActivationCharacters, int proposalAcceptanceStyle, int autoActivationDelay)
      Configure the parameters necessary to create the content proposal adapter on opening an editor.
      Parameters:
      controlContentAdapter - the IControlContentAdapter used to obtain and update the control's contents as proposals are accepted. May not be null.
      proposalProvider - the IContentProposalProvider used to obtain content proposals for this control, or null if no content proposal is available.
      keyStroke - the keystroke that will invoke the content proposal popup. If this value is null, then proposals will be activated automatically when any of the auto activation characters are typed.
      autoActivationCharacters - An array of characters that trigger auto-activation of content proposal. If specified, these characters will trigger auto-activation of the proposal popup, regardless of whether an explicit invocation keyStroke was specified. If this parameter is null, then only a specified keyStroke will invoke content proposal. If this parameter is null and the keyStroke parameter is null, then all alphanumeric characters will auto-activate content proposal.
      proposalAcceptanceStyle - a constant indicating how an accepted proposal should affect the control's content. Should be one of PROPOSAL_INSERT, PROPOSAL_REPLACE, or PROPOSAL_IGNORE
      autoActivationDelay - the time in milliseconds that will pass before a popup is automatically opened
      Since:
      2.0
      See Also:
      • ContentProposalAdapter
    • configureContentProposalAdapter

      protected void configureContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter contentProposalAdapter)
      Adds the listeners necessary for interaction between the control of this TextCellEditor and the ContentProposalAdapter.
      Parameters:
      contentProposalAdapter - The ContentProposalAdapter that should be used to add content proposal abilities to this TextCellEditor.
      Since:
      1.4
    • isCommitOnEnter

      public boolean isCommitOnEnter()
      Return whether this editor should try to commit and close on pressing the ENTER key. The default is true. For a multi line text editor, the ENTER key might be used to insert a new line instead of committing the value when opened in a dialog. In that case the value should not be committed, as applying the dialog will trigger the commit. For inline editors setting commitWithCtrlKey to true might be interesting in combination with setting this value to true, which means that the commit operation is only performed if CTRL + ENTER is pressed.
      Returns:
      true if commit and close is performed on pressing the ENTER key, false if pressing ENTER does not perform a commit operation.
      Since:
      1.6
    • setCommitOnEnter

      public void setCommitOnEnter(boolean commitOnEnter)
      Configure whether this editor should try to commit and close on pressing the ENTER key. The default is true. For a multi line text editor, the ENTER key might be used to insert a new line instead of committing the value when opened in a dialog. In that case the value should not be committed, as applying the dialog will trigger the commit. For inline editors setting commitWithCtrlKey to true might be interesting in combination with setting this value to true, which means that the commit operation is only performed if CTRL + ENTER is pressed.
      Parameters:
      commitOnEnter - true to perform commit and close on pressing the ENTER key, false if pressing ENTER should not perform a commit operation.
      Since:
      1.6
    • isCommitWithCtrlKey

      public boolean isCommitWithCtrlKey()
      Return whether this editor should try to commit and close on pressing the ENTER key in combination with the CTRL state mask key, or if pressing ENTER solely should work. It is only interpreted with commitOnEnter set to true, and it is needed for a multi line text editor where a simple enter press should add a new line and a combination with CTRL should commit the value.
      Returns:
      true if committing via pressing the ENTER key is only working with the CTRL state mask key pressed. false if pressing the ENTER key solely is performing the commit.
      Since:
      1.6
    • setCommitWithCtrlKey

      public void setCommitWithCtrlKey(boolean commitWithCtrlKey)
      Configure whether this editor should try to commit and close on pressing the ENTER key in combination with the CTRL state mask key, or if pressing ENTER solely should work. It is only interpreted with commitOnEnter set to true, and it is needed for a multi line text editor where a simple enter press should add a new line and a combination with CTRL should commit the value.
      Parameters:
      commitWithCtrlKey - true if committing via pressing the ENTER key should only work with the CTRL state mask key pressed. false if pressing the ENTER key solely should perform the commit.
      Since:
      1.6
    • isProposalPopupOpen

      protected boolean isProposalPopupOpen()
      Returns:
      true if a ContentProposalAdapter is active and the proposal popup is open.
      Since:
      2.0