Class DnDListModel<T>

Object
AbstractListModel<T>
DnDListModel<T>
All Implemented Interfaces:
Serializable, ListModel<T>

public class DnDListModel<T> extends AbstractListModel<T>
A generic ListModel class to support DnDList.

The DnDListModel acts as a wrapper around an internal list of items; providing notification as the items are changed.

Since:
2.6
Author:
Michael Bedward
See Also:
  • Constructor Details

    • DnDListModel

      public DnDListModel()
      Default constructor
  • Method Details

    • setNofifyListeners

      public void setNofifyListeners(boolean notify)
    • getNotifyListeners

      public boolean getNotifyListeners()
    • getSize

      public int getSize()
    • getElementAt

      public T getElementAt(int index)
      Get the list item at the specified index.

      Note: this method returns a live reference.

      Throws:
      IndexOutOfBoundsException - if index is invalid
    • getElementsAt

      public List<T> getElementsAt(int[] indices)
      Returns a list of the items at the specified indices.

      Note: The returned List contains live references.

      Throws:
      IndexOutOfBoundsException - if any of the indices are invalid
    • getElementsAt

      public List<T> getElementsAt(Collection<Integer> indices)
      Returns a list of the items at the indices specified in the Collection.

      Note: The returned List contains live references.

      Throws:
      IndexOutOfBoundsException - if any of the indices are invalid
    • addItem

      public void addItem(T newItem)
      Append a new item to the end of the list of current items
    • addItems

      public void addItems(T[] newItems)
      Add new items to the end of the list of current items
    • addItems

      public void addItems(Collection<T> newItems)
      Add new items to the end of the list of current items
    • insertItem

      public void insertItem(int destIndex, T newItem)
      Insert an item into the list at the specified position.
      Parameters:
      destIndex - the position of the new item: if < 0 the item will be inserted at the start of the list; if >= the current list size the item will be appended to the end of the list
    • insertItems

      public void insertItems(int destIndex, T[] newItems)
      Insert new items into the list at the specified position.
      Parameters:
      destIndex - the position of the new item: if < 0 the items will be inserted at the start of the list; if >= the current list size the items will be appended to the end of the list
    • insertItems

      public void insertItems(int destIndex, Collection<T> newItems)
      Insert new items into the list at the specified position.
      Parameters:
      destIndex - the position of the new item: if < 0 the items will be inserted at the start of the list; if >= the current list size the items will be appended to the end of the list
    • moveItems

      public void moveItems(int destIndex, int[] srcIndices)
      Move the items currently positioned at the indices in the srcIndices array as block such that they are inserted into the list at destIndex. It is assumed that srcIndices is sorted in ascending order.
    • removeAt

      public void removeAt(int index)
      Remove the item at the specified index
    • removeItem

      public void removeItem(T item)
      Removes the first instance of the specified item if it is contained in the list
    • clear

      public void clear()
      Remove all items from the list
    • contains

      public boolean contains(T item)
      Query whether this list contains the specified item
    • indexOf

      public int indexOf(T item)
      Get the (first) index of the given item in the list of items held by this model.
      Parameters:
      item - the item to search for
      Returns:
      the index or -1 if the item is not present
    • toString

      public String toString()
      Overrides:
      toString in class Object