Package ucar.ui.widget
Class ProgressMonitorTask
- java.lang.Object
-
- ucar.ui.widget.ProgressMonitorTask
-
- All Implemented Interfaces:
Runnable
public abstract class ProgressMonitorTask extends Object implements Runnable
Subclass this for use in a ProgressMonitor. Responsibilities of your subclass:- You must provide the run method, which actually does the work that the ProgressMonitor is showing progress for.
- You must set the done flag for the ProgressMonitor to complete. To avoid race conditions, do eveything else before you set the done flag.
- You should override setProgress() and return a real count that corresponds to progressMaxCount in ProgressMonitor.start().
- If possible, you should stop working if isCancel(). Usually this means checking the cancel flag in an iteration.
- You should set the success flag if everything worked ok.
- You should set an error message if there is an error. Normally you would also set done=true, and stop working. The ProgressMonitor will detect this and exit.
- Call cancel() if the user pressed cancel.
- Set progress value by counting elapsed seconds. You may overrride this by overridding getProgress() and/or getNote().
- See Also:
ProgressMonitor
-
-
Constructor Summary
Constructors Constructor Description ProgressMonitorTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcancel()ProgressMonitor will call this when the user cancels.StringgetErrorMessage()Applications call this to get an error message.StringgetNote()ProgressMonitor displays this note in the ProgressMonitor.intgetProgress()ProgressMonitor displays this progress value in the ProgressMonitor.booleanisCancel()Application calls to see if task is cancelled.booleanisDone()ProgressMonitor calls to see if task is done.booleanisError()Applications call this to find out if there was an error.booleanisSuccess()Application calls to see if task is success.abstract voidrun()Here is where the work gets done.voidsetDone(boolean done)voidsetError(String error)for compatibility with ucar.nc2.CancelTaskvoidsetProgress(String msg, int progress)
-
-
-
Method Detail
-
run
public abstract void run()
Here is where the work gets done.
-
isSuccess
public boolean isSuccess()
Application calls to see if task is success.
-
isCancel
public boolean isCancel()
Application calls to see if task is cancelled.
-
isError
public boolean isError()
Applications call this to find out if there was an error.
-
getErrorMessage
public String getErrorMessage()
Applications call this to get an error message.
-
isDone
public boolean isDone()
ProgressMonitor calls to see if task is done.
-
cancel
public void cancel()
ProgressMonitor will call this when the user cancels.
-
getNote
public String getNote()
ProgressMonitor displays this note in the ProgressMonitor. If null, ProgressMonitor will show elasped seconds.
-
getProgress
public int getProgress()
ProgressMonitor displays this progress value in the ProgressMonitor. If <0, ProgressMonitor will show elasped seconds.
-
setError
public void setError(String error)
for compatibility with ucar.nc2.CancelTask
-
setProgress
public void setProgress(String msg, int progress)
-
setDone
public void setDone(boolean done)
-
-