E
- the type of elements returned by the underlying column viewer.V
- the type of values to use with the underlying
ComboBoxViewerCellEditor
.public abstract class ComboBoxEditingSupport<E,V> extends TypedEditingSupportConstantEditor<E,V>
An editing support with typed elements and values, using a
ComboBoxViewerCellEditor
underlying cell editor. Objects of this type
convert elements from the untyped (Object) elements, given by the underlying
column viewer, to elements of type E. Similarly, objects of this type convert
values from the untyped (Object) values given by the underlying cell editor
to values of type V. Both conversions are done using a cast.
The user of this class must ensure that the underlying column viewer always gives elements of type E. The underlying column viewer is set at construction time.
Objects of this type ensure that the underlying combo box cell editor rejects values out of the provided list of items, thus, the end-user may not type into the combo box a value of its choice that would not belong to the pre-defined list of acceptable choices.
The user must go through this object to change the validator behavior of the underlying cell editor. The user may not set or remove the validator directly on the underlying cell editor, and may not change the first-level validator.
The user of this class must override #getValueTyped(E)
to provide values corresponding to elements; and
#setValueTyped(E, V)
to set the values
sent by the cell editor back to the model. The user may also override
#canEditTyped(E)
(true
by
default), and #toString(V)
(which by default
returns the empty string if the value is null
, and otherwise
uses Object.toString()
). The latter is used to show the entries in
the combo box to the end-user.
Constructor and Description |
---|
ComboBoxEditingSupport(ColumnViewer viewer,
Class<E> classOfElements,
Class<V> classOfValues) |
Modifier and Type | Method and Description |
---|---|
CellEditor |
getCellEditorTyped(E element)
The editor to be shown
This method is simply a better typed version of
TypedEditingSupport.getCellEditor(Object) . |
ComboBoxViewerCellEditor |
getComboBoxCellEditor()
Returns the underlying cell editor.
|
List<V> |
getItems()
Only returns the items if they have been set using this object
constructor or
setItems(List) . |
void |
setItems(List<V> items)
Sets the input items to the underlying ComboBoxCellEditor.
|
String |
toString(V value) |
getCellEditor, setCellEditor, setFirstLevelValidator, setValidator
canEdit, canEditTyped, getCellEditor, getTypedElement, getTypedValue, getValue, getValueTyped, setValue, setValueTyped
getViewer, initializeCellEditorValue, saveCellEditorValue
public ComboBoxEditingSupport(ColumnViewer viewer, Class<E> classOfElements, Class<V> classOfValues)
viewer
- must have a composite as underlying control.public CellEditor getCellEditorTyped(E element)
TypedEditingSupport
The editor to be shown
This method is simply a better typed version of
TypedEditingSupport.getCellEditor(Object)
.
getCellEditorTyped
in class TypedEditingSupportConstantEditor<E,V>
element
- the model elementpublic ComboBoxViewerCellEditor getComboBoxCellEditor()
getCellEditorTyped(Object)
, and the same object than
TypedEditingSupportConstantEditor.getCellEditor()
.null
.public List<V> getItems()
setItems(List)
. If the items have been set (or
modified) directly on the underlying widget, this method has unspecified
effects.null
if not set.public void setItems(List<V> items)
items
- a null
value is converted to an empty list.Copyright © 2017. All rights reserved.