foxtrot.pumps
Class ConditionalEventPump

java.lang.Object
  extended by foxtrot.pumps.ConditionalEventPump
All Implemented Interfaces:
EventPump, EventFilterable
Direct Known Subclasses:
SunJDK14ConditionalEventPump

public class ConditionalEventPump
extends Object
implements EventPump, EventFilterable

This implementation of EventPump calls the package protected method java.awt.EventDispatchThread.pumpEvents(Conditional) to pump events while a Task is executed.

Version:
$Revision: 259 $

Nested Class Summary
static class ConditionalEventPump.ThrowableHandler
          Handler for RuntimeExceptions or Errors thrown during dispatching of AWT events.
 
Constructor Summary
ConditionalEventPump()
           
 
Method Summary
protected  boolean canPumpEvent(AWTEvent event)
          Returns whether this event can be pumped from the EventQueue.
 EventFilter getEventFilter()
          Returns the EventFilter
protected  EventQueue getEventQueue()
           
protected  AWTEvent peekEvent(EventQueue queue)
          Peeks the EventQueue for the next event, without removing it.
 void pumpEvents(Task task)
          Pumps AWT events from the standard AWT Event Queue and dispatches the events until the given task is completed; must be called from the Event Dispatch Thread.
 void setEventFilter(EventFilter filter)
          Sets the EventFilter
protected  AWTEvent waitForEvent()
          Waits until an event is available on the EventQueue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConditionalEventPump

public ConditionalEventPump()
Method Detail

setEventFilter

public void setEventFilter(EventFilter filter)
Description copied from interface: EventFilterable
Sets the EventFilter

Specified by:
setEventFilter in interface EventFilterable
See Also:
EventFilterable.getEventFilter()

getEventFilter

public EventFilter getEventFilter()
Description copied from interface: EventFilterable
Returns the EventFilter

Specified by:
getEventFilter in interface EventFilterable
See Also:
EventFilterable.setEventFilter(foxtrot.pumps.EventFilter)

pumpEvents

public void pumpEvents(Task task)
Description copied from interface: EventPump
Pumps AWT events from the standard AWT Event Queue and dispatches the events until the given task is completed; must be called from the Event Dispatch Thread.
No Exceptions (included RuntimeExceptions) or Errors should escape this method: it must return only when the task is completed.

Specified by:
pumpEvents in interface EventPump

canPumpEvent

protected boolean canPumpEvent(AWTEvent event)
Returns whether this event can be pumped from the EventQueue. JDK 1.4 introduced SequencedEvent, which is an event holding a list SequencedEvents that should be dispatched in order. Bug #4531693 was caused by the fact that the first SequencedEvent of a list, when dispatched, might end up calling an event listener that displayed a dialog (or called Foxtrot, that uses the same event pumping mechanism); the new event pump might try to dispatch the SequencedEvent second in the list (while the first wasn't completely dispatched yet), causing the application to hang. Bug #4531693 has been fixed in JDK 1.4.2, and backported to 1.4.1, but seems to be sneaking in again in JDK 5 and JDK 6.


getEventQueue

protected EventQueue getEventQueue()

waitForEvent

protected AWTEvent waitForEvent()
Waits until an event is available on the EventQueue. This method uses the same synchronization mechanisms used by EventQueue to be notified when an event is posted on the EventQueue. Waiting for events is necessary in this case: a Task is posted and we would like to start pumping, but no events have been posted yet (peekEvent(java.awt.EventQueue) returns null).


peekEvent

protected AWTEvent peekEvent(EventQueue queue)
Peeks the EventQueue for the next event, without removing it.



Copyright © 2011 KnowledgePlaza. All Rights Reserved.