public class FilterProxyListModel<T> extends Object implements ListModel<T>, DataChangedListener
ADDED, CHANGED, REMOVED
Constructor and Description |
---|
FilterProxyListModel(ListModel<T> underlying)
The proxy is applied to the actual model and effectively hides it
|
Modifier and Type | Method and Description |
---|---|
void |
addDataChangedListener(DataChangedListener l)
Invoked to indicate interest in future change events
|
void |
addItem(T item)
Adds the specified item to the end of this list.
|
void |
addSelectionListener(SelectionListener l)
Invoked to indicate interest in future selection events
|
protected boolean |
check(Object o,
String str)
Checks whether the filter condition is matched, receives an uppercase version of the
filter string to match against
|
protected int |
compare(Object a,
Object b,
boolean ascending)
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
|
void |
dataChanged(int type,
int index)
Invoked when there was a change in the underlying model
|
void |
filter(String str)
Filters the list based on the given string
|
T |
getItemAt(int index)
Returns the item at the given offset
|
int |
getSelectedIndex()
Returns the selected list offset
|
int |
getSize()
Returns the number of items in the list
|
ListModel |
getUnderlying()
Returns the underlying model which is needed to perform mutations on the list.
|
static void |
install(TextField search,
ContainerList l)
Installs a search field on a list making sure the filter method is invoked properly
|
static void |
install(TextField search,
List l)
Installs a search field on a list making sure the filter method is invoked properly
|
boolean |
isStartsWithMode()
When enabled this makes the filter check that the string starts with rather than within the index
|
void |
removeDataChangedListener(DataChangedListener l)
Invoked to indicate no further interest in future change events
|
void |
removeItem(int index)
Removes the item at the specified position in this list.
|
void |
removeSelectionListener(SelectionListener l)
Invoked to indicate no further interest in future selection events
|
void |
setSelectedIndex(int index)
Sets the selected list offset can be set to -1 to clear selection
|
void |
setStartsWithMode(boolean startsWithMode)
When enabled this makes the filter check that the string starts with rather than within the index
|
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
|
public void sort(boolean ascending)
ascending
- sort in ascending orderprotected int compare(Object a, Object b, boolean ascending)
a
- first objectb
- second objectascending
- direction of sortpublic ListModel getUnderlying()
protected boolean check(Object o, String str)
o
- the object being comparedstr
- the stringpublic void filter(String str)
str
- the string to filter the list bypublic T getItemAt(int index)
public int getSize()
public int getSelectedIndex()
getSelectedIndex
in interface ListModel<T>
public void setSelectedIndex(int index)
setSelectedIndex
in interface ListModel<T>
index
- an index into this listpublic void addDataChangedListener(DataChangedListener l)
addDataChangedListener
in interface ListModel<T>
l
- a data changed listenerpublic void removeDataChangedListener(DataChangedListener l)
removeDataChangedListener
in interface ListModel<T>
l
- a data changed listenerpublic void addSelectionListener(SelectionListener l)
addSelectionListener
in interface ListModel<T>
l
- a selection listenerpublic void removeSelectionListener(SelectionListener l)
removeSelectionListener
in interface ListModel<T>
l
- a selection listenerpublic void addItem(T item)
public void removeItem(int index)
removeItem
in interface ListModel<T>
index
- the index of the item to removedpublic void dataChanged(int type, int index)
dataChanged
in interface DataChangedListener
type
- the type data change; REMOVED, ADDED or CHANGEDindex
- item index in a list modelpublic static void install(TextField search, List l)
public static void install(TextField search, ContainerList l)
public boolean isStartsWithMode()
public void setStartsWithMode(boolean startsWithMode)
startsWithMode
- the startsWithMode to set