Package com.xinapse.util
Class MonitorWorker
- All Implemented Interfaces:
Runnable,Future<ExitStatus>,RunnableFuture<ExitStatus>
- Direct Known Subclasses:
AbstractDynamicWorker,ContourWorker,SmootherWorker
A class to implement a
SwingWorker that can pop up a ProgressMonitor
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 javax.swing.SwingWorker
SwingWorker.StateValue -
Field Summary
FieldsModifier and TypeFieldDescriptionAn error message set when an error occurs.An IndeterminateProgressMonitor which may pop up.A ProgressMonitor which may pop up. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMonitorWorker(Component c, String progName) Creates a new MonitorWorker with a parent component and a program name. -
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 program name for thisMonitorWorker.voidSet the action description for the Progress monitor or IndeterminateProgressMonitor.voidSet the action description for the ProgressMonitor.Methods inherited from class javax.swing.SwingWorker
addPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress
-
Field Details
-
monitor
A ProgressMonitor which may pop up. -
indeterminateMonitor
An IndeterminateProgressMonitor which may pop up. -
errorMessage
An error message set when an error occurs.
-
-
Constructor Details
-
MonitorWorker
Creates a new MonitorWorker with a parent component and a program name.- Parameters:
c- a Component which may be able to show status messages, if non-null.progName- program name for the program that is running this MonitorWorker.
-
-
Method Details
-
getComponent
Returns the component from which thisMonitorWorkerwas launched.- Returns:
- the component (if non-null) from which this
MonitorWorkerwas launched.
-
getProgName
Returns the program name for thisMonitorWorker.- Returns:
- the program name for this
MonitorWorker.
-
setAction
Set the action description for the ProgressMonitor.- Parameters:
descr- the action description.min- the minimum for the ProgressMonitor.max- the maximum for the ProgressMonitor.
-
setAction
Set the action description for the Progress monitor or IndeterminateProgressMonitor.- 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.- Specified by:
doInBackgroundin classSwingWorker<ExitStatus,Integer> - Returns:
- the
ExitStatusindicating whether the processing was successful, and if not why not.
-
done
public void done()- Overrides:
donein classSwingWorker<ExitStatus,Integer>
-