Package com.nomagic.ui
Class EventQueueDispatcher
- java.lang.Object
-
- com.nomagic.ui.EventQueueDispatcher
-
@OpenApi public abstract class EventQueueDispatcher extends java.lang.Object
AWT event dispatcher which dispatches events in the event queue thread until done condition is encountered.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.reflect.Method
DISPATCH_EVENT_METHOD
private static boolean
dispatchAllEvents
private int
dispatchReentrancyDepth
private java.util.function.Predicate<java.awt.AWTEvent>
dispatchTheseEvents
private boolean
doneCondition
private java.util.BitSet
timeoutCondition
-
Constructor Summary
Constructors Modifier Constructor Description protected
EventQueueDispatcher()
Creates aEventQueueDispatcher
and resets done condition.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
customDispatchMouseEvent(com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher, java.awt.EventQueue eventQueue, java.awt.event.MouseEvent mouseEvent)
protected void
dispatchEvents()
Dispatches AWT events until done condition is encountered.protected boolean
dispatchEvents(int timeout)
Dispatches AWT events until done condition is encountered or timeout is reached whatever happens first.static void
disposeSequencedEvent()
This is required to avoid hang.void
doneDispatching()
Sets done condition which causesdispatchEvents
method to exit.void
forceTimeout()
Forcefully sets timeout condition which causesdispatchEvents
method to exit.private static com.nomagic.ui.EventQueueDispatcher.Dispatcher
getDispatcher(java.awt.EventQueue eventQueue)
java.util.function.Predicate<java.awt.AWTEvent>
getDispatchTheseEvents()
private static java.awt.EventQueue
getEventQueue()
protected boolean
isDoneDispatching()
The method has to be called from event thread.private boolean
pumpEvent(com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher, java.awt.EventQueue eventQueue)
private void
pumpEvents(java.awt.EventQueue eventQueue, com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher)
protected void
reset()
Resets done condition.(package private) static void
setDispatchAllEvents(boolean dispatchAllEvents)
void
setDispatchTheseEvents(java.util.function.Predicate<java.awt.AWTEvent> dispatchTheseEvents)
Set verification which events needs to be dispatched.
-
-
-
Field Detail
-
DISPATCH_EVENT_METHOD
private static final java.lang.reflect.Method DISPATCH_EVENT_METHOD
-
doneCondition
private boolean doneCondition
-
timeoutCondition
private final java.util.BitSet timeoutCondition
-
dispatchReentrancyDepth
private int dispatchReentrancyDepth
-
dispatchAllEvents
private static boolean dispatchAllEvents
-
dispatchTheseEvents
private java.util.function.Predicate<java.awt.AWTEvent> dispatchTheseEvents
-
-
Method Detail
-
reset
protected void reset()
Resets done condition.The method has to be called from event thread.
-
dispatchEvents
protected void dispatchEvents()
Dispatches AWT events until done condition is encountered.The method has to be called from event thread.
-
dispatchEvents
protected boolean dispatchEvents(int timeout)
Dispatches AWT events until done condition is encountered or timeout is reached whatever happens first.The method has to be called from event thread.
- Parameters:
timeout
- the timeout or -1 if there is no timeout- Returns:
true
if dispatching has stopped because of done condition,false
if dispatching has stopped because timeout was reached.
-
getDispatcher
private static com.nomagic.ui.EventQueueDispatcher.Dispatcher getDispatcher(java.awt.EventQueue eventQueue)
-
disposeSequencedEvent
public static void disposeSequencedEvent()
This is required to avoid hang.
-
doneDispatching
public void doneDispatching()
Sets done condition which causesdispatchEvents
method to exit.
-
forceTimeout
public void forceTimeout()
Forcefully sets timeout condition which causesdispatchEvents
method to exit.
-
isDoneDispatching
protected boolean isDoneDispatching()
The method has to be called from event thread.
- Returns:
true
if done condition was encountered.
-
getEventQueue
private static java.awt.EventQueue getEventQueue()
-
pumpEvents
private void pumpEvents(java.awt.EventQueue eventQueue, com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher)
-
pumpEvent
private boolean pumpEvent(com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher, java.awt.EventQueue eventQueue)
-
customDispatchMouseEvent
protected boolean customDispatchMouseEvent(com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher, java.awt.EventQueue eventQueue, java.awt.event.MouseEvent mouseEvent)
-
setDispatchTheseEvents
public final void setDispatchTheseEvents(java.util.function.Predicate<java.awt.AWTEvent> dispatchTheseEvents)
Set verification which events needs to be dispatched. For normal UI only invocation events are dispatched.- Parameters:
dispatchTheseEvents
- predicate to check if event needs to be dispatched
-
getDispatchTheseEvents
public final java.util.function.Predicate<java.awt.AWTEvent> getDispatchTheseEvents()
-
setDispatchAllEvents
static void setDispatchAllEvents(boolean dispatchAllEvents)
-
-