Package com.nomagic.ui
Class EventQueueDispatcher
- java.lang.Object
-
- com.nomagic.ui.EventQueueDispatcher
-
@OpenApi public abstract class EventQueueDispatcher extends java.lang.ObjectAWT 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.MethodDISPATCH_EVENT_METHODprivate static booleandispatchAllEventsprivate intdispatchReentrancyDepthprivate java.util.function.Predicate<java.awt.AWTEvent>dispatchTheseEventsprivate booleandoneConditionprivate java.util.BitSettimeoutCondition
-
Constructor Summary
Constructors Modifier Constructor Description protectedEventQueueDispatcher()Creates aEventQueueDispatcherand resets done condition.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancustomDispatchMouseEvent(com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher, java.awt.EventQueue eventQueue, java.awt.event.MouseEvent mouseEvent)protected voiddispatchEvents()Dispatches AWT events until done condition is encountered.protected booleandispatchEvents(int timeout)Dispatches AWT events until done condition is encountered or timeout is reached whatever happens first.static voiddisposeSequencedEvent()This is required to avoid hang.voiddoneDispatching()Sets done condition which causesdispatchEventsmethod to exit.voidforceTimeout()Forcefully sets timeout condition which causesdispatchEventsmethod to exit.private static com.nomagic.ui.EventQueueDispatcher.DispatchergetDispatcher(java.awt.EventQueue eventQueue)java.util.function.Predicate<java.awt.AWTEvent>getDispatchTheseEvents()private static java.awt.EventQueuegetEventQueue()protected booleanisDoneDispatching()The method has to be called from event thread.private booleanpumpEvent(com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher, java.awt.EventQueue eventQueue)private voidpumpEvents(java.awt.EventQueue eventQueue, com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher)protected voidreset()Resets done condition.(package private) static voidsetDispatchAllEvents(boolean dispatchAllEvents)voidsetDispatchTheseEvents(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:
trueif dispatching has stopped because of done condition,falseif 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 causesdispatchEventsmethod to exit.
-
forceTimeout
public void forceTimeout()
Forcefully sets timeout condition which causesdispatchEventsmethod to exit.
-
isDoneDispatching
protected boolean isDoneDispatching()
The method has to be called from event thread.
- Returns:
trueif 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)
-
-