Class FilterProxyListModel<T>
- All Implemented Interfaces:
DataChangedListener, ListModel<T>
-
Field Summary
Fields inherited from interface DataChangedListener
ADDED, CHANGED, REMOVED -
Constructor Summary
ConstructorsConstructorDescriptionFilterProxyListModel(ListModel<T> underlying) The proxy is applied to the actual model and effectively hides it -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked to indicate interest in future change eventsvoidAdds the specified item to the end of this list.voidInvoked to indicate interest in future selection eventsprotected booleanChecks whether the filter condition is matched, receives an uppercase version of the filter string to match againstprotected intThis method can be overriden by subclasses to allow sorting arbitrary objects within the list, it follows the traditional contract of the compare method in JavavoiddataChanged(int type, int index) Invoked when there was a change in the underlying modelvoidFilters the list based on the given stringgetItemAt(int index) Returns the item at the given offsetintReturns the selected list offsetintgetSize()Returns the number of items in the listReturns the underlying model which is needed to perform mutations on the list.static voidInstalls a search field on a list making sure the filter method is invoked properlystatic voidinstall(TextField search, ContainerList l) Installs a search field on a list making sure the filter method is invoked properlybooleanWhen enabled this makes the filter check that the string starts with rather than within the indexvoidInvoked to indicate no further interest in future change eventsvoidremoveItem(int index) Removes the item at the specified position in this list.voidInvoked to indicate no further interest in future selection eventsvoidsetSelectedIndex(int index) Sets the selected list offset can be set to -1 to clear selectionvoidsetStartsWithMode(boolean startsWithMode) When enabled this makes the filter check that the string starts with rather than within the indexvoidsort(boolean ascending) This method performs a sort of the list, to determine the sort order this class should be derived and the compare() method should be overriden
-
Constructor Details
-
FilterProxyListModel
-
-
Method Details
-
install
-
install
Installs a search field on a list making sure the filter method is invoked properly -
sort
public void sort(boolean ascending) This method performs a sort of the list, to determine the sort order this class should be derived and the compare() method should be overriden
Parameters
ascending: sort in ascending order
-
compare
This method can be overriden by subclasses to allow sorting arbitrary objects within the list, it follows the traditional contract of the compare method in Java
Parameters
-
a: first object -
b: second object -
ascending: direction of sort
Returns
1, 0 or -1 to indicate the larger/smaller object
-
-
getUnderlying
Returns the underlying model which is needed to perform mutations on the list.
Returns
the underlying model
-
check
-
filter
Filters the list based on the given string
Parameters
str: the string to filter the list by
-
getItemAt
-
getSize
-
getSelectedIndex
public int getSelectedIndex()Returns the selected list offset
Returns
the selected list index
- Specified by:
getSelectedIndexin interfaceListModel<T>
-
setSelectedIndex
public void setSelectedIndex(int index) Sets the selected list offset can be set to -1 to clear selection
Parameters
index: an index into this list
- Specified by:
setSelectedIndexin interfaceListModel<T>
-
addDataChangedListener
Invoked to indicate interest in future change events
Parameters
l: a data changed listener
- Specified by:
addDataChangedListenerin interfaceListModel<T>
-
removeDataChangedListener
Invoked to indicate no further interest in future change events
Parameters
l: a data changed listener
- Specified by:
removeDataChangedListenerin interfaceListModel<T>
-
addSelectionListener
Invoked to indicate interest in future selection events
Parameters
l: a selection listener
- Specified by:
addSelectionListenerin interfaceListModel<T>
-
removeSelectionListener
Invoked to indicate no further interest in future selection events
Parameters
l: a selection listener
- Specified by:
removeSelectionListenerin interfaceListModel<T>
-
addItem
-
removeItem
public void removeItem(int index) Removes the item at the specified position in this list.
Parameters
index: the index of the item to removed
- Specified by:
removeItemin interfaceListModel<T>
-
dataChanged
public void dataChanged(int type, int index) Invoked when there was a change in the underlying model
Parameters
-
type: the type data change; REMOVED, ADDED or CHANGED -
index: item index in a list model
- Specified by:
dataChangedin interfaceDataChangedListener
-
-
isStartsWithMode
public boolean isStartsWithMode()When enabled this makes the filter check that the string starts with rather than within the index
Returns
the startsWithMode
-
setStartsWithMode
public void setStartsWithMode(boolean startsWithMode) When enabled this makes the filter check that the string starts with rather than within the index
Parameters
startsWithMode: the startsWithMode to set
-