|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.sciss.common.ProcessingThread
public class ProcessingThread
A subclass of Thread that is capable of dealing with synchronization issues. It will pause all event dispatching related to specified doors which will be locked during processing. It includes helper methods for updating a progress bar and displaying messages and exceptions.
Nested Class Summary | |
---|---|
static class |
ProcessingThread.CancelledException
|
static interface |
ProcessingThread.Client
|
static class |
ProcessingThread.Event
|
static interface |
ProcessingThread.Listener
|
Field Summary | |
---|---|
protected EventManager |
elm
|
protected java.lang.Exception |
exception
|
protected java.lang.String |
name
|
protected float |
progress
|
protected boolean |
progressInvoked
|
protected int |
returnCode
|
protected java.lang.Object |
sync
|
Constructor Summary | |
---|---|
ProcessingThread(ProcessingThread.Client client,
ProgressComponent pc,
java.lang.String procName)
Creates a new ProcessingThread. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
|
void |
addListener(ProcessingThread.Listener l)
Registers a listener to be notified when the process starts and terminates. |
void |
cancel(boolean doSync)
Forwards the cancel request to the client. |
static ProcessingThread |
currentThread()
|
void |
dispose()
|
static void |
flushProgression()
|
java.lang.Object |
getClientArg(java.lang.Object key)
|
java.util.Map |
getClientMap()
|
java.awt.Component |
getComponent()
|
java.lang.Exception |
getException()
Queries the last exception thrown in the run method. |
java.lang.String |
getName()
|
int |
getReturnCode()
Returns the cient's return code. |
boolean |
isRunning()
|
void |
processEvent(BasicEvent e)
Processes the next event in the queue. |
void |
putClientArg(java.lang.Object key,
java.lang.Object value)
|
void |
removeListener(ProcessingThread.Listener l)
Removes a listener from being notified when the process starts and terminates. |
void |
resetProgression()
|
void |
run()
The is the main method of a thread; it invokes the client's processRun method. |
void |
setException(java.lang.Exception e)
If the client is capable of catching an exception in its execution block, it should pass it to the pt calling this method. |
static void |
setNextProgStop(float p)
|
void |
setProgression(float p)
Called by the client to update the progress bar. |
static boolean |
shouldCancel()
|
void |
start()
Starts processing. |
void |
sync()
Puts the calling thread in wait mode until the processing is finished. |
void |
sync(int timeout)
|
static void |
update(float progress)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.lang.String name
protected volatile float progress
protected volatile boolean progressInvoked
protected volatile java.lang.Exception exception
protected EventManager elm
protected int returnCode
protected final java.lang.Object sync
Constructor Detail |
---|
public ProcessingThread(ProcessingThread.Client client, ProgressComponent pc, java.lang.String procName)
client
- Interface whose method runProcessing() is called
inside the new thread when it's started.pc
- Component responsible for displaying progress bar etc.procName
- Name for the thread and the process monitoringMethod Detail |
---|
public void putClientArg(java.lang.Object key, java.lang.Object value)
public java.lang.Object getClientArg(java.lang.Object key)
public java.util.Map getClientMap()
public java.lang.String getName()
public void start()
public void sync()
addListener( ProcessingThread.Listener )
public void sync(int timeout)
public void cancel(boolean doSync)
doSync
- if true
, wait for the client to
abort, otherwise return immediatelypublic static ProcessingThread currentThread()
public static boolean shouldCancel()
public static void update(float progress) throws ProcessingThread.CancelledException
ProcessingThread.CancelledException
public boolean isRunning()
public int getReturnCode()
Client.DONE
etc.)
or -1
if the client had not been startedpublic void addListener(ProcessingThread.Listener l)
l
- the listener to registerpublic void removeListener(ProcessingThread.Listener l)
l
- the listener to unregisterpublic void dispose()
dispose
in interface Disposable
public void run()
run
in interface java.lang.Runnable
public void setException(java.lang.Exception e)
e
- exception which was thrown in the client's
run method. when the thread stops it
will display this error to the user.public java.lang.Exception getException()
public static void setNextProgStop(float p)
public static void flushProgression()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
public void processEvent(BasicEvent e)
EventManager.Processor
processEvent
in interface EventManager.Processor
public java.awt.Component getComponent()
public void setProgression(float p)
p
- new progression between zero and onepublic void resetProgression()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |