Class ObservableList<E>
java.lang.Object
org.eclipse.core.databinding.observable.AbstractObservable
org.eclipse.core.databinding.observable.list.ObservableList<E>
- Type Parameters:
E- the type of the elements in this list
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,SequencedCollection<E>,IObservable,IObservableCollection<E>,IObservableList<E>
- Direct Known Subclasses:
WritableList
Abstract implementation of
IObservableList, based on an underlying
regular list.
This class is thread safe. All state accessing methods must be invoked from
the current realm. Methods for adding and removing
listeners may be invoked from any thread.
- Since:
- 1.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedObservableList(List<E> wrappedList, Object elementType) protectedObservableList(Realm realm, List<E> wrappedList, Object elementType) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends E> c) booleanaddAll(Collection<? extends E> c) voidaddListChangeListener(IListChangeListener<? super E> listener) Adds the given list change listener to the list of list change listeners.protected voidaddListener(Object listenerType, IObservablesListener listener) voidclear()protected Objectclone()booleanbooleancontainsAll(Collection<?> c) booleanprotected voidprotected voidfireEvent(ObservableEvent event) protected voidfireListChange(ListDiff<E> diff) protected voidget(int index) Returns the element type of this observable collection, ornullif this observable collection is untyped.getRealm()protected voidinthashCode()protected booleanintbooleanisEmpty()booleanisStale()Returns the stale state.iterator()intprotected voidlistIterator(int index) move(int oldIndex, int newIndex) Moves the element located atoldIndextonewIndex.remove(int index) booleanbooleanremoveAll(Collection<?> c) voidremoveListChangeListener(IListChangeListener<? super E> listener) Removes the given list change listener from the list of list change listeners.protected voidremoveListener(Object listenerType, IObservablesListener listener) booleanretainAll(Collection<?> c) voidsetStale(boolean stale) Sets the stale state.intsize()subList(int fromIndex, int toIndex) Object[]toArray()<T> T[]toArray(T[] a) toString()protected voidupdateWrappedList(List<E> newList) Methods inherited from class org.eclipse.core.databinding.observable.AbstractObservable
addChangeListener, addDisposeListener, addStaleListener, checkRealm, dispose, fireStale, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListenerMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface org.eclipse.core.databinding.observable.IObservable
addChangeListener, addDisposeListener, addStaleListener, dispose, getRealm, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListenerMethods inherited from interface java.util.List
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
wrappedList
-
-
Constructor Details
-
ObservableList
-
ObservableList
-
-
Method Details
-
addListChangeListener
Description copied from interface:IObservableListAdds the given list change listener to the list of list change listeners.- Specified by:
addListChangeListenerin interfaceIObservableList<E>- Parameters:
listener- the change listener to add; notnull
-
removeListChangeListener
Description copied from interface:IObservableListRemoves the given list change listener from the list of list change listeners. Has no effect if the given listener is not registered as a list change listener.- Specified by:
removeListChangeListenerin interfaceIObservableList<E>- Parameters:
listener- the change listener to remove; notnull
-
fireListChange
-
contains
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceIObservableList<E>- Specified by:
containsin interfaceList<E>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceIObservableList<E>- Specified by:
containsAllin interfaceList<E>
-
equals
-
hashCode
public int hashCode() -
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceIObservableList<E>- Specified by:
isEmptyin interfaceList<E>
-
iterator
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceIObservableList<E>- Specified by:
sizein interfaceList<E>
-
toArray
- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceIObservableList<E>- Specified by:
toArrayin interfaceList<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceIObservableList<E>- Specified by:
toArrayin interfaceList<E>
-
toString
-
get
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceIObservableList<E>- Specified by:
lastIndexOfin interfaceList<E>- TrackedGetter
-
listIterator
- Specified by:
listIteratorin interfaceIObservableList<E>- Specified by:
listIteratorin interfaceList<E>- TrackedGetter
-
listIterator
- Specified by:
listIteratorin interfaceIObservableList<E>- Specified by:
listIteratorin interfaceList<E>- TrackedGetter
-
subList
-
getterCalled
protected void getterCalled() -
set
-
move
Moves the element located atoldIndextonewIndex. This method is equivalent to callingadd(newIndex, remove(oldIndex)).Subclasses should override this method to deliver list change notification for the remove and add operations in the same ListChangeEvent, as this allows
ListDiff.accept(ListDiffVisitor)to recognize the operation as a move.- Specified by:
movein interfaceIObservableList<E>- Parameters:
oldIndex- the element's position before the move. Must be within the range0 <= oldIndex < size().newIndex- the element's position after the move. Must be within the range0 <= newIndex < size().- Returns:
- the element that was moved.
- Throws:
IndexOutOfBoundsException- if either argument is out of range (0 <= index < size()).- Since:
- 1.1
- See Also:
-
remove
-
add
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceIObservableList<E>- Specified by:
addin interfaceList<E>
-
add
-
addAll
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceIObservableList<E>- Specified by:
addAllin interfaceList<E>
-
addAll
-
remove
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceIObservableList<E>- Specified by:
removein interfaceList<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceIObservableList<E>- Specified by:
removeAllin interfaceList<E>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceIObservableList<E>- Specified by:
retainAllin interfaceList<E>
-
clear
public void clear() -
isStale
public boolean isStale()Returns the stale state. Must be invoked from the current realm.- Specified by:
isStalein interfaceIObservable- Returns:
- stale state
-
setStale
public void setStale(boolean stale) Sets the stale state. Must be invoked from the current realm.- Parameters:
stale- The stale state to list. This will fire a stale event if the given boolean is true and this observable list was not already stale.
-
fireChange
protected void fireChange()- Overrides:
fireChangein classAbstractObservable
-
getElementType
Description copied from interface:IObservableCollectionReturns the element type of this observable collection, ornullif this observable collection is untyped.- Specified by:
getElementTypein interfaceIObservableCollection<E>- Specified by:
getElementTypein interfaceIObservableList<E>- Returns:
- the type of the elements or
nullif untyped
-
updateWrappedList
-
addListener
- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to add; notnull
-
removeListener
- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to remove; notnull
-
hasListeners
protected boolean hasListeners() -
fireEvent
-
firstListenerAdded
protected void firstListenerAdded() -
lastListenerRemoved
protected void lastListenerRemoved() -
getRealm
- Returns:
- Returns the realm.
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-