| java.lang.Object com.jgoodies.binding.beans.DelayedPropertyChangeHandler
DelayedPropertyChangeHandler | abstract public class DelayedPropertyChangeHandler implements PropertyChangeListener(Code) | | A PropertyChangeListener that is intended to handle property changes
after a specified delay. Useful to defer changes until a stable state
is reached. For example if you look up a persistent object for a selection
in a list. You don't want to find and transport objects that the user
selects temporarily; you want to get only a stable selection.
Or if you want to validate on every key typed, you may delay the
validation until no key has been typed for a given time.
If this handler is notified about a property change it stores
the PropertyChangeEvent it has received in #propertyChange ,
and starts a Swing Timer that will call #delayedPropertyChange
after a delay. In coalescing mode a previously started timer - if any -
will be stopped before. In other words, the timer is restarted.
TODO: Write about the recommended delay time - above the double-click time
and somewhere below a second, e.g. 100ms to 200ms.
TODO: Summarize the differences between the DelayedReadValueModel, the
DelayedWriteValueModel, and this DelayedPropertyChangeHandler.
author: Karsten Lentzsch version: $Revision: 1.10 $ See Also: com.jgoodies.binding.value.DelayedReadValueModel See Also: com.jgoodies.binding.extras.DelayedWriteValueModel See Also: javax.swing.Timer since: 1.1 |
Field Summary | |
final public static int | DEFAULT_DELAY The delay in milliseconds used as default in the no-arg constructor. |
Constructor Summary | |
public | DelayedPropertyChangeHandler() Constructs a DelayedPropertyChangeHandler with a default delay. | public | DelayedPropertyChangeHandler(int delay) Constructs a DelayedPropertyChangeHandler with the specified Timer delay
and the coalesce disabled. | public | DelayedPropertyChangeHandler(int delay, boolean coalesce) Constructs a DelayedPropertyChangeHandler with the specified Timer delay
and the given coalesce mode. |
Method Summary | |
abstract public void | delayedPropertyChange(PropertyChangeEvent evt) This method gets called after this handler's delay
if a bound property has changed. | public int | getDelay() Returns the delay, in milliseconds, that is used to defer value change
notifications. | public boolean | isCoalesce() Returns if this model coalesces all pending changes or not. | final public void | propertyChange(PropertyChangeEvent evt) This handler has been notified about a change in a bound property.
Stores the given event, then starts a timer that'll call
#delayedPropertyChange after this handler's delay.
If coalescing is enabled, a previously started timer - if any -
if stopped before. | public void | setCoalesce(boolean b) Sets if this model shall coalesce all pending changes or not. | public void | setDelay(int delay) Sets the delay, in milliseconds, that is used to defer value change
notifications. | final public void | stop() Stops a running timer - if any. |
DEFAULT_DELAY | final public static int DEFAULT_DELAY(Code) | | The delay in milliseconds used as default in the no-arg constructor.
|
DelayedPropertyChangeHandler | public DelayedPropertyChangeHandler()(Code) | | Constructs a DelayedPropertyChangeHandler with a default delay.
|
DelayedPropertyChangeHandler | public DelayedPropertyChangeHandler(int delay)(Code) | | Constructs a DelayedPropertyChangeHandler with the specified Timer delay
and the coalesce disabled.
Parameters: delay - the milliseconds to wait before the delayed property changewill be performed throws: IllegalArgumentException - if the delay is negative |
DelayedPropertyChangeHandler | public DelayedPropertyChangeHandler(int delay, boolean coalesce)(Code) | | Constructs a DelayedPropertyChangeHandler with the specified Timer delay
and the given coalesce mode.
Parameters: delay - the milliseconds to wait before the delayed property changewill be performed Parameters: coalesce - true to coalesce all pending changes,false to fire changes with the delay when an updatehas been received throws: IllegalArgumentException - if the delay is negative See Also: DelayedPropertyChangeHandler.setCoalesce(boolean) |
delayedPropertyChange | abstract public void delayedPropertyChange(PropertyChangeEvent evt)(Code) | | This method gets called after this handler's delay
if a bound property has changed. The event is the
pending event as stored in #propertyChange .
This method is invoked only if this handler hasn't received
subsequent property changes. In other words, it is called only
if the observed bound property is stable during the delay time.
Parameters: evt - the PropertyChangeEvent describing the event sourceand the property that has changed |
getDelay | public int getDelay()(Code) | | Returns the delay, in milliseconds, that is used to defer value change
notifications.
the delay, in milliseconds, that is used to defervalue change notifications See Also: DelayedPropertyChangeHandler.setDelay since: 1.5 |
isCoalesce | public boolean isCoalesce()(Code) | | Returns if this model coalesces all pending changes or not.
true if all pending changes will be coalesced,false if pending changes are fired with a delaywhen an update has been received. See Also: DelayedPropertyChangeHandler.setCoalesce(boolean) |
propertyChange | final public void propertyChange(PropertyChangeEvent evt)(Code) | | This handler has been notified about a change in a bound property.
Stores the given event, then starts a timer that'll call
#delayedPropertyChange after this handler's delay.
If coalescing is enabled, a previously started timer - if any -
if stopped before. In other words, the timer is restarted.
Parameters: evt - the PropertyChangeEvent describing the event sourceand the property that has changed |
setCoalesce | public void setCoalesce(boolean b)(Code) | | Sets if this model shall coalesce all pending changes or not.
In this case, a change event will be fired first,
if no updates have been received for this model's delay.
If coalesce is false , a change event will be fired
with this model's delay when an update has been received.
The default value is false .
Note that this value is not the #coalesce value
of this model's internal Swing timer.
Parameters: b - true to coalesce,false to fire separate changes |
setDelay | public void setDelay(int delay)(Code) | | Sets the delay, in milliseconds, that is used to defer value change
notifications.
Parameters: delay - the delay, in milliseconds, that is used to defervalue change notifications See Also: DelayedPropertyChangeHandler.getDelay since: 1.5 |
stop | final public void stop()(Code) | | Stops a running timer - if any. The last pending event
won't be delivered to #delayedPropertyChange .
since: 1.2 |
|
|