Class ComboBoxCellEditor
java.lang.Object
org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor
org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor
- All Implemented Interfaces:
ICellEditor
- Direct Known Subclasses:
FilterRowComboBoxCellEditor
ICellEditor implementation to provide combo box editing behaviour.
Uses the NatCombo as editor control which provides free editing in
the text control part and multi selection in the dropdown part if configured.
You can create a ComboBoxCellEditor either by setting the items to show
statically by constructor, or by using an IComboBoxDataProvider. Last
one is a way to dynamically populate the items showed in a combobox in
NatTable. It is not possible to mix these two approaches!
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor
AbstractCellEditor.InlineFocusListener, AbstractCellEditor.InlineTraverseListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag that indicates whether this ComboBoxCellEditor supports free editing in the text control of the NatCombo or not.protected org.eclipse.swt.graphics.ImageThe image to use as overlay to theTextControl if the dropdown is visible.protected intThe maximum number of items the drop down will show before introducing a scroll bar.protected booleanFlag that indicates whether this ComboBoxCellEditor supports multiple selection or not.protected StringString that is used to prefix the generated String representation showed in the text control if multiselect is supported.protected StringString that is used to suffix the generated String representation showed in the text control if multiselect is supported.protected StringString that is used to separate values in the String representation showed in the text control if multiselect is supported.protected booleanFlag that indicates whether a text box is displayed to filter the drop down optionsprotected booleanFlag that indicates whether this ComboBoxCellEditor shows checkboxes for items in the dropdown or not.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
ConstructorsConstructorDescriptionComboBoxCellEditor(Object... canonicalValues) Create a new single selectionComboBoxCellEditorbased on the given list of items, showing the default number of items in the dropdown of the combo.ComboBoxCellEditor(List<?> canonicalValues) Create a new single selectionComboBoxCellEditorbased on the given list of items, showing the default number of items in the dropdown of the combo.ComboBoxCellEditor(List<?> canonicalValues, int maxVisibleItems) Create a new single selectionComboBoxCellEditorbased on the given list of items.ComboBoxCellEditor(IComboBoxDataProvider dataProvider) Create a new single selectionComboBoxCellEditorbased on the givenIComboBoxDataProvider, showing the default number of items in the dropdown of the combo.ComboBoxCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems) Create a new single selectionComboBoxCellEditorbased on the givenIComboBoxDataProvider. -
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.protected voidaddNatComboListener(NatCombo combo) Registers special listeners to theNatComboregarding theEditModeEnum, that are needed to commit/close or change the visibility state of theNatCombodependent on UI interactions.voidclose()Close/dispose the containedControlcreateEditorControl(org.eclipse.swt.widgets.Composite parent) Creates the editor control that is wrapped by this ICellEditor.This implementation overrides the default implementation because we can work on the list of canonical items in the combo directly.Returns the current value in this editor prior to conversion.org.eclipse.swt.graphics.Imagebooleanbooleanbooleanbooleanbooleanbooleanbooleanvoidselect(int index) Selects the item at the given zero-relative index in the receiver's list.voidselect(int[] indices) Selects the items at the given zero-relative indices in the receiver.voidsetCanonicalValue(Object canonicalValue) This implementation overrides the default implementation because of the special handling for comboboxes.voidsetEditorValue(Object value) Sets the given value to editor control.voidsetFocusOnDropdownFilter(boolean focusOnDropDownFilter) Configure if the focus on the activated combobox should be set to the dropdown filter field, if it was activated viasetShowDropdownFilter(boolean).voidsetFocusOnText(boolean focusOnText) voidsetFreeEdit(boolean freeEdit) voidsetIconImage(org.eclipse.swt.graphics.Image iconImage) voidsetLinkItemAndCheckbox(boolean linkItemAndCheckbox) voidsetMultiselect(boolean multiselect) voidsetMultiselectTextBracket(String multiselectTextPrefix, String multiselectTextSuffix) Set the prefix and suffix that will parenthesize the text that is created out of the selected values if this NatCombo supports multiselection.voidsetMultiselectValueSeparator(String multiselectValueSeparator) voidsetShowDropdownFilter(boolean showDropdownFilter) voidsetUseCheckbox(boolean useCheckbox) 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
-
Field Details
-
maxVisibleItems
protected int maxVisibleItemsThe maximum number of items the drop down will show before introducing a scroll bar. -
showDropdownFilter
protected boolean showDropdownFilterFlag that indicates whether a text box is displayed to filter the drop down options- Since:
- 1.4
-
freeEdit
protected boolean freeEditFlag that indicates whether this ComboBoxCellEditor supports free editing in the text control of the NatCombo or not. By default free editing is disabled. -
multiselect
protected boolean multiselectFlag that indicates whether this ComboBoxCellEditor supports multiple selection or not. By default multiple selection is disabled. -
useCheckbox
protected boolean useCheckboxFlag that indicates whether this ComboBoxCellEditor shows checkboxes for items in the dropdown or not. -
multiselectValueSeparator
String that is used to separate values in the String representation showed in the text control if multiselect is supported.nullto use the default String ", ". -
multiselectTextPrefix
String that is used to prefix the generated String representation showed in the text control if multiselect is supported. Needed to visualize the multiselection to the user. If this value isnullthe default String "[" is used. -
multiselectTextSuffix
String that is used to suffix the generated String representation showed in the text control if multiselect is supported. Needed to visualize the multiselection to the user. If this value isnullthe default String "]" is used. -
iconImage
protected org.eclipse.swt.graphics.Image iconImageThe image to use as overlay to theTextControl if the dropdown is visible. It will indicate that the control is an open combo to the user. If this value isnullthe default image specified in NatCombo will be used.
-
-
Constructor Details
-
ComboBoxCellEditor
Create a new single selectionComboBoxCellEditorbased on the given list of items, showing the default number of items in the dropdown of the combo.- Parameters:
canonicalValues- Array of items to be shown in the drop down box. These will be converted using theIDisplayConverterfor display purposes
-
ComboBoxCellEditor
Create a new single selectionComboBoxCellEditorbased on the given list of items, showing the default number of items in the dropdown of the combo.- Parameters:
canonicalValues- Array of items to be shown in the drop down box. These will be converted using theIDisplayConverterfor display purposes- Since:
- 1.5
-
ComboBoxCellEditor
Create a new single selectionComboBoxCellEditorbased on the given list of items.- Parameters:
canonicalValues- Array of items to be shown in the drop down box. These will be converted using theIDisplayConverterfor display purposesmaxVisibleItems- The maximum number of items the drop down will show before introducing a scroll bar.
-
ComboBoxCellEditor
Create a new single selectionComboBoxCellEditorbased on the givenIComboBoxDataProvider, showing the default number of items in the dropdown of the combo.- Parameters:
dataProvider- TheIComboBoxDataProviderthat is responsible for populating the items to the dropdown box. This is the way to use a ComboBoxCellEditor with dynamic content.
-
ComboBoxCellEditor
Create a new single selectionComboBoxCellEditorbased on the givenIComboBoxDataProvider.- Parameters:
dataProvider- TheIComboBoxDataProviderthat is responsible for populating the items to the dropdown box. This is the way to use a ComboBoxCellEditor with dynamic content.maxVisibleItems- The maximum number of items the drop down will show before introducing a scroll bar.
-
-
Method Details
-
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.
-
getCanonicalValue
This implementation overrides the default implementation because we can work on the list of canonical items in the combo directly. Only for multiselect in combination with free editing, we need to convert here ourself.- 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
This implementation overrides the default implementation because of the special handling for comboboxes. It can handle multi selection and needs to transfer the converted values into a String array so the values in the combobox can be selected.- Specified by:
setCanonicalValuein interfaceICellEditor- Overrides:
setCanonicalValuein classAbstractCellEditor- Parameters:
canonicalValue- The canonical value to be set to the wrapped editor control.
-
close
public void close()Description copied from interface:ICellEditorClose/dispose the containedControl- Specified by:
closein interfaceICellEditor- Overrides:
closein classAbstractCellEditor
-
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.
-
getEditorControl
- Returns:
- The editor control that is wrapped by this ICellEditor.
-
createEditorControl
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.
-
addNatComboListener
Registers special listeners to theNatComboregarding theEditModeEnum, that are needed to commit/close or change the visibility state of theNatCombodependent on UI interactions.- Parameters:
combo- TheNatComboto add the listeners to.
-
select
public void select(int index) Selects the item at the given zero-relative index in the receiver's list. If the item at the index was already selected, it remains selected. Indices that are out of range are ignored.- Parameters:
index- the index of the item to select- See Also:
-
List.select(int)
-
select
public void select(int[] indices) Selects the items at the given zero-relative indices in the receiver. The current selection is not cleared before the new items are selected.If the item at a given index is not selected, it is selected. If the item at a given index was already selected, it remains selected. Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.
- Parameters:
indices- the array of indices for the items to select- See Also:
-
List.select(int[])
-
setMultiselectValueSeparator
- Parameters:
multiselectValueSeparator- String that should be used to separate values in the String representation showed in the text control if multiselect is supported.nullto use the default value separator.- See Also:
-
setMultiselectTextBracket
Set the prefix and suffix that will parenthesize the text that is created out of the selected values if this NatCombo supports multiselection.- Parameters:
multiselectTextPrefix- String that should be used to prefix the generated String representation showed in the text control if multiselect is supported.nullto use the default prefix.multiselectTextSuffix- String that should be used to suffix the generated String representation showed in the text control if multiselect is supported.nullto use the default suffix.- See Also:
-
getIconImage
public org.eclipse.swt.graphics.Image getIconImage()- Returns:
- The image that is used as overlay to the
TextControl if the dropdown is visible. It will indicate that the control is an open combo to the user. If this value isnullthe default image specified in NatCombo will be used.
-
setIconImage
public void setIconImage(org.eclipse.swt.graphics.Image iconImage) - Parameters:
iconImage- The image to use as overlay to theTextControl if the dropdown is visible. It will indicate that the control is an open combo to the user. If this value isnullthe default image specified in NatCombo will be used.
-
isFreeEdit
public boolean isFreeEdit()- Returns:
trueif this ComboBoxCellEditor supports free editing in the text control of the NatCombo or not. By default free editing is disabled.
-
setFreeEdit
public void setFreeEdit(boolean freeEdit) - Parameters:
freeEdit-trueto indicate that this ComboBoxCellEditor supports free editing in the text control of the NatCombo,falseif not.
-
isMultiselect
public boolean isMultiselect()- Returns:
trueif this ComboBoxCellEditor supports multiple selection or not. By default multiple selection is disabled.
-
setMultiselect
public void setMultiselect(boolean multiselect) - Parameters:
multiselect-trueto indicate that this ComboBoxCellEditor supports multiple selection,falseif not.
-
isUseCheckbox
public boolean isUseCheckbox()- Returns:
trueif this ComboBoxCellEditor shows checkboxes for items in the dropdown. By default there are not checkboxes shown.
-
setUseCheckbox
public void setUseCheckbox(boolean useCheckbox) - Parameters:
useCheckbox-trueif this ComboBoxCellEditor should show checkboxes for items in the dropdown,falseif not.
-
isShowDropdownFilter
public boolean isShowDropdownFilter()- Returns:
trueif this ComboBoxCellEditor should show the text control for filtering items in the dropdown. By default the filter is not shown.- Since:
- 1.4
-
setShowDropdownFilter
public void setShowDropdownFilter(boolean showDropdownFilter) - Parameters:
showDropdownFilter-trueif this ComboBoxCellEditor should show the text control for filtering items in the dropdown,falseif not.- Since:
- 1.4
-
isFocusOnText
public boolean isFocusOnText()- Returns:
trueif the focus on the activated combobox is set to the text field,falseif the dropdown gets the focus. Default isfalse.- Since:
- 1.6
-
setFocusOnText
public void setFocusOnText(boolean focusOnText) - Parameters:
focusOnText-trueif the focus on the activated combobox should be set to the text field,falseif the dropdown should get the focus.- Since:
- 1.6
-
isFocusOnDropdownFilter
public boolean isFocusOnDropdownFilter()- Returns:
trueif the focus on the activated combobox is set to the dropdown filter field,falseif the dropdown gets the focus. Default isfalse.- Since:
- 2.3
-
setFocusOnDropdownFilter
public void setFocusOnDropdownFilter(boolean focusOnDropDownFilter) Configure if the focus on the activated combobox should be set to the dropdown filter field, if it was activated viasetShowDropdownFilter(boolean).- Parameters:
focusOnDropDownFilter-trueif the focus on the activated combobox should be set to the dropdown filter field,falseif the dropdown should get the focus.- Since:
- 2.3
-
isLinkItemAndCheckbox
public boolean isLinkItemAndCheckbox()- Returns:
trueif a click on the item updates the checkbox state,falseif a click on an item does not affect the checkbox state. Default isfalse.- Since:
- 2.3
-
setLinkItemAndCheckbox
public void setLinkItemAndCheckbox(boolean linkItemAndCheckbox) - Parameters:
linkItemAndCheckbox-trueif a click on the item should update the checkbox state,falseif a click on an item should not affect the checkbox state.- Since:
- 2.3
-
getComboBoxDataProvider
- Returns:
- The
IComboBoxDataProviderthat is responsible for populating the items to the dropdown box. - Since:
- 2.2
-