|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.sys.TaskObject
ewe.util.EventDispatcher
An EventDispatcher is a utility class that can be used to keep track of a set of ewe.ui.EventListener objects that wish to listen to some kind of event via their onEvent(Event ev) method.
The EventDispatcher can be configured to dispatch events in the current thread or via one or more background threads.
Listeners can also be added weakly, where a reference to them is kept only as long as they are referenced by other objects other than the EventDispatcher. So when they are garbage collected they will automatically be removed from the EventDispatcher.
| Field Summary | |
boolean |
dontUseSeparateThread
If this is set true then events are not delivered via a separate thread, but within the same thread that called dispatch(). |
| Fields inherited from class ewe.sys.TaskObject |
handle, interruptThreadToStop, myThread, napIterations, napTime, shouldStop |
| Constructor Summary | |
EventDispatcher()
|
|
EventDispatcher(int maxParallelDeliveries)
Create an EventDispatcher specifying the number of threads used to deliver events. |
|
| Method Summary | |
void |
addListener(EventListener listener)
Add an event listener. |
void |
addListener(EventListener listener,
boolean addToWeakSet)
Add an event listener. |
void |
close()
Close the EventDispatcher. |
void |
dispatch(Event ev)
Send off the event to the listeners. |
protected void |
doRun()
Override this method if you want to use an mThread to run your Task. |
void |
finalize()
This method (when overriden), will be called when the VM determines that the Object can be garbage collected. |
Vector |
getCurrentListeners(Vector destination)
Get all current listeners. |
boolean |
isEmpty()
Check if there are any listeners in the Dispatcher. |
void |
removeListener(EventListener listener)
Remove an event listener. |
| Methods inherited from class ewe.sys.TaskObject |
checkAbortFail, checkFailure, doStart, doStop, exec, getHandle, nap, run, setNapTime, show, sleep, start, startTask, stopTask, waitOn, waitOnAny, waitOnSuccess, yield, yield |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, toString |
| Field Detail |
public boolean dontUseSeparateThread
| Constructor Detail |
public EventDispatcher()
public EventDispatcher(int maxParallelDeliveries)
maxParallelDeliveries - the maximum number of threads used to deliver evetns simultaneously.| Method Detail |
protected final void doRun()
TaskObject
doRun in class TaskObject
public void addListener(EventListener listener,
boolean addToWeakSet)
listener - The listener to add.addToWeakSet - If this is true the listener will be added to an internal
WeakSet. This means that if no other object is referring to that listener it will
eventually be garbage collected and removed from the list.public void addListener(EventListener listener)
listener - The listener to add.public void removeListener(EventListener listener)
listener - The listener to remove.public Vector getCurrentListeners(Vector destination)
destination - A destination Vector, which will be cleared first, to hold the listeners. This can be null in which case a new one will be created.
public void dispatch(Event ev)
ev - the event to send.public boolean isEmpty()
public void close()
public void finalize()
ObjectThe finalize() method of a Class is only called if it overrides finalize() - the finalize() method java.lang.Object is never called by the Ewe VM.
Note that under a native Ewe VM, the call to finalize() will be synchronized with the Ewe library, but under a Java VM, the finalize() method may be called by a separate Thread that is not synchronized with the Ewe library. To ensure that the execution of the finalize() method is sychronized with the Ewe library your finalize() method should look like this:
protected void finalize()
{
synchronized(ewe.sys.Vm.getSyncObject()){
//
// Put your finalize() code here.
//
}
}
Under Ewe the synchronized keyword is silently ignored.
finalize in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||