com.jgoodies.binding.value
public final class Trigger extends 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();
BufferedValueModel
PROPERTYNAME_VALUE
Constructor and Description |
---|
Trigger()
Constructs a Trigger set to neutral.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getValue()
Returns a Boolean that indicates the current trigger state.
|
void |
setValue(java.lang.Object newValue)
Sets a new Boolean value and rejects all non-Boolean values.
|
void |
triggerCommit()
Triggers a commit event in BufferedValueModels that share this Trigger.
|
void |
triggerFlush()
Triggers a flush event in BufferedValueModels that share this Trigger.
|
addValueChangeListener, booleanValue, doubleValue, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, floatValue, getString, intValue, longValue, paramString, removeValueChangeListener, setValue, setValue, setValue, setValue, setValue, toString, valueString
createPropertyChangeSupport, firePropertyChange
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, removePropertyChangeListener
public java.lang.Object getValue()
public void setValue(java.lang.Object newValue)
This method is not intended to be used by API users.
Instead you should trigger commit and flush events by invoking
#triggerCommit
or #triggerFlush
.
newValue
- the Boolean value to be setjava.lang.IllegalArgumentException
- if the newValue is not a Booleanpublic void triggerCommit()
Boolean.TRUE
and ensures that listeners
are notified about a value change to this new value. If necessary
the value is temporarily set to null
. This way it minimizes
the number of PropertyChangeEvents fired by this Trigger.public void triggerFlush()
Boolean.FALSE
and ensures that listeners
are notified about a value change to the new value. If necessary
the value is temporarily set to null
. This way it minimizes
the number of PropertyChangeEvents fired by this Trigger.Copyright © 2002-2010 JGoodies Karsten Lentzsch. All Rights Reserved.