- Type Parameters:
T
- the item type
- All Known Subinterfaces:
FilterComboBoxModel.ComboBoxItems<T>
- Enclosing interface:
FilterModel<T>
FilterModel
.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Collection<T> items) Adds the given items to this model.void
Adds the given item to this model.static <T> FilterModel.Items.Builder.SelectionStage
<T> builder
(Function<FilterModel.Items<T>, FilterModel.Refresher<T>> refresher) void
clear()
Clears the itemsboolean
Returns true if the model contain the given item, as visible or filtered.int
count()
void
filter()
Filters the items according to theFilterModel.VisibleItems.predicate()
.filtered()
get()
void
refresh()
Refreshes the items in this model using itsFilterModel.Refresher
.void
refresh
(Consumer<Collection<T>> onResult) Refreshes the data in this model using itsFilterModel.Refresher
.void
remove
(Collection<T> items) Removes the given items from this model.void
Removes the given item from this model.void
Replaces the given map keys with their respective values.void
Replaces the first occurrence of the given item.void
set
(Collection<T> items) It is up to the implementation whether the visible items are sorted when the items are set.visible()
-
Method Details
-
refresher
FilterModel.Refresher<T> refresher()- Returns:
- this models
FilterModel.Refresher
instance
-
refresh
void refresh()Refreshes the items in this model using itsFilterModel.Refresher
.
Retains the selection and filtering. Sorts the refreshed data unless merging on refresh is enabled. Note that an empty selection event will be triggered during a normal refresh, since the model is cleared before it is repopulated, during which the selection is cleared as well. Using merge on refresh (refreshStrategy()
) will prevent that at a considerable performance cost.- Throws:
RuntimeException
- in case of an exception when running refresh synchronously- See Also:
-
refresh
Refreshes the data in this model using its
FilterModel.Refresher
.Note that this method only throws exceptions when run synchronously off the user interface thread. Use
FilterModel.Refresher.exception()
to listen for exceptions that happen during asynchronous refresh.
Retains the selection and filtering. Sorts the refreshed data unless merging on refresh is enabled. Note that an empty selection event will be triggered during a normal refresh, since the model is cleared before it is repopulated, during which the selection is cleared as well. Using merge on refresh (refreshStrategy()
) will prevent that at a considerable performance cost.- Parameters:
onResult
- called after a successful refresh- Throws:
RuntimeException
- in case of an exception when running refresh synchronously- See Also:
-
refreshStrategy
Value<FilterModel.RefreshStrategy> refreshStrategy()- Returns:
- the
Value
controlling the refresh strategy
-
get
Collection<T> get()- Returns:
- all items, visible and filtered, in no particular order
-
set
It is up to the implementation whether the visible items are sorted when the items are set.- Parameters:
items
- the items
-
add
Adds the given item to this model.
If the item passes the
FilterModel.VisibleItems.predicate()
it is appended to the visible items, which are then sorted if sorting is enabled.If the item does not pass the
FilterModel.VisibleItems.predicate()
, it will be filtered right away.- Parameters:
item
- the item to add
-
add
Adds the given items to this model.
Items that pass the
FilterModel.VisibleItems.predicate()
are is appended to the visible items, which are then sorted if sorting is enabled.If no items pass the
FilterModel.VisibleItems.predicate()
, they will be filtered right away.- Parameters:
items
- the items to add
-
remove
Removes the given item from this model.
- Parameters:
item
- the item to remove from the model
-
remove
Removes the given items from this model.
- Parameters:
items
- the items to remove from the model
-
replace
Replaces the first occurrence of the given item. If the item is not found this method has no effect.
Note that this method respects the visible predicate, so a currently filtered item may be replaced with a visible item and vice verse.
If the visible items change they are sorted if sorting is enabled.
- Parameters:
item
- the item to replacereplacement
- the replacement item- See Also:
-
replace
Replaces the given map keys with their respective values.
Note that this method respects the visible predicate, so a currently filtered item may be replaced with a visible item and vice verse.
If the visible items change they are sorted if sorting is enabled.
- Parameters:
replacements
-
-
clear
void clear()Clears the items -
visible
FilterModel.VisibleItems<T> visible()- Returns:
- a
FilterModel.VisibleItems
providing access to the visible items, in the order they appear in the model
-
filtered
FilterModel.FilteredItems<T> filtered()- Returns:
- a
FilterModel.FilteredItems
providing access to the filtered items
-
contains
Returns true if the model contain the given item, as visible or filtered.- Parameters:
item
- the item- Returns:
- true if this model contains the item
-
count
int count()- Returns:
- the total number of items, visible and filtered
-
filter
void filter()Filters the items according to the
FilterModel.VisibleItems.predicate()
.If no predicate is specified calling this method has no effect.
This method does not interfere with the internal ordering of the visible items.
- See Also:
-
builder
static <T> FilterModel.Items.Builder.SelectionStage<T> builder(Function<FilterModel.Items<T>, FilterModel.Refresher<T>> refresher) - Type Parameters:
T
- the item type- Parameters:
refresher
- the item refresher to use- Returns:
- a new
FilterModel.Items.Builder.SelectionStage
instance
-