Class EventQueue
java.lang.Object
vaadinx.awt.EventQueue
Emulator for
EventQueue. Three EDT primitives —
invokeLater(Runnable), invokeAndWait(Runnable), isDispatchThread() —
delegate to SwingUtilities and bottom out in
UI.getCurrent() != null (the Vaadin UI-thread proxy);
getMostRecentEventTime() returns System.currentTimeMillis().
The remainder of the JDK surface (instance dispatch machinery,
postEvent, peekEvent, getNextEvent,
dispatchEvent, getCurrentEvent, push / pop,
createSecondaryLoop) is present so migrated code compiles, but
each method WARNs via EHelper.onUnimplemented(String, String, Object...) and returns a safe
default — no AWT EventQueue dispatch thread exists server-side, so the
dispatch contract can't be honoured. This matches R_match_swing_errors / D_never_fail_on_gaps: log the gap,
never crash the host app.
Why ported despite not being Component-shaped. The JDK
EventQueue bottoms out in an AWT EventQueue dispatch thread
that doesn't exist server-side; EventQueue.invokeLater(...)
against the JDK class would silently queue the runnable and never run
it. The porting rule is "port what would silently fail server-side;
leave what works unchanged on the JDK" — EventQueue's static EDT
methods fall on the port side, and once the class is present the rest
of its API surface is added as WARN-stubs to avoid compile errors on
incidental references.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddispatchEvent(AWTEvent event) static AWTEventstatic longApproximation of "time of the most recently dispatched AWT event."static voidinvokeAndWait(Runnable runnable) Posts the runnable to the Vaadin UI thread and blocks the calling thread until it has run.static voidinvokeLater(Runnable runnable) Posts the runnable to the Vaadin UI thread asynchronously.static booleanpeekEvent(int id) protected voidpop()RealEventQueue.pop()throwsEmptyStackExceptionwhen called on a non-pushed queue.voidvoidpush(EventQueue newEventQueue)
-
Constructor Details
-
EventQueue
public EventQueue()
-
-
Method Details
-
isDispatchThread
public static boolean isDispatchThread()- Returns:
truewhen called from a Vaadin UI thread context.- See Also:
-
invokeLater
Posts the runnable to the Vaadin UI thread asynchronously. SeeSwingUtilities.invokeLater(Runnable)for the full dispatch contract, including the background-thread case.- Throws:
IllegalStateException- on a thread with neither a current UI nor anEmulatorContext.
-
invokeAndWait
public static void invokeAndWait(Runnable runnable) throws InterruptedException, InvocationTargetException Posts the runnable to the Vaadin UI thread and blocks the calling thread until it has run. SeeSwingUtilities.invokeAndWait(Runnable)for the full dispatch contract; in particular, calling from the EDT throwsIllegalStateException(D_gap_severity_triage case 2: the loom rescue trigger).- Throws:
IllegalStateException- when called from the EDT, or on a thread with noEmulatorContext.InvocationTargetException- if the runnable throws.InterruptedException- if the wait is interrupted.BrowserSessionClosedError- if the session has no live UI to run the runnable on.
-
getMostRecentEventTime
public static long getMostRecentEventTime()Approximation of "time of the most recently dispatched AWT event." We have no AWT event pump, so we return the current wall-clock time; migrated code that uses this for event-recency comparisons sees a monotonically advancing value, which is the closest faithful behaviour without a real event queue. -
getCurrentEvent
-
postEvent
-
getNextEvent
- Throws:
InterruptedException
-
peekEvent
-
peekEvent
-
dispatchEvent
-
push
-
pop
protected void pop()RealEventQueue.pop()throwsEmptyStackExceptionwhen called on a non-pushed queue. Without an event-pump stack to interrogate, we WARN and return — pop is a paired operation withpush(EventQueue), and push already WARNs. -
createSecondaryLoop
-