|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.sciss.app.EventManager
public class EventManager
A custom event dispatcher which carefully deals with synchronization issues. Assuming, the synchronization requests specified for some methods are fulfilled, this class is completely thread safe.
It is constructed using a second object, the manager's processor which will be invoked whenever new events are available in the event FIFO queue. the processor is then responsible for querying all registered listeners and calling their appropriate event listening methods.
Event dispatching is deferred to the Swing thread execution time since this makes the whole application much more predictable and easily synchronizable.
Nested Class Summary | |
---|---|
static interface |
EventManager.Processor
Callers of the EventManager constructor must provide an object implementing this interface |
Field Summary | |
---|---|
static boolean |
DEBUG_EVENTS
|
protected EventManager.Processor |
eventProcessor
|
Constructor Summary | |
---|---|
protected |
EventManager()
|
|
EventManager(EventManager.Processor eventProcessor)
|
Method Summary | |
---|---|
void |
addListener(Object listener)
Adds a new listener. |
int |
countListeners()
Get the number of listeners |
void |
debugDump()
|
void |
dispatchEvent(BasicEvent e)
Puts a new event in the queue. |
void |
dispose()
|
Object |
getListener(int index)
Gets a listener from the list |
void |
pause()
Pauses event dispatching. |
void |
removeListener(Object listener)
Removes a listener. |
void |
resume()
Resumes event dispatching. |
void |
run()
Called by add/removeListener and dispatchEvent. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean DEBUG_EVENTS
protected EventManager.Processor eventProcessor
Constructor Detail |
---|
public EventManager(EventManager.Processor eventProcessor)
protected EventManager()
Method Detail |
---|
public void dispose()
public void addListener(Object listener)
listener
- the listener to addpublic void removeListener(Object listener)
listener
- the listener to remove. null
is allowed (no op).public void run()
run
in interface Runnable
public Object getListener(int index)
public int countListeners()
public void debugDump()
public void dispatchEvent(BasicEvent e)
e
- the event to add to the queue.
before it's added, the event's incorporate
method will be checked against the most
recent event in the queue.public void pause()
public void resume()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |