Module is.codion.swing.common.model
Interface FilterComboBoxModel.Builder<T>
- Type Parameters:
T- the item type
- Enclosing interface:
FilterComboBoxModel<T>
public static interface FilterComboBoxModel.Builder<T>
Builds a
FilterComboBoxModel-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionasync(boolean async) build()comparator(@Nullable Comparator<T> comparator) filterSelected(boolean filterSelected) Specifies whether filtering the model affects the currently selected item.includeNull(boolean includeNull) SetsincludeNull(boolean)to true ifnullItemis non-null, false otherwise.onRefreshException(Consumer<Exception> onRefreshException) By default, exceptions during refresh are rethrown, use this method to handle async exceptions differentlyonSelection(Consumer<@Nullable T> onSelection) refresh(boolean refresh) Default false.translator(Function<Object, T> translator) Provides a way for a combo box model to translate an item received viaSingleSelection.item()to an actual item to select, such as selecting the String "1" in a String based model when selected item is set to the Integer 1.
-
Method Details
-
comparator
- Parameters:
comparator- the comparator, null for unsorted- Returns:
- this builder
-
includeNull
- Parameters:
includeNull- true if a null item should be included- Returns:
- this builder
-
nullItem
SetsincludeNull(boolean)to true ifnullItemis non-null, false otherwise.- Parameters:
nullItem- the item representing null- Returns:
- this builder
-
select
- Parameters:
item- the item to select initially- Returns:
- this builder
-
translator
Provides a way for a combo box model to translate an item received viaSingleSelection.item()to an actual item to select, such as selecting the String "1" in a String based model when selected item is set to the Integer 1.- Parameters:
translator- the selected item translator- Returns:
- this builder
-
filterSelected
Specifies whether filtering the model affects the currently selected item. If true, the selection is cleared when the selected item is excluded from the model, otherwise the selected item can potentially represent a value which is not currently included in the model
This is false by default.
- Parameters:
filterSelected- true if the select item should be filtered- See Also:
-
onSelection
- Parameters:
onSelection- called when an item is selected, note that this item may be null- Returns:
- this builder instance
-
async
- Parameters:
async- true if async refresh should be enabled- Returns:
- this builder instance
-
onRefreshException
By default, exceptions during refresh are rethrown, use this method to handle async exceptions differently- Parameters:
onRefreshException- the exception handler to use during refresh- Returns:
- this builder instance
-
refresh
Default false.- Parameters:
refresh- true if the model items should be refreshed on initialization- Returns:
- this builder instance
-
build
FilterComboBoxModel<T> build()- Returns:
- a new
FilterComboBoxModelinstance
-