Package com.nomagic.ui
Class EventQueueDispatcher
java.lang.Object
com.nomagic.ui.EventQueueDispatcher
AWT event dispatcher which dispatches events in the event queue thread until done condition is encountered.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates aEventQueueDispatcher
and resets done condition. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
customDispatchMouseEvent
(com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher, EventQueue eventQueue, MouseEvent mouseEvent) protected void
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
This is required to avoid hang.void
Sets done condition which causesdispatchEvents
method to exit.void
Forcefully sets timeout condition which causesdispatchEvents
method to exit.protected boolean
The method has to be called from event thread.protected void
reset()
Resets done condition.final void
setDispatchTheseEvents
(Predicate<AWTEvent> dispatchTheseEvents) Set verification which events needs to be dispatched.
-
Constructor Details
-
EventQueueDispatcher
protected EventQueueDispatcher()Creates aEventQueueDispatcher
and resets done condition.
-
-
Method Details
-
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.
-
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.
-
customDispatchMouseEvent
protected boolean customDispatchMouseEvent(com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher, EventQueue eventQueue, MouseEvent mouseEvent) -
setDispatchTheseEvents
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
-