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 SWTText
control to support text editing. This is also the default editor in NatTable if you didn't configure something else.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor
AbstractCellEditor.InlineFocusListener, AbstractCellEditor.InlineTraverseListener
-
-
Field Summary
Fields Modifier and Type Field Description protected char[]
autoActivationCharacters
protected int
autoActivationDelay
protected boolean
commitOnEnter
Flag to determine whether this editor should try to commit and close on pressing the ENTER key.protected org.eclipse.jface.fieldassist.ContentProposalAdapter
contentProposalAdapter
The activeContentProposalAdapter
if supported.protected org.eclipse.jface.fieldassist.IControlContentAdapter
controlContentAdapter
protected ControlDecorationProvider
decorationProvider
TheControlDecorationProvider
responsible for adding aControlDecoration
to the wrapped editor control.protected org.eclipse.jface.bindings.keys.KeyStroke
keyStroke
protected int
proposalAcceptanceStyle
protected org.eclipse.jface.fieldassist.IContentProposalProvider
proposalProvider
-
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 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(boolean commitOnUpDown)
Creates a TextCellEditor that will not move the selection on committing a value by pressing enter.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.TextCellEditor(boolean commitOnUpDown, boolean moveSelectionOnEnter, boolean commitOnLeftRight)
Creates a TextCellEditor.
-
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
protected void
configureContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter contentProposalAdapter)
Adds the listeners necessary for interaction between the control of this TextCellEditor and the ContentProposalAdapter.org.eclipse.swt.widgets.Text
createEditorControl(org.eclipse.swt.widgets.Composite parent)
Creates the editor control that is wrapped by this ICellEditor.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.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.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.ControlDecorationProvider
getDecorationProvider()
org.eclipse.swt.widgets.Text
getEditorControl()
String
getEditorValue()
Returns the current value in this editor prior to conversion.IEditErrorHandler
getInputConversionErrorHandler()
IEditErrorHandler
getInputValidationErrorHandler()
EditorSelectionEnum
getSelectionMode()
Returns the current configured selection mode that is used on activating the wrapped text editor control.boolean
isCommitOnEnter()
Return whether this editor should try to commit and close on pressing the ENTER key.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.boolean
isEditable()
protected boolean
isProposalPopupOpen()
void
setCommitOnEnter(boolean commitOnEnter)
Configure whether this editor should try to commit and close on pressing the ENTER key.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.void
setDecorationPositionOverride(int decorationPositionOverride)
Set the position of the control decoration relative to the control.void
setEditable(boolean editable)
void
setEditorValue(Object value)
Sets the given value to editor control.void
setErrorDecorationEnabled(boolean enabled)
Enables/disables the error decoration for the wrapped text control.void
setFieldDecorationId(String fieldDecorationId)
Set the id of theFieldDecoration
to be used by the localControlDecorationProvider
.void
setInputConversionErrorHandler(IEditErrorHandler inputConversionErrorHandler)
void
setInputValidationErrorHandler(IEditErrorHandler inputValidationErrorHandler)
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.void
showErrorDecorationHover(String customErrorText)
Force the error decoration hover to show immediately.-
Methods inherited from class org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor
activateAtAnyPosition, activateCell, activateOnTraversal, addEditorControlListeners, calculateControlBounds, commit, commit, commit, getCanonicalValue, getCanonicalValue, getColumnIndex, getColumnPosition, getRowIndex, getRowPosition, handleConversion, isClosed, openAdjacentEditor, openInline, openMultiEditDialog, removeEditorControlListeners, setCanonicalValue, setDataValidator, supportMultiEdit, validateCanonicalValue, validateCanonicalValue
-
-
-
-
Field Detail
-
decorationProvider
protected final ControlDecorationProvider decorationProvider
TheControlDecorationProvider
responsible for adding aControlDecoration
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 istrue
. 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 settingcommitWithCtrlKey
totrue
might be interesting in combination with setting this value totrue
, 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 activeContentProposalAdapter
if supported.- Since:
- 2.0
-
-
Constructor Detail
-
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 Detail
-
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.
-
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 benull
- 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 benull
style
- The SWT style of the text control to create.- Returns:
- The created editor control that is wrapped by this ICellEditor.
-
close
public void close()
Description copied from interface:ICellEditor
Close/dispose the containedControl
- Specified by:
close
in interfaceICellEditor
- Overrides:
close
in classAbstractCellEditor
-
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 isnull
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 tonull
will reactivate the default behaviour like described heregetSelectionMode()
.- 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 aControlDecoration
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 theFieldDecoration
to be used by the localControlDecorationProvider
.- Parameters:
fieldDecorationId
- The String to determine theFieldDecoration
to use by theControlDecoration
that is provided by thisControlDecorationProvider
.- 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
, andSWT.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 theRenderErrorHandling
which will render the content in the editor red to indicate a conversion error.
-
setInputConversionErrorHandler
public void setInputConversionErrorHandler(IEditErrorHandler inputConversionErrorHandler)
- Parameters:
inputConversionErrorHandler
- TheIEditErrorHandler
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 theRenderErrorHandling
which will render the content in the editor red to indicate a validation error.
-
setInputValidationErrorHandler
public void setInputValidationErrorHandler(IEditErrorHandler inputValidationErrorHandler)
- Parameters:
inputValidationErrorHandler
- TheIEditErrorHandler
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
- theIControlContentAdapter
used to obtain and update the control's contents as proposals are accepted. May not benull
.proposalProvider
- theIContentProposalProvider
used to obtain content proposals for this control, ornull
if no content proposal is available.keyStroke
- the keystroke that will invoke the content proposal popup. If this value isnull
, 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 isnull
, then only a specified keyStroke will invoke content proposal. If this parameter isnull
and the keyStroke parameter isnull
, 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
- theIControlContentAdapter
used to obtain and update the control's contents as proposals are accepted. May not benull
.proposalProvider
- theIContentProposalProvider
used to obtain content proposals for this control, ornull
if no content proposal is available.keyStroke
- the keystroke that will invoke the content proposal popup. If this value isnull
, 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 isnull
, then only a specified keyStroke will invoke content proposal. If this parameter isnull
and the keyStroke parameter isnull
, 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 ofPROPOSAL_INSERT
,PROPOSAL_REPLACE
, orPROPOSAL_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
- TheContentProposalAdapter
that should be used to add content proposal abilities to thisTextCellEditor
.- Since:
- 1.4
-
isCommitOnEnter
public boolean isCommitOnEnter()
Return whether this editor should try to commit and close on pressing the ENTER key. The default istrue
. 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 settingcommitWithCtrlKey
totrue
might be interesting in combination with setting this value totrue
, 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 istrue
. 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 settingcommitWithCtrlKey
totrue
might be interesting in combination with setting this value totrue
, 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 withcommitOnEnter
set totrue
, 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 withcommitOnEnter
set totrue
, 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 aContentProposalAdapter
is active and the proposal popup is open.- Since:
- 2.0
-
-