Package groovy.swing.impl
Class ListWrapperListModel<E>
java.lang.Object
javax.swing.AbstractListModel
groovy.swing.impl.ListWrapperListModel<E>
- All Implemented Interfaces:
Serializable,ListModel
A
ListModel implementation that's backed by a live List.- See Also:
-
Field Summary
Fields inherited from class javax.swing.AbstractListModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionListWrapperListModel(List<E> delegateList) Creates a list model backed by the supplied live list. -
Method Summary
Modifier and TypeMethodDescriptionvoidInserts an element at the supplied index and notifies listeners.booleanAppends the supplied element to the backing list and notifies listeners.booleanaddAll(int i, Collection<? extends E> es) Inserts every element from the supplied collection at the supplied index.booleanaddAll(Collection<? extends E> es) Appends every element from the supplied collection and notifies listeners when anything was added.voidclear()Removes every element from the backing list and notifies listeners.booleanReturns whether the backing list contains the supplied element.booleancontainsAll(Collection<?> objects) Returns whether the backing list contains every supplied element.get(int i) Returns the element at the supplied index.Returns the live backing list.getElementAt(int i) Returns the element at the supplied index from the backing list.intgetSize()Returns the number of elements currently exposed by the backing list.intReturns the first index of the supplied element in the backing list.booleanisEmpty()Returns whether the backing list is empty.iterator()Returns an iterator over the backing list.intReturns the last index of the supplied element in the backing list.Returns a list iterator over the backing list.listIterator(int i) Returns a list iterator that starts at the supplied index.remove(int i) Removes the element at the supplied index and notifies listeners.booleanRemoves the supplied element from the backing list and notifies listeners when it was present.voidremoveRange(int fromIndex, int toIndex) Removes the inclusive index range from the backing list and notifies listeners.Replaces the element at the supplied index and fires a content-changed event.Object[]toArray()Copies the backing list into a new object array.<T> T[]toArray(T[] ts) Copies the backing list into the supplied destination array.Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
Constructor Details
-
ListWrapperListModel
Creates a list model backed by the supplied live list.- Parameters:
delegateList- the backing list
-
-
Method Details
-
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
Returns the element at the supplied index from the backing list.- Parameters:
i- the requested element index- Returns:
- the element at
i
-
set
Replaces the element at the supplied index and fires a content-changed event.- Parameters:
i- the element indexe- the replacement element- Returns:
- the previous element
-
clear
public void clear()Removes every element from the backing list and notifies listeners. -
lastIndexOf
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
Returns whether the backing list contains the supplied element.- Parameters:
o- the element to search for- Returns:
truewhen the element is present
-
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:
truewhen the model contains no elements
-
indexOf
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
Inserts an element at the supplied index and notifies listeners.- Parameters:
i- the insertion indexe- the element to insert
-
iterator
Returns an iterator over the backing list.- Returns:
- an iterator over the current contents
-
addAll
Appends every element from the supplied collection and notifies listeners when anything was added.- Parameters:
es- the elements to append- Returns:
truewhen the backing list changed
-
remove
Removes the element at the supplied index and notifies listeners.- Parameters:
i- the element index- Returns:
- the removed element
-
addAll
Inserts every element from the supplied collection at the supplied index.- Parameters:
i- the insertion indexes- the elements to insert- Returns:
truewhen the backing list changed
-
listIterator
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
Returns whether the backing list contains every supplied element.- Parameters:
objects- the elements to test- Returns:
truewhen every element is present
-
remove
Removes the supplied element from the backing list and notifies listeners when it was present.- Parameters:
o- the element to remove- Returns:
truewhen the backing list changed
-
add
Appends the supplied element to the backing list and notifies listeners.- Parameters:
e- the element to append- Returns:
truewhen the backing list changed
-
get
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
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 removetoIndex- the last index to remove
-