- java.lang.Object
-
- javax.swing.AbstractListModel<E>
-
- javax.swing.DefaultListModel<T>
-
- com.iamsoft.util.ui.EnhancedListModel<T>
-
- Type Parameters:
T
- The type of the elements of this model.
- All Implemented Interfaces:
Reorderable
,ReorderableListModel<T>
,Serializable
,ListModel<T>
- Direct Known Subclasses:
UndoableListModel
public class EnhancedListModel<T> extends DefaultListModel<T> implements ReorderableListModel<T>
Allow user to move items up/down within list. List models really should be generified.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EnhancedListModel.Direction
Enum for indicating direction of movement of items in list.
-
Field Summary
-
Fields inherited from class javax.swing.AbstractListModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description EnhancedListModel()
EnhancedListModel(Collection<? extends T> pContents)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAll(Collection<? extends T> pObjects)
Add all elements in a collection.void
fireContentsChanged(Object pSrc, int pIdx0, int pIdx1)
TODO: Protect method.protected void
fireIntervalAdded(Object pSrc, int pIdx0, int pIdx1)
protected void
fireIntervalRemoved(Object pSrc, int pIdx0, int pIdx1)
int[]
getIndices(Collection<?> pColl)
Any elements not present in list marked with -1.void
insertAll(Collection<? extends T> pObjects, int pIdx)
Inserts all elements in a collection.protected boolean
isEventFiringEnabled()
ListModelEvents are fired if this is true.void
move(Object pObject, EnhancedListModel.Direction pDir)
Move specified object up or down.void
moveAll(int[] pIndices, EnhancedListModel.Direction pDir)
Shifts elements at specified locations in specified direction.void
moveAll(Collection<?> pObjects, EnhancedListModel.Direction pDir)
Move specified objects up or down.void
removeAll(int[] pIndices)
Remove specified indices.boolean
removeAll(Collection<?> pColl)
Remove all elements in a collection.protected void
setEventFiringEnabled(boolean pEventFiringEnabled)
Object[]
toArray(Object[] pType)
-
Methods inherited from class javax.swing.DefaultListModel
add, addAll, addElement, capacity, clear, contains, copyInto, elementAt, elements, ensureCapacity, firstElement, get, getElementAt, getSize, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, removeAllElements, removeElement, removeElementAt, removeRange, set, setElementAt, setSize, size, toArray, toString, trimToSize
-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, getListDataListeners, getListeners, removeListDataListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.swing.ListModel
addListDataListener, getElementAt, getSize, removeListDataListener
-
-
-
-
Constructor Detail
-
EnhancedListModel
public EnhancedListModel()
-
EnhancedListModel
public EnhancedListModel(Collection<? extends T> pContents)
-
-
Method Detail
-
isEventFiringEnabled
protected boolean isEventFiringEnabled()
ListModelEvents are fired if this is true.
-
setEventFiringEnabled
protected void setEventFiringEnabled(boolean pEventFiringEnabled)
- See Also:
isEventFiringEnabled()
-
moveAll
public void moveAll(int[] pIndices, EnhancedListModel.Direction pDir)
Shifts elements at specified locations in specified direction. One event is fired with indices determined by range of updates. Behavior undefined if indices are duplicated or out of range.- Specified by:
moveAll
in interfaceReorderable
-
moveAll
public void moveAll(Collection<?> pObjects, EnhancedListModel.Direction pDir)
Move specified objects up or down. Behavior undefined if objects in collection are duplicated.
-
move
public void move(Object pObject, EnhancedListModel.Direction pDir)
Move specified object up or down.
-
getIndices
public int[] getIndices(Collection<?> pColl)
Any elements not present in list marked with -1.- Returns:
- int array with same size of Collection.
-
addAll
public void addAll(Collection<? extends T> pObjects)
Add all elements in a collection. Fires a single event.- Overrides:
addAll
in classDefaultListModel<T>
-
insertAll
public void insertAll(Collection<? extends T> pObjects, int pIdx)
Inserts all elements in a collection. Fires a single event.
-
removeAll
public void removeAll(int[] pIndices)
Remove specified indices. Contiguous ranges are removed as a batch. This method minimizes event notifications rather that execution time. Behavior undefined if indices are repeated or out of range.
-
removeAll
public boolean removeAll(Collection<?> pColl)
Remove all elements in a collection. Minimizes number of events rather than execution time. Behavior undefined if duplicate elements contained within argument collection.- Returns:
- true if list is updated.
-
fireContentsChanged
public void fireContentsChanged(Object pSrc, int pIdx0, int pIdx1)
TODO: Protect method.- Overrides:
fireContentsChanged
in classAbstractListModel<T>
-
fireIntervalAdded
protected void fireIntervalAdded(Object pSrc, int pIdx0, int pIdx1)
- Overrides:
fireIntervalAdded
in classAbstractListModel<T>
-
fireIntervalRemoved
protected void fireIntervalRemoved(Object pSrc, int pIdx0, int pIdx1)
- Overrides:
fireIntervalRemoved
in classAbstractListModel<T>
-
-