Class DefaultSearchListModel<T>

java.lang.Object
javax.swing.AbstractListModel<SearchListEntry<T>>
docking.widgets.searchlist.DefaultSearchListModel<T>
Type Parameters:
T - The type of items to display and select.
All Implemented Interfaces:
SearchListModel<T>, Serializable, ListModel<SearchListEntry<T>>
Direct Known Subclasses:
ActionsModel

public class DefaultSearchListModel<T> extends AbstractListModel<SearchListEntry<T>> implements SearchListModel<T>
Default implementation of the SearchListModel. Since this model's primary purpose is to also implement the ListModel, this class extends the AbstractListModel. This model's primary type is T, but it implements the list model on SearchListEntry to provide more information for the custom rendering that groups items into categories.
See Also:
  • Constructor Details

    • DefaultSearchListModel

      public DefaultSearchListModel()
  • Method Details

    • getSize

      public int getSize()
      Specified by:
      getSize in interface ListModel<T>
    • getElementAt

      public SearchListEntry<T> getElementAt(int index)
      Specified by:
      getElementAt in interface ListModel<T>
    • add

      public void add(String category, List<T> items)
      Adds the list of items to the given category. If the category already exists, these items will be added to any items already associated with that cateogry.
      Parameters:
      category - the category to add the items to
      items - the list of items to add to and be associated with the given category
    • fireDataChanged

      public void fireDataChanged()
      Provides a way to kick the list display to update.
    • clearData

      public void clearData()
      Removes all categories and items from this model
    • setFilter

      public void setFilter(BiPredicate<T,String> filter)
      Description copied from interface: SearchListModel
      Sets the filter for the model data to display.
      Specified by:
      setFilter in interface SearchListModel<T>
      Parameters:
      filter - the BiPredicate for the model data to display which will filter based on the item and its category
    • getCategories

      public List<String> getCategories()
      Description copied from interface: SearchListModel
      Returns the list of categories in the order they were added to the model
      Specified by:
      getCategories in interface SearchListModel<T>
      Returns:
      the list of categories in the order they were added to the model
    • dispose

      public void dispose()
      Description copied from interface: SearchListModel
      Clean up any resources held by the model
      Specified by:
      dispose in interface SearchListModel<T>
    • getDisplayedItems

      public List<SearchListEntry<T>> getDisplayedItems()
      Returns a list of all displayed item entries (only ones matching the current filter).
      Returns:
      a list of all display item entries
    • getAllItems

      public List<SearchListEntry<T>> getAllItems()
      Returns a list of all item entries regardless of the current filter.
      Returns:
      a list of all item entries