Class SortableListModel<T>
- java.lang.Object
-
- javax.swing.AbstractListModel<T>
-
- org.opends.guitools.controlpanel.datamodel.SortableListModel<T>
-
- Type Parameters:
T- type of the elements in this list model
- All Implemented Interfaces:
Serializable,ListModel<T>
public class SortableListModel<T> extends AbstractListModel<T>
Note: this implementation does not call automatically fireContentsChanged, its up to the caller of the different methods of this implementation to call it explicitly. This is done because in general there is a series of calls to the add/remove methods and a single call to notify that things have changed is enough.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.swing.AbstractListModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description SortableListModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(T value)Adds a value to the list model.voidaddAll(Collection<T> newData)Adds all the elements in the collection to the list model.voidclear()Clears the list model.voidfireContentsChanged(Object source, int index0, int index1)SortedSet<T>getData()Returns the data in this list model ordered.TgetElementAt(int i)intgetSize()booleanremove(T value)Removes a value from the list model.voidsetComparator(Comparator<T> comp)Sets the comparator to be used to sort the list.-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
-
-
-
Method Detail
-
getSize
public int getSize()
-
setComparator
public void setComparator(Comparator<T> comp)
Sets the comparator to be used to sort the list.- Parameters:
comp- the comparator.
-
getElementAt
public T getElementAt(int i)
-
add
public void add(T value)
Adds a value to the list model.- Parameters:
value- the value to be added.
-
remove
public boolean remove(T value)
Removes a value from the list model.- Parameters:
value- the value to be removed.- Returns:
trueif the element was on the list andfalseotherwise.
-
clear
public void clear()
Clears the list model.
-
addAll
public void addAll(Collection<T> newData)
Adds all the elements in the collection to the list model.- Parameters:
newData- the collection containing the elements to be added.
-
fireContentsChanged
public void fireContentsChanged(Object source, int index0, int index1)
- Overrides:
fireContentsChangedin classAbstractListModel<T>
-
-