Class JaxxFilterableListModel<E>
- java.lang.Object
-
- javax.swing.AbstractListModel<E>
-
- org.nuiton.jaxx.runtime.swing.model.JaxxDefaultListModel<E>
-
- org.nuiton.jaxx.runtime.swing.model.JaxxFilterableListModel<E>
-
- All Implemented Interfaces:
Serializable,ListModel<E>
public class JaxxFilterableListModel<E> extends JaxxDefaultListModel<E>
List model for filterable lists.- Since:
- 2.5.11
- Author:
- Kevin Morin - morin@codelutin.com
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected io.ultreia.java4all.decoration.Decoratordecoratorthe decorator of dataprotected ArrayList<E>filteredItemsprotected List<Predicate<E>>filtersprotected StringfilterText-
Fields inherited from class org.nuiton.jaxx.runtime.swing.model.JaxxDefaultListModel
delegate, valueIsAdjusting
-
Fields inherited from class javax.swing.AbstractListModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description JaxxFilterableListModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, E element)Inserts the specified element at the specified position in this list.voidaddAllElements(Collection<E> elements)voidaddElement(E o)Adds the specified component to the end of this list.voidaddFilter(Predicate<E> filter)voidclear()Removes all of the elements from this list.voidclearFilters()EelementAt(int index)Returns the component at the specified index.voidensureCapacity(int minCapacity)Increases the capacity of this list, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.io.ultreia.java4all.decoration.DecoratorgetDecorator()EgetElementAt(int index)Returns the component at the specified index.StringgetFilterText()intgetSize()Returns the number of components in this list.voidinsertElementAt(E element, int index)Inserts the specified element as a component in this list at the specifiedindex.protected voidrefilter()voidrefreshFilteredElements()Eremove(int index)Removes the element at the specified position in this list.voidremoveAllElements()Removes all components from this list and sets its size to zero.voidremoveAllElements(Collection<E> elements)booleanremoveElement(E o)Removes the first (lowest-indexed) occurrence of the argument from this list.voidremoveElementAt(int index)Deletes the component at the specified index.voidremoveFilter(Predicate<E> filter)voidremoveRange(int fromIndex, int toIndex)Deletes the components at the specified range of indexes.Eset(int index, E element)Replaces the element at the specified position in this list with the specified element.voidsetAllElements(Collection<E> objects)voidsetDecorator(io.ultreia.java4all.decoration.Decorator decorator)voidsetElementAt(E element, int index)Sets the component at the specifiedindexof this list to be the specified element.voidsetFilterText(String filterText)voidsetSize(int newSize)Sets the size of this list.intsize()Returns the number of components in this list.voidtrimToSize()Trims the capacity of this list to be the list's current size.-
Methods inherited from class org.nuiton.jaxx.runtime.swing.model.JaxxDefaultListModel
capacity, contains, firstElement, get, indexOf, indexOf, isEmpty, isValueIsAdjusting, lastElement, lastIndexOf, lastIndexOf, refresh, refresh, setValueIsAdjusting, toArray, toList, toString
-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
-
-
-
Method Detail
-
getElementAt
public E getElementAt(int index)
Description copied from class:JaxxDefaultListModelReturns the component at the specified index.Note: Although this method is not deprecated, the preferred method to use is
get(int), which implements theListinterface defined in the 1.2 Collections framework.- Specified by:
getElementAtin interfaceListModel<E>- Overrides:
getElementAtin classJaxxDefaultListModel<E>- Parameters:
index- an index into this list- Returns:
- the component at the specified index
- See Also:
JaxxDefaultListModel.get(int)
-
elementAt
public E elementAt(int index)
Description copied from class:JaxxDefaultListModelReturns the component at the specified index. Throws anArrayIndexOutOfBoundsExceptionif the index is negative or not less than the size of the list.Note: Although this method is not deprecated, the preferred method to use is
get(int), which implements theListinterface defined in the 1.2 Collections framework.- Overrides:
elementAtin classJaxxDefaultListModel<E>- Parameters:
index- an index into this list- Returns:
- the component at the specified index
- See Also:
JaxxDefaultListModel.get(int),Vector.elementAt(int)
-
addElement
public void addElement(E o)
Description copied from class:JaxxDefaultListModelAdds the specified component to the end of this list.- Overrides:
addElementin classJaxxDefaultListModel<E>- Parameters:
o- the component to be added- See Also:
Vector.addElement(Object)
-
removeElement
public boolean removeElement(E o)
Description copied from class:JaxxDefaultListModelRemoves the first (lowest-indexed) occurrence of the argument from this list.- Overrides:
removeElementin classJaxxDefaultListModel<E>- Parameters:
o- the component to be removed- Returns:
trueif the argument was a component of this list;falseotherwise- See Also:
Vector.removeElement(Object)
-
getSize
public int getSize()
Description copied from class:JaxxDefaultListModelReturns the number of components in this list.This method is identical to
size, which implements theListinterface defined in the 1.2 Collections framework. This method exists in conjunction withsetSizeso thatsizeis identifiable as a JavaBean property.- Specified by:
getSizein interfaceListModel<E>- Overrides:
getSizein classJaxxDefaultListModel<E>- Returns:
- the number of components in this list
- See Also:
JaxxDefaultListModel.size()
-
size
public int size()
Description copied from class:JaxxDefaultListModelReturns the number of components in this list.- Overrides:
sizein classJaxxDefaultListModel<E>- Returns:
- the number of components in this list
- See Also:
Vector.size()
-
trimToSize
public void trimToSize()
Description copied from class:JaxxDefaultListModelTrims the capacity of this list to be the list's current size.- Overrides:
trimToSizein classJaxxDefaultListModel<E>- See Also:
Vector.trimToSize()
-
ensureCapacity
public void ensureCapacity(int minCapacity)
Description copied from class:JaxxDefaultListModelIncreases the capacity of this list, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.- Overrides:
ensureCapacityin classJaxxDefaultListModel<E>- Parameters:
minCapacity- the desired minimum capacity- See Also:
Vector.ensureCapacity(int)
-
setSize
public void setSize(int newSize)
Description copied from class:JaxxDefaultListModelSets the size of this list.- Overrides:
setSizein classJaxxDefaultListModel<E>- Parameters:
newSize- the new size of this list- See Also:
Vector.setSize(int)
-
setElementAt
public void setElementAt(E element, int index)
Description copied from class:JaxxDefaultListModelSets the component at the specifiedindexof this list to be the specified element. The previous component at that position is discarded.Throws an
ArrayIndexOutOfBoundsExceptionif the index is invalid.Note: Although this method is not deprecated, the preferred method to use is
set(int,Object), which implements theListinterface defined in the 1.2 Collections framework.- Overrides:
setElementAtin classJaxxDefaultListModel<E>- Parameters:
element- what the component is to be set toindex- the specified index- See Also:
JaxxDefaultListModel.set(int, Object),Vector.setElementAt(Object, int)
-
removeElementAt
public void removeElementAt(int index)
Description copied from class:JaxxDefaultListModelDeletes the component at the specified index.Throws an
ArrayIndexOutOfBoundsExceptionif the index is invalid.Note: Although this method is not deprecated, the preferred method to use is
remove(int), which implements theListinterface defined in the 1.2 Collections framework.- Overrides:
removeElementAtin classJaxxDefaultListModel<E>- Parameters:
index- the index of the object to remove- See Also:
JaxxDefaultListModel.remove(int),Vector.removeElementAt(int)
-
insertElementAt
public void insertElementAt(E element, int index)
Description copied from class:JaxxDefaultListModelInserts the specified element as a component in this list at the specifiedindex.Throws an
ArrayIndexOutOfBoundsExceptionif the index is invalid.Note: Although this method is not deprecated, the preferred method to use is
add(int,Object), which implements theListinterface defined in the 1.2 Collections framework.- Overrides:
insertElementAtin classJaxxDefaultListModel<E>- Parameters:
element- the component to insertindex- where to insert the new component- See Also:
JaxxDefaultListModel.add(int, Object),Vector.insertElementAt(Object, int)
-
removeAllElements
public void removeAllElements()
Description copied from class:JaxxDefaultListModelRemoves all components from this list and sets its size to zero.Note: Although this method is not deprecated, the preferred method to use is
clear, which implements theListinterface defined in the 1.2 Collections framework.- Overrides:
removeAllElementsin classJaxxDefaultListModel<E>- See Also:
JaxxDefaultListModel.clear(),Vector.removeAllElements()
-
set
public E set(int index, E element)
Description copied from class:JaxxDefaultListModelReplaces the element at the specified position in this list with the specified element.Throws an
ArrayIndexOutOfBoundsExceptionif the index is out of range (index < 0 || index >= size()).- Overrides:
setin classJaxxDefaultListModel<E>- Parameters:
index- index of element to replaceelement- element to be stored at the specified position- Returns:
- the element previously at the specified position
-
add
public void add(int index, E element)Description copied from class:JaxxDefaultListModelInserts the specified element at the specified position in this list.Throws an
ArrayIndexOutOfBoundsExceptionif the index is out of range (index < 0 || index > size()).- Overrides:
addin classJaxxDefaultListModel<E>- Parameters:
index- index at which the specified element is to be insertedelement- element to be inserted
-
setAllElements
public void setAllElements(Collection<E> objects)
- Overrides:
setAllElementsin classJaxxDefaultListModel<E>
-
addAllElements
public void addAllElements(Collection<E> elements)
- Overrides:
addAllElementsin classJaxxDefaultListModel<E>
-
removeAllElements
public void removeAllElements(Collection<E> elements)
- Overrides:
removeAllElementsin classJaxxDefaultListModel<E>
-
remove
public E remove(int index)
Description copied from class:JaxxDefaultListModelRemoves the element at the specified position in this list. Returns the element that was removed from the list.Throws an
ArrayIndexOutOfBoundsExceptionif the index is out of range (index < 0 || index >= size()).- Overrides:
removein classJaxxDefaultListModel<E>- Parameters:
index- the index of the element to removed- Returns:
- the element previously at the specified position
-
clear
public void clear()
Description copied from class:JaxxDefaultListModelRemoves all of the elements from this list. The list will be empty after this call returns (unless it throws an exception).- Overrides:
clearin classJaxxDefaultListModel<E>
-
removeRange
public void removeRange(int fromIndex, int toIndex)Description copied from class:JaxxDefaultListModelDeletes the components at the specified range of indexes. The removal is inclusive, so specifying a range of (1,5) removes the component at index 1 and the component at index 5, as well as all components in between.Throws an
ArrayIndexOutOfBoundsExceptionif the index was invalid. Throws anIllegalArgumentExceptioniffromIndex > toIndex.- Overrides:
removeRangein classJaxxDefaultListModel<E>- Parameters:
fromIndex- the index of the lower end of the rangetoIndex- the index of the upper end of the range- See Also:
JaxxDefaultListModel.remove(int)
-
getFilterText
public String getFilterText()
-
setFilterText
public void setFilterText(String filterText)
-
getDecorator
public io.ultreia.java4all.decoration.Decorator getDecorator()
-
setDecorator
public void setDecorator(io.ultreia.java4all.decoration.Decorator decorator)
-
clearFilters
public void clearFilters()
-
refreshFilteredElements
public void refreshFilteredElements()
-
refilter
protected void refilter()
-
-