Class EnhancedListModel<T>

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:
  • Constructor Details

    • EnhancedListModel

      public EnhancedListModel()
    • EnhancedListModel

      public EnhancedListModel(Collection<? extends T> pContents)
  • Method Details

    • isEventFiringEnabled

      protected boolean isEventFiringEnabled()
      ListModelEvents are fired if this is true.
    • setEventFiringEnabled

      protected void setEventFiringEnabled(boolean pEventFiringEnabled)
      See Also:
    • 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 interface Reorderable
    • 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 class DefaultListModel<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.
    • toArray

      public Object[] toArray(Object[] pType)
    • fireContentsChanged

      public void fireContentsChanged(Object pSrc, int pIdx0, int pIdx1)
      TODO: Protect method.
      Overrides:
      fireContentsChanged in class AbstractListModel<T>
    • fireIntervalAdded

      protected void fireIntervalAdded(Object pSrc, int pIdx0, int pIdx1)
      Overrides:
      fireIntervalAdded in class AbstractListModel<T>
    • fireIntervalRemoved

      protected void fireIntervalRemoved(Object pSrc, int pIdx0, int pIdx1)
      Overrides:
      fireIntervalRemoved in class AbstractListModel<T>