java.lang.Object
AbstractValueModel
com.jgoodies.binding.extras.DelayedValueModel
- public final class DelayedValueModel
- extends AbstractValueModel
A ValueModel that deferres value changes for a specified delay.
Useful to coalesce frequent changes. For example if a heavy computation
shall be performed only for a "stable" selection after a series of
quick selection changes.
Wraps a given subject ValueModel and returns the subject value or
the value to be set as this model's value. Observes subject value changes
and forwards them to listeners of this model. If a value is set to this
model, a Swing Timer is used to delay the value commit to the subject.
A previously started timer - if any - will be stopped before.
- Version:
- $Revision: 1.2 $
|
Constructor Summary |
DelayedValueModel(ValueModel subject,
int delay)
Constructs a DelayedValueModel for the given subject ValueModel
and the specified Timer delay in milliseconds. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
subject
private final ValueModel subject
- Refers to the underlying subject ValueModel.
timer
private final javax.swing.Timer timer
- The Timer used to perform the delayed commit.
pendingValue
private java.lang.Object pendingValue
- Holds the most recent pending value. It is updated
evertime
#setValue is invoked.
DelayedValueModel
public DelayedValueModel(ValueModel subject,
int delay)
- Constructs a DelayedValueModel for the given subject ValueModel
and the specified Timer delay in milliseconds.
getValue
public java.lang.Object getValue()
- Returns the subject's value or in case of a pending commit,
the pending new value.
setValue
public void setValue(java.lang.Object newValue)
- Sets the given new value after this model's delay.
Does nothing if the new value and the latest pending value are the same.
hasPendingChange
private boolean hasPendingChange()