Package docking.widgets.searchlist
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<T>
to provide more information for the custom rendering that groups items into categories.- See Also:
-
Field Summary
Fields inherited from class javax.swing.AbstractListModel
listenerList
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the list of items to the given category.void
Removes all categories and items from this modelvoid
dispose()
Clean up any resources held by the modelvoid
Provides a way to kick the list display to update.Returns a list of all item entries regardless of the current filter.Returns the list of categories in the order they were added to the modelReturns a list of all displayed item entries (only ones matching the current filter).getElementAt
(int index) int
getSize()
void
setFilter
(BiPredicate<T, String> filter) Sets the filter for the model data to display.Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
-
Constructor Details
-
DefaultSearchListModel
public DefaultSearchListModel()
-
-
Method Details
-
getSize
public int getSize() -
getElementAt
- Specified by:
getElementAt
in interfaceListModel<T>
-
add
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 toitems
- 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
Description copied from interface:SearchListModel
Sets the filter for the model data to display.- Specified by:
setFilter
in interfaceSearchListModel<T>
- Parameters:
filter
- the BiPredicate for the model data to display which will filter based on the item and its category
-
getCategories
Description copied from interface:SearchListModel
Returns the list of categories in the order they were added to the model- Specified by:
getCategories
in interfaceSearchListModel<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 interfaceSearchListModel<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
Returns a list of all item entries regardless of the current filter.- Returns:
- a list of all item entries
-