public class SwingTaskMonitor<C extends ApplicationContext> extends AbstractTaskMonitor<C> implements TaskEvent.Source
AsyncTask
about it's RunState changes. It
converts the asynchronous RunState
change notifications to thread-safe TaskEvent
s
which you can register for. The events can i.e. be used for driving a ZProgressBar
.
Note that this monitor does nothing when it is running in a non graphics environment (headless).
Constructor and Description |
---|
SwingTaskMonitor(C ctx) |
SwingTaskMonitor(C ctx,
LogChannel logCh) |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(RunState stateFlag)
|
void |
addTaskListener(TaskEvent.Listener l) |
int |
getTaskListenerCount() |
protected boolean |
isAutoReportError() |
void |
removeTaskListener(TaskEvent.Listener l) |
void |
setAutoReportError(boolean isAutoReportError)
Tells whether a a GUI error dialog should be raised on failure.
|
void |
setBlockingEventNotification(boolean isBlocking) |
void |
setTestMode(boolean isTestMode) |
void |
taskCancelled(RunStateFlag stateFlag)
Called when the async task has discovered that it was cancelled
|
void |
taskChildFinished(RunStateFlag stateFlag)
Indicates that a child task has been finished.
|
void |
taskChildStarted(RunStateFlag stateFlag)
Indicates that a child task has been started.
|
void |
taskChildSucceeded(RunStateFlag stateFlag,
java.lang.Object result)
Indicates that a child task has been succeeded with the given result.
|
void |
taskFailed(RunStateFlag stateFlag,
java.lang.Exception error)
Called when the async task failed
|
void |
taskFinished(RunStateFlag stateFlag)
Called when the async task finished
|
void |
taskProceeded(RunStateFlag stateFlag,
java.lang.Object info,
int step,
int maxSteps,
java.lang.String message)
Is called on task progress.
|
void |
taskStarted(RunStateFlag stateFlag)
Called when the async task started
|
void |
taskSucceeded(RunStateFlag stateFlag,
java.lang.Object result)
Called when the async task succeeded
|
getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getApplicationContext
public SwingTaskMonitor(C ctx)
public SwingTaskMonitor(C ctx, LogChannel logCh)
public void setTestMode(boolean isTestMode)
public void setBlockingEventNotification(boolean isBlocking)
public void taskStarted(RunStateFlag stateFlag)
TaskMonitor
taskStarted
in interface TaskMonitor<C extends ApplicationContext>
public void taskSucceeded(RunStateFlag stateFlag, java.lang.Object result)
TaskMonitor
taskSucceeded
in interface TaskMonitor<C extends ApplicationContext>
public void taskCancelled(RunStateFlag stateFlag)
TaskMonitor
taskCancelled
in interface TaskMonitor<C extends ApplicationContext>
public void taskFailed(RunStateFlag stateFlag, java.lang.Exception error)
TaskMonitor
taskFailed
in interface TaskMonitor<C extends ApplicationContext>
public void taskFinished(RunStateFlag stateFlag)
TaskMonitor
taskFinished
in interface TaskMonitor<C extends ApplicationContext>
public void taskProceeded(RunStateFlag stateFlag, java.lang.Object info, int step, int maxSteps, java.lang.String message)
TaskMonitor
taskProceeded
in interface TaskMonitor<C extends ApplicationContext>
info
- may be anything the running task has produced (i.e. a DBRecord)step
- the number of steps performedmaxSteps
- the maximum number of steps expected (0 if not known)public void taskChildStarted(RunStateFlag stateFlag)
TaskMonitor
RunStateFlag.getCurrentChild()
;taskChildStarted
in interface TaskMonitor<C extends ApplicationContext>
public void taskChildSucceeded(RunStateFlag stateFlag, java.lang.Object result)
TaskMonitor
taskChildSucceeded
in interface TaskMonitor<C extends ApplicationContext>
public void taskChildFinished(RunStateFlag stateFlag)
TaskMonitor
taskChildFinished
in interface TaskMonitor<C extends ApplicationContext>
public boolean accept(RunState stateFlag)
RunState
before actually firing a TaskEvent
.
By default firing only happens, when there are listeners.accept
in interface TaskMonitor<C extends ApplicationContext>
accept
in class AbstractTaskMonitor<C extends ApplicationContext>
protected boolean isAutoReportError()
setAutoReportError(boolean)
public void setAutoReportError(boolean isAutoReportError)
isAutoReportError
- is by default trueisAutoReportError()
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 int getTaskListenerCount()
Copyright © 2014 EsprIT-Systems. All Rights Reserved.