Class AbstractVetoableValue<T>
java.lang.Object
org.eclipse.core.databinding.observable.AbstractObservable
org.eclipse.core.databinding.observable.value.AbstractObservableValue<T>
org.eclipse.core.databinding.observable.value.AbstractVetoableValue<T>
- Type Parameters:
T
- the type of value being observed
- All Implemented Interfaces:
IObservable
,IObservableValue<T>
,IVetoableValue<T>
public abstract class AbstractVetoableValue<T>
extends AbstractObservableValue<T>
implements IVetoableValue<T>
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addListener
(Object listenerType, IObservablesListener listener) void
addValueChangingListener
(IValueChangingListener<T> listener) protected Object
clone()
protected abstract void
doSetApprovedValue
(T value) Sets the value.protected final void
doSetValue
(T value) Template method for setting the value of the observable.protected void
fireEvent
(ObservableEvent event) protected boolean
fireValueChanging
(ValueDiff<T> diff) Notifies listeners about a pending change, and returns true if no listener vetoed the change.protected void
getRealm()
protected boolean
protected void
protected void
removeListener
(Object listenerType, IObservablesListener listener) void
removeValueChangingListener
(IValueChangingListener<T> listener) Methods inherited from class org.eclipse.core.databinding.observable.value.AbstractObservableValue
addValueChangeListener, doGetValue, fireChange, fireValueChange, getValue, isStale, removeValueChangeListener, setValue
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
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.core.databinding.observable.IObservable
addChangeListener, addDisposeListener, addStaleListener, dispose, getRealm, isDisposed, isStale, removeChangeListener, removeDisposeListener, removeStaleListener
Methods inherited from interface org.eclipse.core.databinding.observable.value.IObservableValue
addValueChangeListener, getValue, getValueType, removeValueChangeListener, setValue
-
Constructor Details
-
AbstractVetoableValue
public AbstractVetoableValue()Creates a new vetoable value. -
AbstractVetoableValue
- Parameters:
realm
- the realm
-
-
Method Details
-
doSetValue
Description copied from class:AbstractObservableValue
Template method for setting the value of the observable. By default the method throws anUnsupportedOperationException
.- Overrides:
doSetValue
in classAbstractObservableValue<T>
- Parameters:
value
- the value to set
-
doSetApprovedValue
Sets the value. Invoked after performing veto checks. Should not fire change events.- Parameters:
value
- the approved value to set
-
addValueChangingListener
- Specified by:
addValueChangingListener
in interfaceIVetoableValue<T>
- Parameters:
listener
- the listener to add; notnull
-
removeValueChangingListener
- Specified by:
removeValueChangingListener
in interfaceIVetoableValue<T>
- Parameters:
listener
- the listener to remove; notnull
-
fireValueChanging
Notifies listeners about a pending change, and returns true if no listener vetoed the change.- Parameters:
diff
- the pending change- Returns:
- false if the change was vetoed, true otherwise
-
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
-