public abstract class AbstractSwingTask<C extends ApplicationContext> extends AbstractAsyncTask<C> implements Renderable, ErrorHandlerSupport, TaskEvent.Source
AsyncTask
supposed to be run in a Swing GUIs environment.
It runs with a SwingTaskMonitor
that translates direct task state notifications into TaskEvent
s
which you can register for. These events can be used to drive GUI components such as a ProgressBar.
Furthermore you may override any of the doneTaskXXX() methods for performing
GUI-synchronous actions driven by the asynchronous task.
Note that the running task is registered within the context's ActiveTasksListModel
which
allows for observing the task's RunStateFlag
in an ActiveTasksList
.childTaskRef, isTestMode, monitorController, resultRef, stateFlag
Constructor and Description |
---|
AbstractSwingTask(C ctx) |
AbstractSwingTask(C ctx,
LogChannel logCh) |
AbstractSwingTask(C ctx,
LogChannel logCh,
java.lang.String taskName,
TaskType taskType) |
AbstractSwingTask(C ctx,
java.lang.String taskName) |
AbstractSwingTask(C ctx,
java.lang.String taskName,
TaskType taskType) |
AbstractSwingTask(C ctx,
TaskType taskType) |
Modifier and Type | Method and Description |
---|---|
void |
addMonitor(TaskMonitor newMonitor)
Adds a
TaskMonitor which is notified about RunStateFlag changes |
void |
addTaskListener(TaskEvent.Listener l) |
void |
awaitEventsDone()
Provides a means to synchronize on the state that all
TaskEvent s of this task have
been actually processed by the event dispatcher Thread. |
protected void |
doneChildFinished(TaskEvent e) |
protected void |
doneChildStarted(TaskEvent e) |
protected void |
doneTaskCancelled(TaskEvent e) |
protected void |
doneTaskFailed(TaskEvent e) |
protected void |
doneTaskFinished(TaskEvent e) |
protected void |
doneTaskProceeded(TaskEvent e) |
protected void |
doneTaskStarted(TaskEvent e) |
protected void |
doneTaskStateChanged(TaskEvent e) |
protected void |
doneTaskSucceeded(TaskEvent e) |
TaskCancelAction |
getActionCancel() |
java.awt.Color |
getRenderColor() |
javax.swing.Icon |
getRenderIcon() |
java.lang.String |
getRenderText() |
SwingTaskMonitor |
getSwingTaskMonitor() |
protected boolean |
isRegisterInTaskList() |
void |
removeTaskListener(TaskEvent.Listener l) |
void |
showError(java.lang.Exception e) |
void |
showError(java.lang.String message,
java.lang.Exception e) |
void |
showError(java.lang.String message,
java.lang.String details,
java.lang.Exception e) |
void |
showInfo(java.lang.String message) |
void |
showInfo(java.lang.String message,
java.lang.String details) |
void |
showWarning(java.lang.String message) |
void |
showWarning(java.lang.String message,
java.lang.String details) |
awaitFinished, awaitFinished, awaitStarted, cancel, createTaskId, deregisterTask, doOnFinish, doOnStart, doOnSuccess, executeAsync, executeChildTask, executeChildTask, getCurrentFuture, getMaxChildTasks, getPriority, getProcessingDuration, getStartTime, getStopWatch, handleFinish, handleStart, handleSuccess, isRegisterForCancel, isRunning, notifyProceeded, registerTask, releaseStart, run, setCurrentFuture, setMaxChildTasks, setPriority, setRegisterForCancel, setReleaseTimeout, submit, submit, submitInternal, toString, wasSucceeded
checkCancelled, checkForErrorAndRethrow, clearMonitors, createRunStateFlag, doOnCancel, doOnFailure, execute, executeSubTask, getError, getMaxProgressSteps, getMonitorCount, getMonitors, getName, getProgressStepCount, getResult, getRunStateFlag, getTaskId, getType, handleCancellation, handleFailure, hasError, hasMonitor, isCancellable, registerTaskStateChange, removeMonitor, resetProgress, setCancellable, setLogLevel, setMaxProgressSteps, setMonitor, setName, setName, setResult, setRunStateFlag, setTaskId, setType, shouldFireMonitor, sleepChecked, wasCancelled
getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
checkCancelled, checkForErrorAndRethrow, executeSubTask, getName, getResult, getRunStateFlag, getTaskId, getType, handleCancellation, handleFailure, isCancellable, setCancellable, setName, setResult, setRunStateFlag, sleepChecked
getApplicationContext
execute
clearMonitors, getMonitorCount, getMonitors, hasMonitor, removeMonitor
getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
wasCancelled
getTaskId
toDumpString, toDumpString, toString
public AbstractSwingTask(C ctx)
public AbstractSwingTask(C ctx, java.lang.String taskName)
public AbstractSwingTask(C ctx, LogChannel logCh)
public AbstractSwingTask(C ctx, LogChannel logCh, java.lang.String taskName, TaskType taskType)
public void awaitEventsDone() throws java.lang.InterruptedException
TaskEvent
s of this task have
been actually processed by the event dispatcher Thread.java.lang.InterruptedException
public final void addTaskListener(TaskEvent.Listener l)
addTaskListener
in interface TaskEvent.Source
public final void removeTaskListener(TaskEvent.Listener l)
removeTaskListener
in interface TaskEvent.Source
public final TaskCancelAction getActionCancel()
public final SwingTaskMonitor getSwingTaskMonitor()
public final void addMonitor(TaskMonitor newMonitor)
TaskMonitorSupport
TaskMonitor
which is notified about RunStateFlag
changesaddMonitor
in interface TaskMonitorSupport
addMonitor
in class AbstractAsyncExecutable<C extends ApplicationContext>
protected void doneTaskStateChanged(TaskEvent e)
protected void doneTaskStarted(TaskEvent e)
protected void doneTaskProceeded(TaskEvent e)
protected void doneTaskCancelled(TaskEvent e)
protected void doneTaskSucceeded(TaskEvent e)
protected void doneTaskFailed(TaskEvent e)
protected void doneTaskFinished(TaskEvent e)
protected void doneChildStarted(TaskEvent e)
protected void doneChildFinished(TaskEvent e)
public java.awt.Color getRenderColor()
getRenderColor
in interface Renderable
public javax.swing.Icon getRenderIcon()
getRenderIcon
in interface Renderable
public java.lang.String getRenderText()
getRenderText
in interface Renderable
public final void showError(java.lang.Exception e)
showError
in interface ErrorHandlerSupport
public final void showError(java.lang.String message, java.lang.Exception e)
showError
in interface ErrorHandlerSupport
public final void showError(java.lang.String message, java.lang.String details, java.lang.Exception e)
showError
in interface ErrorHandlerSupport
public final void showInfo(java.lang.String message, java.lang.String details)
showInfo
in interface ErrorHandlerSupport
public final void showInfo(java.lang.String message)
showInfo
in interface ErrorHandlerSupport
public final void showWarning(java.lang.String message, java.lang.String details)
showWarning
in interface ErrorHandlerSupport
public final void showWarning(java.lang.String message)
showWarning
in interface ErrorHandlerSupport
protected boolean isRegisterInTaskList()
Copyright © 2014 EsprIT-Systems. All Rights Reserved.