Package com.nomagic.task
Class Task
java.lang.Object
com.nomagic.task.SwingWorker<Object>
com.nomagic.task.Task
Task for execution of some code on a separate thread.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class com.nomagic.task.SwingWorker
doFinishedReached, mName, THREAD_GROUP, THREAD_GROUP_NAME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
Method invoked on task's thread just beforeSwingWorker.finished()
is called.final Object
Compute the value to be returned by theget
method.static ProgressStatus
Returns currently activeTask
progress statusfinal void
abstract void
execute()
static void
executeTaskOnSameThread
(Task task) Executes task on same thread.getName()
getState()
void
Sets state to CANCELED.final void
Deprecated.See MDUML-57069 for deprecationstatic boolean
boolean
boolean
boolean
boolean
boolean
boolean
isReady()
boolean
void
void
setCancelable
(boolean cancelable) void
setDoFinishedExecuter
(com.nomagic.task.Task.DoFinishedExecuter doFinishedExecuter) void
void
setFinished
(boolean finished) void
setInterruptThreadOnCancel
(boolean interruptThreadOnCancel) void
void
void
setStatus
(ProgressStatus status) void
stopTask()
Interrupt task and wait while it is workingMethods inherited from class com.nomagic.task.SwingWorker
finished, get, getThread, getValue, isStopped, newFixedThreadExecutor, newSerialExecutor, newSerialExecutor, newSerialExecutorWithPriority, resume, setPriority, start, startOn, suspend, threadInterrupt, threadJoin, threadStop
-
Field Details
-
STATE_CHANGED_PROPERTY
- See Also:
-
CANCELED
- See Also:
-
FINISHED
- See Also:
-
COMPLETED
- See Also:
-
WORKING
- See Also:
-
READY
- See Also:
-
EXCEPTION
- See Also:
-
-
Constructor Details
-
Task
-
-
Method Details
-
executeTaskOnSameThread
Executes task on same thread. Updates progress status from same thread.- Throws:
Exception
-
setInterruptThreadOnCancel
public void setInterruptThreadOnCancel(boolean interruptThreadOnCancel) -
currentTaskStatus
Returns currently activeTask
progress status- Returns:
- currently active
Task
progress status ornull
if current thread is not executing aTask
-
setName
-
setException
-
getException
-
getName
-
getStatus
-
setStatus
-
isCompleted
public boolean isCompleted() -
isWorking
public boolean isWorking() -
isReady
public boolean isReady() -
isException
public boolean isException() -
isCanceled
public boolean isCanceled() -
setState
-
getState
-
construct
Description copied from class:com.nomagic.task.SwingWorker
Compute the value to be returned by theget
method.- Specified by:
construct
in classcom.nomagic.task.SwingWorker<Object>
- Returns:
- the result value
-
execute
- Throws:
Exception
-
interruptAndStop
Deprecated.See MDUML-57069 for deprecationDescription copied from class:com.nomagic.task.SwingWorker
A new method that interrupts ant stops the worker thread. Call this method to force the worker to stop what it's doing.- Overrides:
interruptAndStop
in classcom.nomagic.task.SwingWorker<Object>
-
doFinished
public final void doFinished()- Overrides:
doFinished
in classcom.nomagic.task.SwingWorker<Object>
-
beforeFinished
protected void beforeFinished()Method invoked on task's thread just beforeSwingWorker.finished()
is called. -
isFinished
public boolean isFinished()- Returns:
- true if task is completely finished (execute and finished methods are executed)
-
isCancelable
public boolean isCancelable()- Returns:
- Returns the cancelable.
-
setCancelable
public void setCancelable(boolean cancelable) - Parameters:
cancelable
- The cancelable to set.
-
interrupt
public void interrupt()Sets state to CANCELED. Notifies all threads that are waiting on this object monitor.- Overrides:
interrupt
in classcom.nomagic.task.SwingWorker<Object>
-
isActiveTasks
public static boolean isActiveTasks() -
addPropertyChangedListener
-
removePropertyChangedListener
-
setFinished
public void setFinished(boolean finished) -
setDoFinishedExecuter
public void setDoFinishedExecuter(com.nomagic.task.Task.DoFinishedExecuter doFinishedExecuter) -
stopTask
public void stopTask()Interrupt task and wait while it is working
-