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>
,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
-
Constructor Summary
ModifierConstructorDescriptionprotected
ObservableList
(List<E> wrappedList, Object elementType) protected
ObservableList
(Realm realm, List<E> wrappedList, Object elementType) -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection<? extends E> c) boolean
addAll
(Collection<? extends E> c) void
addListChangeListener
(IListChangeListener<? super E> listener) Adds the given list change listener to the list of list change listeners.protected void
addListener
(Object listenerType, IObservablesListener listener) void
clear()
protected Object
clone()
boolean
boolean
containsAll
(Collection<?> c) boolean
protected void
protected void
fireEvent
(ObservableEvent event) protected void
fireListChange
(ListDiff<E> diff) protected void
get
(int index) Returns the element type of this observable collection, ornull
if this observable collection is untyped.getRealm()
protected void
int
hashCode()
protected boolean
int
boolean
isEmpty()
boolean
isStale()
Returns the stale state.iterator()
int
protected void
listIterator
(int index) move
(int oldIndex, int newIndex) Moves the element located atoldIndex
tonewIndex
.remove
(int index) boolean
boolean
removeAll
(Collection<?> c) void
removeListChangeListener
(IListChangeListener<? super E> listener) Removes the given list change listener from the list of list change listeners.protected void
removeListener
(Object listenerType, IObservablesListener listener) boolean
retainAll
(Collection<?> c) void
setStale
(boolean stale) Sets the stale state.int
size()
subList
(int fromIndex, int toIndex) Object[]
toArray()
<T> T[]
toArray
(T[] a) toString()
protected void
updateWrappedList
(List<E> newList) Methods inherited from class org.eclipse.core.databinding.observable.AbstractObservable
addChangeListener, addDisposeListener, addStaleListener, checkRealm, dispose, fireStale, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface org.eclipse.core.databinding.observable.IObservable
addChangeListener, addDisposeListener, addStaleListener, dispose, getRealm, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
Field Details
-
wrappedList
-
-
Constructor Details
-
ObservableList
-
ObservableList
-
-
Method Details
-
addListChangeListener
Description copied from interface:IObservableList
Adds the given list change listener to the list of list change listeners.- Specified by:
addListChangeListener
in interfaceIObservableList<E>
- Parameters:
listener
- the change listener to add; notnull
-
removeListChangeListener
Description copied from interface:IObservableList
Removes 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:
removeListChangeListener
in interfaceIObservableList<E>
- Parameters:
listener
- the change listener to remove; notnull
-
fireListChange
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceIObservableList<E>
- Specified by:
contains
in interfaceList<E>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceIObservableList<E>
- Specified by:
containsAll
in interfaceList<E>
-
equals
-
hashCode
public int hashCode() -
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceIObservableList<E>
- Specified by:
isEmpty
in interfaceList<E>
-
iterator
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceIObservableList<E>
- Specified by:
size
in interfaceList<E>
-
toArray
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceIObservableList<E>
- Specified by:
toArray
in interfaceList<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceIObservableList<E>
- Specified by:
toArray
in interfaceList<E>
-
toString
-
get
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceIObservableList<E>
- Specified by:
lastIndexOf
in interfaceList<E>
- TrackedGetter
-
listIterator
- Specified by:
listIterator
in interfaceIObservableList<E>
- Specified by:
listIterator
in interfaceList<E>
- TrackedGetter
-
listIterator
- Specified by:
listIterator
in interfaceIObservableList<E>
- Specified by:
listIterator
in interfaceList<E>
- TrackedGetter
-
subList
-
getterCalled
protected void getterCalled() -
set
-
move
Moves the element located atoldIndex
tonewIndex
. 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:
move
in 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:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceIObservableList<E>
- Specified by:
add
in interfaceList<E>
-
add
-
addAll
- Specified by:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceIObservableList<E>
- Specified by:
addAll
in interfaceList<E>
-
addAll
-
remove
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceIObservableList<E>
- Specified by:
remove
in interfaceList<E>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceIObservableList<E>
- Specified by:
removeAll
in interfaceList<E>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceIObservableList<E>
- Specified by:
retainAll
in interfaceList<E>
-
clear
public void clear() -
isStale
public boolean isStale()Returns the stale state. Must be invoked from the current realm.- Specified by:
isStale
in 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:
fireChange
in classAbstractObservable
-
getElementType
Description copied from interface:IObservableCollection
Returns the element type of this observable collection, ornull
if this observable collection is untyped.- Specified by:
getElementType
in interfaceIObservableCollection<E>
- Specified by:
getElementType
in interfaceIObservableList<E>
- Returns:
- the type of the elements or
null
if 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:
clone
in classObject
- Throws:
CloneNotSupportedException
-