Class ListWrapperListModel<E>

java.lang.Object
javax.swing.AbstractListModel
groovy.swing.impl.ListWrapperListModel<E>
All Implemented Interfaces:
Serializable, ListModel

public class ListWrapperListModel<E> extends AbstractListModel
A ListModel implementation that's backed by a live List.
See Also:
  • Constructor Details

    • ListWrapperListModel

      public ListWrapperListModel(List<E> delegateList)
      Creates a list model backed by the supplied live list.
      Parameters:
      delegateList - the backing list
  • Method Details

    • getDelegateList

      public List<E> getDelegateList()
      Returns the live backing list.
      Returns:
      the delegate list
    • getSize

      public int getSize()
      Returns the number of elements currently exposed by the backing list.
      Returns:
      the current model size
    • getElementAt

      public Object getElementAt(int i)
      Returns the element at the supplied index from the backing list.
      Parameters:
      i - the requested element index
      Returns:
      the element at i
    • set

      public E set(int i, E e)
      Replaces the element at the supplied index and fires a content-changed event.
      Parameters:
      i - the element index
      e - the replacement element
      Returns:
      the previous element
    • clear

      public void clear()
      Removes every element from the backing list and notifies listeners.
    • lastIndexOf

      public int lastIndexOf(Object o)
      Returns the last index of the supplied element in the backing list.
      Parameters:
      o - the element to search for
      Returns:
      the last matching index, or -1
    • contains

      public boolean contains(Object o)
      Returns whether the backing list contains the supplied element.
      Parameters:
      o - the element to search for
      Returns:
      true when the element is present
    • listIterator

      public ListIterator<E> listIterator()
      Returns a list iterator over the backing list.
      Returns:
      a list iterator over the current contents
    • isEmpty

      public boolean isEmpty()
      Returns whether the backing list is empty.
      Returns:
      true when the model contains no elements
    • indexOf

      public int indexOf(Object o)
      Returns the first index of the supplied element in the backing list.
      Parameters:
      o - the element to search for
      Returns:
      the first matching index, or -1
    • add

      public void add(int i, E e)
      Inserts an element at the supplied index and notifies listeners.
      Parameters:
      i - the insertion index
      e - the element to insert
    • iterator

      public Iterator<E> iterator()
      Returns an iterator over the backing list.
      Returns:
      an iterator over the current contents
    • addAll

      public boolean addAll(Collection<? extends E> es)
      Appends every element from the supplied collection and notifies listeners when anything was added.
      Parameters:
      es - the elements to append
      Returns:
      true when the backing list changed
    • remove

      public E remove(int i)
      Removes the element at the supplied index and notifies listeners.
      Parameters:
      i - the element index
      Returns:
      the removed element
    • addAll

      public boolean addAll(int i, Collection<? extends E> es)
      Inserts every element from the supplied collection at the supplied index.
      Parameters:
      i - the insertion index
      es - the elements to insert
      Returns:
      true when the backing list changed
    • listIterator

      public ListIterator<E> listIterator(int i)
      Returns a list iterator that starts at the supplied index.
      Parameters:
      i - the starting index
      Returns:
      a list iterator positioned at the supplied index
    • containsAll

      public boolean containsAll(Collection<?> objects)
      Returns whether the backing list contains every supplied element.
      Parameters:
      objects - the elements to test
      Returns:
      true when every element is present
    • remove

      public boolean remove(Object o)
      Removes the supplied element from the backing list and notifies listeners when it was present.
      Parameters:
      o - the element to remove
      Returns:
      true when the backing list changed
    • add

      public boolean add(E e)
      Appends the supplied element to the backing list and notifies listeners.
      Parameters:
      e - the element to append
      Returns:
      true when the backing list changed
    • get

      public E get(int i)
      Returns the element at the supplied index.
      Parameters:
      i - the element index
      Returns:
      the element at that index
    • toArray

      public <T> T[] toArray(T[] ts)
      Copies the backing list into the supplied destination array.
      Type Parameters:
      T - the array component type
      Parameters:
      ts - the destination array
      Returns:
      the populated array
    • toArray

      public Object[] toArray()
      Copies the backing list into a new object array.
      Returns:
      an array containing the current contents
    • removeRange

      public void removeRange(int fromIndex, int toIndex)
      Removes the inclusive index range from the backing list and notifies listeners.
      Parameters:
      fromIndex - the first index to remove
      toIndex - the last index to remove