| Prev Class | Next Class | Frames | No Frames |
| Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Objectcom.jgoodies.binding.beans.Modelcom.jgoodies.binding.value.AbstractValueModelcom.jgoodies.binding.value.Triggerpublic final class Triggerextends AbstractValueModel#triggerCommit and #triggerFlush.
This Trigger class works around an inconvenient situation when using
a general ValueHolder as trigger channel of a BufferedValueModel.
BufferedValueHolder performs commit and flush events only if the trigger
channel value reports a change. And a ValueHolder doesn't report a change
if #setValue tries to set the current value. For example
if you set Boolean.TRUE twice, the latter doesn't fire
a property change event. The methods #triggerCommit and
#triggerFlush check for the current state and guarantee
that the appropriate PropertyChangeEvent is fired.
On the other hand, the implementation minimizes the number of events
necessary to commit or flush buffered values.
Constraints: The value is of type Boolean.
The following example delays the commit of a buffered value:
ValueModel subject = new ValueHolder();
Trigger trigger = new Trigger();
BufferedValueModel buffer = new BufferedValueModel(subject, trigger);
buffer.setValue("value");
...
trigger.triggerCommit();
BufferedValueModelField Summary |
Fields inherited from class com.jgoodies.binding.value.AbstractValueModel | |
PROPERTYNAME_VALUE | |
Constructor Summary | |
| |
Method Summary | |
Object |
|
void |
|
void |
|
void |
|
Methods inherited from class com.jgoodies.binding.value.AbstractValueModel | |
String toString, addValueChangeListener, booleanValue, doubleValue, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, floatValue, getString, intValue, longValue, paramString, removeValueChangeListener, setValue, setValue, setValue, setValue, setValue, valueString | |
public Object getValue()
Returns a Boolean that indicates the current trigger state.
- Specified by:
- getValue in interface ValueModel
- Returns:
- a Boolean that indicates the current trigger state
public void setValue(Object newValue)
Sets a new Boolean value and rejects all non-Boolean values. Fires no change event if the new value is equal to the previously set value. This method is not intended to be used by API users. Instead you should trigger commit and flush events by invoking#triggerCommitor#triggerFlush.
- Specified by:
- setValue in interface ValueModel
- Parameters:
newValue- the Boolean value to be set
public void triggerCommit()
Triggers a commit event in BufferedValueModels that share this Trigger. Sets the value toBoolean.TRUEand ensures that listeners are notified about a value change to this new value. If necessary the value is temporarily set tonull. This way it minimizes the number of PropertyChangeEvents fired by this Trigger.
public void triggerFlush()
Triggers a flush event in BufferedValueModels that share this Trigger. Sets the value toBoolean.FALSEand ensures that listeners are notified about a value change to the new value. If necessary the value is temporarily set tonull. This way it minimizes the number of PropertyChangeEvents fired by this Trigger.