Package org.csstudio.ui.util
Class DelayedNotificator
java.lang.Object
org.csstudio.ui.util.DelayedNotificator
A utility class to throttle actions caused by user interaction.
In some cases, user interaction may trigger actions that require some time to complete. Multiple interactions will need to cancel the previous submitted task in favor of the latest one. This class provides an easy implementation for that case.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDelayedNotificator
(long delay, TimeUnit unit) Creates a new notificator, with the delay given. -
Method Summary
Modifier and TypeMethodDescriptionvoid
delayedExec
(Widget widget, Runnable command) Submits a command for the given widget.
-
Field Details
-
exec
-
-
Constructor Details
-
DelayedNotificator
Creates a new notificator, with the delay given.Only one task per notificator can be queue at a time.
- Parameters:
delay
- the delayunit
- the unit of the delay
-
-
Method Details
-
delayedExec
Submits a command for the given widget. After the timeout, the command is executed on the display thread of the widget. If another command is submitted before the timeout, than the previous action is cancelled.- Parameters:
widget
- the display thread of this widget will be usedcommand
- the command to execute
-