E - the type of elements in the decorated (and this) listpublic class ObservableList<E> extends ListDecorator<E>
List that allows to track modifications of the underlying list
using an ListChangeListener.| Constructor and Description |
|---|
ObservableList(java.util.List<E> underlyingList)
Creates a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListChangeListener(ListChangeListener<E> listener)
Adds a change listener to track changes of the underlying list.
|
protected void |
afterAdd(int index,
java.util.Collection<? extends E> addedElements)
This method is called at the end of all methods of this list that add elements to it, including
methods called on the results of
or iterators. |
protected void |
afterRemove(int index,
java.util.Collection<? extends E> removedElements)
This method is called at the end of all methods of this list that remove elements from it, including
methods called on the results of
ListDecorator.subList(int, int) or iterators. |
protected void |
afterReplace(int index,
E previousElement,
E currentElement)
This method is called at the end of
ListDecorator.set(int, Object) to indicate that an element has been
replaced. |
protected void |
beforeAdd(int index,
java.util.Collection<? extends E> addedElements)
This method is called at the beginning of all methods of this list that add elements to it (including
methods called on the results of
ListDecorator.subList(int, int) or iterators) before the actual inserting
happens. |
protected void |
beforeRemove(int index,
java.util.Collection<java.lang.Object> removedElements)
This method is called at the beginning of all methods of this list that remove elements from it (including
methods called on the results of
ListDecorator.subList(int, int) or iterators) before the actual deletion
happens. |
protected void |
beforeReplace(int index,
E currentElement,
E newElement)
This method is called at the beginning of
ListDecorator.set(int, Object) to indicate that an element will be
replaced. |
boolean |
removeListChangeListener(ListChangeListener<E> listener)
Removes a listener from this list.
|
add, add, addAll, addAll, clear, contains, containsAll, createDecoratedListIterator, equals, get, getUnderlyingList, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArraypublic ObservableList(java.util.List<E> underlyingList)
underlyingList - the list to be observedpublic void addListChangeListener(ListChangeListener<E> listener)
listener - the listener to addpublic boolean removeListChangeListener(ListChangeListener<E> listener)
listener - the listener to be removedtrue if this list contained the specified elementprotected void beforeAdd(int index, java.util.Collection<? extends E> addedElements)
ListDecoratorListDecorator.subList(int, int) or iterators) before the actual inserting
happens. This default implementation is empty and can be overwritten by inherited classes which want
to track modifications of the list.
If more than one element will be add in one operation (e.g. ListDecorator.addAll(Collection)) this method
is only called once before the first elements is inserted.
beforeAdd in class ListDecorator<E>index - the index where the first new element will be insertedaddedElements - the elements that shall be add (Always contains at least one element.)protected void afterAdd(int index, java.util.Collection<? extends E> addedElements)
ListDecoratoror iterators. This default implementation
is empty and can be overwritten by inherited classes which want to track modifications of the list.
If more than one element is add in one operation (e.g. ListDecorator.addAll(Collection)) this method
is only called once when all elements have been inserted.
Note that this method is not called if an add operation is not successful. In such a case only
ListDecorator.beforeAdd(int, Collection) is called.
afterAdd in class ListDecorator<E>index - the index where the first new element has been insertedaddedElements - the elements that have been add (Always contains at least one element.)protected void beforeReplace(int index, E currentElement, E newElement)
ListDecoratorListDecorator.set(int, Object) to indicate that an element will be
replaced. This default implementation is empty and can be overwritten by inherited classes which want
to track modifications of the list.beforeReplace in class ListDecorator<E>index - the index where the element will be replacedcurrentElement - the element that will be replacednewElement - the new element that shall replace the current oneprotected void afterReplace(int index, E previousElement, E currentElement)
ListDecoratorListDecorator.set(int, Object) to indicate that an element has been
replaced. This default implementation is empty and can be overwritten by inherited classes which want
to track modifications of the list.afterReplace in class ListDecorator<E>index - the index where the element has been replacedpreviousElement - the element that was replacedcurrentElement - the new element that is now contained in the listprotected void beforeRemove(int index, java.util.Collection<java.lang.Object> removedElements)
ListDecoratorListDecorator.subList(int, int) or iterators) before the actual deletion
happens. This default implementation is empty and can be overwritten by inherited classes which want to
track modifications of the list.
If more than one element will be removed in one operation (e.g. ListDecorator.retainAll(Collection)) this method
is only called once before the first element is removed.
beforeRemove in class ListDecorator<E>removedElements - the elements that have been removed.protected void afterRemove(int index, java.util.Collection<? extends E> removedElements)
ListDecoratorListDecorator.subList(int, int) or iterators. This default implementation
is empty and can be overwritten by inherited classes which want to track modifications of the list.
If more than one element is removed in one operation (e.g. ListDecorator.retainAll(Collection)) this method
is only called once when all elements have been removed.
Note that this method is not called if an add operation is not successful. In such a case only
#beforeRemove(Collection) is called.
afterRemove in class ListDecorator<E>removedElements - the elements that have been removed.