Interface FilterModel.Items<T>

Type Parameters:
T - the item type
All Known Subinterfaces:
FilterComboBoxModel.ComboBoxItems<T>
Enclosing interface:
FilterModel<T>

public static interface FilterModel.Items<T>
Manages the items in FilterModel.
  • Method Details

    • refresher

      FilterModel.Refresher<T> refresher()
      Returns:
      this models FilterModel.Refresher instance
    • refresh

      void refresh()
      Refreshes the items in this model using its FilterModel.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

      void refresh(Consumer<Collection<T>> onResult)

      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

      Returns:
      the Value controlling the refresh strategy
    • get

      Collection<T> get()
      Returns:
      all items, visible and filtered, in no particular order
    • set

      void set(Collection<T> items)
      It is up to the implementation whether the visible items are sorted when the items are set.
      Parameters:
      items - the items
    • add

      void add(T item)

      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

      void add(Collection<T> items)

      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

      void remove(T item)

      Removes the given item from this model.

      Parameters:
      item - the item to remove from the model
    • remove

      void remove(Collection<T> items)

      Removes the given items from this model.

      Parameters:
      items - the items to remove from the model
    • replace

      void replace(T item, T replacement)

      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 replace
      replacement - the replacement item
      See Also:
    • replace

      void replace(Map<T,T> replacements)

      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

      Returns:
      a FilterModel.VisibleItems providing access to the visible items, in the order they appear in the model
    • filtered

      Returns:
      a FilterModel.FilteredItems providing access to the filtered items
    • contains

      boolean contains(T item)
      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

      Type Parameters:
      T - the item type
      Parameters:
      refresher - the item refresher to use
      Returns:
      a new FilterModel.Items.Builder.SelectionStage instance