public class ComboBoxCellEditor extends AbstractCellEditor
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!
Modifier and Type | Field and Description |
---|---|
protected boolean |
freeEdit
Flag that indicates whether this ComboBoxCellEditor supports free editing in the
text control of the NatCombo or not.
|
protected org.eclipse.swt.graphics.Image |
iconImage
The image to use as overlay to the
Text Control if the dropdown
is visible. |
protected int |
maxVisibleItems
The maximum number of items the drop down will show before introducing a scroll bar.
|
protected boolean |
multiselect
Flag that indicates whether this ComboBoxCellEditor supports multiple selection or not.
|
protected String |
multiselectTextPrefix
String that is used to prefix the generated String representation showed
in the text control if multiselect is supported.
|
protected String |
multiselectTextSuffix
String that is used to suffix the generated String representation showed
in the text control if multiselect is supported.
|
protected String |
multiselectValueSeparator
String that is used to separate values in the String representation showed
in the text control if multiselect is supported.
|
protected boolean |
useCheckbox
Flag that indicates whether this ComboBoxCellEditor shows checkboxes for items in the dropdown
or not.
|
cellStyle, configRegistry, conversionEditErrorHandler, dataValidator, displayConverter, editMode, labelStack, layerCell, validationEditErrorHandler
Constructor and Description |
---|
ComboBoxCellEditor(IComboBoxDataProvider dataProvider)
Create a new single selection
ComboBoxCellEditor based on the given IComboBoxDataProvider ,
showing the default number of items in the dropdown of the combo. |
ComboBoxCellEditor(IComboBoxDataProvider dataProvider,
int maxVisibleItems)
Create a new single selection
ComboBoxCellEditor based on the given IComboBoxDataProvider . |
ComboBoxCellEditor(List<?> canonicalValues)
Create a new single selection
ComboBoxCellEditor based 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 selection
ComboBoxCellEditor based on the given list of items. |
Modifier and Type | Method and Description |
---|---|
protected org.eclipse.swt.widgets.Control |
activateCell(org.eclipse.swt.widgets.Composite parent,
Object originalCanonicalValue)
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. |
protected void |
addNatComboListener(NatCombo combo)
Registers special listeners to the
NatCombo regarding the EditModeEnum ,
that are needed to commit/close or change the visibility state of the NatCombo
dependent on UI interactions. |
NatCombo |
createEditorControl(org.eclipse.swt.widgets.Composite parent)
Creates the editor control that is wrapped by this ICellEditor.
|
Object |
getCanonicalValue()
This implementation overrides the default implementation because we can work on the
list of canonical items in the combo directly.
|
NatCombo |
getEditorControl() |
Object |
getEditorValue()
Returns the current value in this editor prior to conversion.
|
org.eclipse.swt.graphics.Image |
getIconImage() |
boolean |
isFreeEdit() |
boolean |
isMultiselect() |
boolean |
isUseCheckbox() |
void |
select(int index)
Selects the item at the given zero-relative index in the receiver's
list.
|
void |
select(int[] indices)
Selects the items at the given zero-relative indices in the receiver.
|
void |
setCanonicalValue(Object canonicalValue)
This implementation overrides the default implementation because of the special
handling for comboboxes.
|
void |
setEditorValue(Object value)
Sets the given value to editor control.
|
void |
setFreeEdit(boolean freeEdit) |
void |
setIconImage(org.eclipse.swt.graphics.Image iconImage) |
void |
setMultiselect(boolean multiselect) |
void |
setMultiselectTextBracket(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.
|
void |
setMultiselectValueSeparator(String multiselectValueSeparator) |
void |
setUseCheckbox(boolean useCheckbox) |
activateAtAnyPosition, activateCell, addEditorControlListeners, close, commit, commit, commit, getCanonicalValue, getColumnIndex, getColumnPosition, getRowIndex, getRowPosition, handleConversion, isClosed, openAdjacentEditor, openInline, removeEditorControlListeners, setDataValidator, supportMultiEdit, validateCanonicalValue, validateCanonicalValue
protected int maxVisibleItems
protected boolean freeEdit
protected boolean multiselect
protected boolean useCheckbox
protected String multiselectValueSeparator
null
to use the
default String ", ".protected String multiselectTextPrefix
null
the default
String "[" is used.protected String multiselectTextSuffix
null
the default
String "]" is used.protected org.eclipse.swt.graphics.Image iconImage
Text
Control if the dropdown
is visible. It will indicate that the control is an open combo to the user.
If this value is null
the default image specified in NatCombo
will be used.public ComboBoxCellEditor(List<?> canonicalValues)
ComboBoxCellEditor
based on the given list of items,
showing the default number of items in the dropdown of the combo.canonicalValues
- Array of items to be shown in the drop down box. These will be
converted using the IDisplayConverter
for display purposespublic ComboBoxCellEditor(List<?> canonicalValues, int maxVisibleItems)
ComboBoxCellEditor
based on the given list of items.canonicalValues
- Array of items to be shown in the drop down box. These will be
converted using the IDisplayConverter
for display purposesmaxVisibleItems
- The maximum number of items the drop down will show before introducing
a scroll bar.public ComboBoxCellEditor(IComboBoxDataProvider dataProvider)
ComboBoxCellEditor
based on the given IComboBoxDataProvider
,
showing the default number of items in the dropdown of the combo.dataProvider
- The IComboBoxDataProvider
that is responsible for populating the
items to the dropdown box. This is the way to use a ComboBoxCellEditor with dynamic content.public ComboBoxCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems)
ComboBoxCellEditor
based on the given IComboBoxDataProvider
.dataProvider
- The IComboBoxDataProvider
that 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.protected org.eclipse.swt.widgets.Control activateCell(org.eclipse.swt.widgets.Composite parent, Object originalCanonicalValue)
AbstractCellEditor
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.activateCell
in class AbstractCellEditor
parent
- The parent Composite, needed for the creation of the editor control.originalCanonicalValue
- The value that should be put to the activated editor control.Control
to be used for capturing the new cell value.public Object getCanonicalValue()
getCanonicalValue
in interface ICellEditor
getCanonicalValue
in class AbstractCellEditor
IDisplayConverter
is configured.IDisplayConverter
public void setCanonicalValue(Object canonicalValue)
setCanonicalValue
in interface ICellEditor
setCanonicalValue
in class AbstractCellEditor
canonicalValue
- The canonical value to be set to the wrapped editor control.public Object getEditorValue()
ICellEditor
public void setEditorValue(Object value)
ICellEditor
value
- The display value to set to the wrapped editor control.public NatCombo getEditorControl()
public NatCombo createEditorControl(org.eclipse.swt.widgets.Composite parent)
ICellEditor
parent
- The Composite that will be the parent of the new editor control.
Can not be null
protected void addNatComboListener(NatCombo combo)
NatCombo
regarding the EditModeEnum
,
that are needed to commit/close or change the visibility state of the NatCombo
dependent on UI interactions.combo
- The NatCombo
to add the listeners to.public void select(int index)
index
- the index of the item to selectList.select(int)
public void select(int[] indices)
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.
indices
- the array of indices for the items to selectList.select(int[])
public void setMultiselectValueSeparator(String multiselectValueSeparator)
multiselectValueSeparator
- String that should be used to separate values in the
String representation showed in the text control if multiselect is supported.
null
to use the default value separator.NatCombo.DEFAULT_MULTI_SELECT_VALUE_SEPARATOR
public void setMultiselectTextBracket(String multiselectTextPrefix, String multiselectTextSuffix)
multiselectTextPrefix
- String that should be used to prefix the generated String
representation showed in the text control if multiselect is supported.
null
to 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.
null
to use the default suffix.NatCombo.DEFAULT_MULTI_SELECT_PREFIX
,
NatCombo.DEFAULT_MULTI_SELECT_SUFFIX
public org.eclipse.swt.graphics.Image getIconImage()
Text
Control if the dropdown
is visible. It will indicate that the control is an open combo to the user.
If this value is null
the default image specified in NatCombo
will be used.public void setIconImage(org.eclipse.swt.graphics.Image iconImage)
iconImage
- The image to use as overlay to the Text
Control if the dropdown
is visible. It will indicate that the control is an open combo to the user.
If this value is null
the default image specified in NatCombo
will be used.public boolean isFreeEdit()
true
if this ComboBoxCellEditor supports free editing in the
text control of the NatCombo or not. By default free editing is disabled.public void setFreeEdit(boolean freeEdit)
freeEdit
- true
to indicate that this ComboBoxCellEditor supports free
editing in the text control of the NatCombo, false
if not.public boolean isMultiselect()
true
if this ComboBoxCellEditor supports multiple selection or not.
By default multiple selection is disabled.public void setMultiselect(boolean multiselect)
multiselect
- true
to indicate that this ComboBoxCellEditor supports
multiple selection, false
if not.public boolean isUseCheckbox()
true
if this ComboBoxCellEditor shows checkboxes for items in the dropdown.
By default there are not checkboxes shown.public void setUseCheckbox(boolean useCheckbox)
useCheckbox
- true
if this ComboBoxCellEditor should show checkboxes for items
in the dropdown, false
if not.Copyright © 2013. All Rights Reserved.