Class Timer
- All Implemented Interfaces:
Serializable
Timer. Emulator-only per D_timer_swingworker — no
surrogate (Timer isn't a Component, no peer to back).
Backed by the shared per-session UiScheduler (a
single-thread ScheduledExecutorService on a platform daemon
thread). The scheduler thread does no user work — on fire it hops back to
the session's live UI thread via EHelper.onSessionLiveUI(VaadinSession, Runnable),
which resolves the current UI and enters EHelper.callSwing(Runnable)
so the ActionEvent is delivered inside the R_callswing_envelope virtual-thread
envelope. User listeners run under the session lock and can park on
blocking dialogs.
The owning VaadinSession is captured at construction — not
the UI. Session scope is what lets a running Timer survive an F5
@PreserveOnRefresh teleport (the old UI closes, a fresh one takes
over): the scheduler outlives the refresh and each fire re-resolves the
now-current UI. Constructing a Timer with no current session throws
IllegalStateException. See UiScopedFeaturesF5Test.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidintgetDelay()int<T extends EventListener>
T[]getListeners(Class<T> listenerType) static booleanbooleanbooleanbooleanvoidvoidrestart()voidsetActionCommand(String actionCommand) voidsetCoalesce(boolean coalesce) voidsetDelay(int delay) voidsetInitialDelay(int initialDelay) static voidsetLogTimers(boolean flag) voidsetRepeats(boolean repeats) voidstart()Starts the Timer.voidstop()Stops the Timer.
-
Field Details
-
listenerList
-
-
Constructor Details
-
Timer
- Throws:
IllegalArgumentException- ifdelay < 0(JDK-faithful).IllegalStateException- if no current Vaadin session — Timers are session-bound.
-
-
Method Details
-
addActionListener
-
removeActionListener
-
getActionListeners
-
getListeners
-
getDelay
public int getDelay() -
setDelay
public void setDelay(int delay) - Throws:
IllegalArgumentException- ifdelay < 0(JDK-faithful).
-
getInitialDelay
public int getInitialDelay() -
setInitialDelay
public void setInitialDelay(int initialDelay) - Throws:
IllegalArgumentException- ifinitialDelay < 0(JDK-faithful).
-
isRepeats
public boolean isRepeats() -
setRepeats
public void setRepeats(boolean repeats) -
isCoalesce
public boolean isCoalesce() -
setCoalesce
public void setCoalesce(boolean coalesce) -
getActionCommand
-
setActionCommand
-
setLogTimers
public static void setLogTimers(boolean flag) -
getLogTimers
public static boolean getLogTimers() -
isRunning
public boolean isRunning() -
start
public void start()Starts the Timer. Safe to call when already running — JDK-faithful no-op.A started Timer holds the app open (
AutoShutdown), so disposing the last window while it runs leaves the session alive — the status-bar-clock paper cut, reproduced (D_auto_shutdown). -
stop
public void stop()Stops the Timer. Pending fires already queued on the EDT are dropped on delivery (the EDT-side fire body re-checksrunning); fires that haven't yet reached the EDT are cancelled viafuture.cancel(false). -
restart
public void restart()
-