Class MonitorWorker
- All Implemented Interfaces:
Runnable, Future<ExitStatus>, RunnableFuture<ExitStatus>
- Direct Known Subclasses:
AbstractDynamicWorker, ContourWorker, MultiContrastAnalysisFrame.ShowResponseWorker, SmootherWorker
A class to implement a
SwingWorker that can pop up a ProgressMonitor
or IndeterminateProgressMonitor to allow user cancellation.
It is up to the MonitorWorker's doInBackground() method to
check whether cancellation has occured using either the setMonitorProgress(int progress) method,
which throws a CancelledException, or directly with the
SwingWorker.isCancelled() method.-
Nested Class Summary
Nested classes/interfaces inherited from class SwingWorker
SwingWorker.StateValueNested classes/interfaces inherited from interface Future
Future.State -
Field Summary
FieldsModifier and TypeFieldDescriptionAn IndeterminateProgressMonitor which may pop up.final LoggerThe Logger the program that is running this MonitorWorker.A ProgressMonitor which may pop up. -
Method Summary
Modifier and TypeMethodDescriptionvoidTests whether thisMonitorWorkerhas been cancelled.voidcheckCancelled(Integer progress) Tests whether thisMonitorWorkerhas been cancelled, and sets the progress through this operation.voidcheckCancelled(String message) Tests whether thisMonitorWorkerhas been cancelled.voidcheckCancelled(String message, Integer progress) Tests whether thisMonitorWorkerhas been cancelled, and sets the progress through this operation.abstract ExitStatusOverrides thedoInBackground()method.voiddone()Overrides thedone()method.Returns the component from which thisMonitorWorkerwas launched.Returns the error message set for thisMonitorWorker.voidSet the action description for theProgressMonitororIndeterminateProgressMonitor.voidSet the action description for theProgressMonitor.voidsetErrorMessage(String message) Sets the error message for thisMonitorWorker,Methods inherited from class SwingWorker
addPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, removePropertyChangeListener, runMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Future
exceptionNow, resultNow, state
-
Field Details
-
logger
The Logger the program that is running this MonitorWorker. -
monitor
A ProgressMonitor which may pop up. -
indeterminateMonitor
An IndeterminateProgressMonitor which may pop up.
-
-
Method Details
-
getComponent
Returns the component from which thisMonitorWorkerwas launched.- Returns:
- the component (if non-null) from which this
MonitorWorkerwas launched.
-
setAction
Set the action description for theProgressMonitor.- Parameters:
descr- the action description.min- the minimum for theProgressMonitor.max- the maximum for theProgressMonitor.
-
setAction
Set the action description for theProgressMonitororIndeterminateProgressMonitor.- Parameters:
descr- the action description.
-
checkCancelled
Tests whether thisMonitorWorkerhas been cancelled.- Throws:
CancelledException- if the operation has been cancelled.
-
checkCancelled
Tests whether thisMonitorWorkerhas been cancelled.- Parameters:
message- a message to put to the IndeterminateProgressMonitor.- Throws:
CancelledException- if the operation has been cancelled.
-
checkCancelled
Tests whether thisMonitorWorkerhas been cancelled, and sets the progress through this operation.- Parameters:
progress- the progress of the ProgressMonitor.- Throws:
CancelledException- if the operation has been cancelled.
-
checkCancelled
Tests whether thisMonitorWorkerhas been cancelled, and sets the progress through this operation.- Parameters:
message- a message to put to the IndeterminateProgressMonitor.progress- the progress of the ProgressMonitor.- Throws:
CancelledException- if the operation has been cancelled.
-
doInBackground
Overrides thedoInBackground()method.- Returns:
- the
ExitStatusindicating whether the processing was successful, and if not why not.
-
done
public void done() -
setErrorMessage
Sets the error message for thisMonitorWorker,- Parameters:
message- the error message.
-
getErrorMessage
Returns the error message set for thisMonitorWorker.- Returns:
- the error message, or
nullif no error message has been set.
-