Class ComboBoxEditingSupport<T,V>
java.lang.Object
org.eclipse.jface.viewers.EditingSupport
com.amalgamasimulation.desktop.binding.editingsupports.GenericEditingSupport<T,V>
com.amalgamasimulation.desktop.binding.editingsupports.ComboBoxEditingSupport<T,V>
- Type Parameters:
T- type of row valueV- type of column value (cell value)
- Direct Known Subclasses:
AutoCompleteComboBoxEditingSupport,EMFComboBoxEditingSupport,EnumComboBoxEditingSupport
Class is used to enable editing a table cell via a combobox with a list of values.
- Author:
- Ionov Ivan
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intLimitation on the number of elements in the combo box.Function to get the value that will be shown in the cellprotected StringElement on top of other elements in the combo box to clear the table cell value.protected booleanprotected BiConsumer<T, V> A function that will be executed after losing focus on the combo box editor or after pressing the Enter buttonSorted and filtered list itemsFunction that returns the value from the container objectFields inherited from class com.amalgamasimulation.desktop.binding.editingsupports.GenericEditingSupport
canEditCell, parent, viewer -
Constructor Summary
ConstructorsConstructorDescriptionComboBoxEditingSupport(org.eclipse.jface.viewers.ColumnViewer viewer, org.eclipse.swt.widgets.Composite parent) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.eclipse.jface.viewers.ComboBoxCellEditorenableNullElement(String notSetLiteral) Add an element on top of other elements in the combo box to clear the table cell value.protected org.eclipse.jface.viewers.CellEditorgetCellEditorInternal(T element) protected ObjectgetValueInternal(T element) protected voidinitializeCellEditorValueInternal(org.eclipse.jface.viewers.CellEditor cellEditor, org.eclipse.jface.viewers.ViewerCell cell, T element) setComparator(Comparator<V> comparator) Add a comparator that is used to sort combo box values.setElements(Function<T, List<V>> elementsExtractor) Set up the value elementsExtractorsetElements(List<V> elements) Set up the value elementssetFilter(BiPredicate<T, V> filter) Add a filter.setMaxComboBoxElementsCount(int maxComboBoxElementsCount) Set up the maxComboBoxElementsCountsetNameExtractor(Function<V, String> nameExtractor) Set up the combo box elements naming.setSelectionListener(BiConsumer<T, V> selectionListener) Set up the selectionListenersetValueExtractor(Function<T, V> valueExtractor) Set up the value Extractorprotected voidsetValueInternal(T element, V value) protected voidsortAndFilterElements(T element) Methods inherited from class com.amalgamasimulation.desktop.binding.editingsupports.GenericEditingSupport
canEdit, canEditInternal, getCellEditor, getValue, initializeCellEditorValue, setCanEditCell, setValueMethods inherited from class org.eclipse.jface.viewers.EditingSupport
getViewer, saveCellEditorValue
-
Field Details
-
valueExtractor
Function that returns the value from the container object -
nameExtractor
Function to get the value that will be shown in the cell -
selectionListener
A function that will be executed after losing focus on the combo box editor or after pressing the Enter button -
notSetLiteral
Element on top of other elements in the combo box to clear the table cell value. -
maxComboBoxElementsCount
protected int maxComboBoxElementsCountLimitation on the number of elements in the combo box. With a large number of elements in the combo box, it becomes more difficult to find the right one and also negatively affects the operation of the combo box. -
sortedElements
Sorted and filtered list items -
readOnlyComboBox
protected boolean readOnlyComboBox
-
-
Constructor Details
-
ComboBoxEditingSupport
public ComboBoxEditingSupport(org.eclipse.jface.viewers.ColumnViewer viewer, org.eclipse.swt.widgets.Composite parent)
-
-
Method Details
-
sortAndFilterElements
-
createComboBoxCellEditor
protected org.eclipse.jface.viewers.ComboBoxCellEditor createComboBoxCellEditor() -
getCellEditorInternal
- Specified by:
getCellEditorInternalin classGenericEditingSupport<T,V>
-
getValueInternal
- Specified by:
getValueInternalin classGenericEditingSupport<T,V>
-
setValueInternal
- Specified by:
setValueInternalin classGenericEditingSupport<T,V>
-
initializeCellEditorValueInternal
protected void initializeCellEditorValueInternal(org.eclipse.jface.viewers.CellEditor cellEditor, org.eclipse.jface.viewers.ViewerCell cell, T element) - Overrides:
initializeCellEditorValueInternalin classGenericEditingSupport<T,V>
-
enableNullElement
Add an element on top of other elements in the combo box to clear the table cell value.- Parameters:
notSetLiteral- the label of the new combo box element that clears the cell value (typical values are: "", etc.) - Returns:
- this object
-
setFilter
Add a filter. Only matching items will be displayed in the combo box.
Note that there may be at most one filter. If you call this method several times, only the last method call will be effective.- Returns:
- this object
-
setComparator
Add a comparator that is used to sort combo box values.
Note that there may be at most one comparator. If you call this method several times, only the last method call will be effective.- Returns:
- this object
-
setNameExtractor
Set up the combo box elements naming. The name extractor.- Parameters:
nameExtractor- function that converts a combo box element to a String displayed in the combo box- Returns:
- this object
-
setMaxComboBoxElementsCount
Set up the maxComboBoxElementsCount- Parameters:
maxComboBoxElementsCount- limitation on the number of elements in the combo box- Returns:
- this object
-
setValueExtractor
Set up the value Extractor- Parameters:
valueExtractor- Function that returns the value from the container object- Returns:
- this object
-
setSelectionListener
Set up the selectionListener- Parameters:
selectionListener- function that will be executed after losing focus on the combo box editor or after pressing the Enter button- Returns:
- this object
-
setElements
Set up the value elementsExtractor- Parameters:
elementsExtractor- List of elements to be shown in the combo box- Returns:
- this object
-
setElements
Set up the value elements- Parameters:
elements- List of elements to be shown in the combo box- Returns:
- this object
-