|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.charlesames.utility.common.ProgressMonitor
public class ProgressMonitor
Common interface for tracking the status and portion-completed condition of a process.
All internal variables are declared as volatile, for thread safety.
When the process starts running, it should set ProgressMonitor.Goal to the total
number of steps required for completion, ProgressMonitor.Current to 0, and
ProgressMonitor.Status to RUNNING.
Each time the process achieves a step it should
update ProgressMonitor.Current. ProgressMonitor.ActivityMessage can also be used to
communicate what the process is doing.
If the process completes successfully, it
should call ProgressMonitor.complete().
If the process completes with an error it should
call ProgressMonitor.error() with a suitable message.
With one exception, only the process
being monitored should be updating ProgressMonitor properties. The exception is ProgressMonitor.kill().
This method should be called by the monitoring thread when the end user wishes to cancel the process
being monitored. The process being monitored should periodically consult ProgressMonitor.isPermitted().
When this returns false, the process should shut down all activity, then call ProgressMonitor.cancel().
| Nested Class Summary | |
|---|---|
static class |
ProgressMonitor.Status
ProgressMonitor status conditions. |
| Constructor Summary | |
|---|---|
ProgressMonitor()
Constructor for ProgressMonitor instances. |
|
ProgressMonitor(java.lang.Thread thread)
Constructor for ProgressMonitor instances. |
|
| Method Summary | |
|---|---|
void |
appendActivityMessage(java.lang.String message)
|
void |
cancel()
Set ProgressMonitor.Status to CANCELED. |
void |
complete()
Set ProgressMonitor.Status to COMPLETE; set ProgressMonitor.Current to ProgressMonitor.Goal; clear ProgressMonitor.ErrorMessage; and set ProgressMonitor.ActivityMessage to "Done". |
void |
error(java.lang.String message)
Set ProgressMonitor.Status to ERROR; and set ProgressMonitor.ErrorMessage to the message parameter. |
java.lang.String |
getActivityMessage()
Get the activity message. |
java.lang.String |
getCompletedMessage()
Get the completed message. |
double |
getCurrent()
|
java.lang.String |
getErrorMessage()
|
double |
getGoal()
|
int |
getPhase()
Get the phase. |
ProgressMonitor.Status |
getStatus()
|
java.lang.Thread |
getThread()
Get the thread whose progress is being monitored. |
void |
incrementCurrent(double increment)
Increment the current progress amount. |
boolean |
isComplete()
|
boolean |
isPermitted()
|
boolean |
isRunning()
|
void |
kill()
Set ProgressMonitor.Status to KILLED. |
void |
setActivityMessage(java.lang.String message)
|
void |
setCompletedMessage(java.lang.String message)
|
void |
setCurrent(double current)
Update the current progress amount. |
void |
setGoal(double goal)
Update the progress limit. |
void |
setPhase(int phase)
Set the phase. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ProgressMonitor()
public ProgressMonitor(java.lang.Thread thread)
thread - The thread whose progress is being monitored.| Method Detail |
|---|
public java.lang.Thread getThread()
public int getPhase()
public void setPhase(int phase)
phase - The intended phase.public double getCurrent()
public void setCurrent(double current)
current - A number indicating the current progress. Ranges from 0 to ProgressMonitor.Goal.public void incrementCurrent(double increment)
increment - A number indicating the change in current progress.public double getGoal()
public void setGoal(double goal)
goal - A number indicating the current progress. Ranges from 0 to ProgressMonitor.Goal.public boolean isPermitted()
ProgressMonitor.Status.RUNNING; false otherwise.public boolean isComplete()
ProgressMonitor.Status.COMPLETE; false otherwise.public void complete()
public void error(java.lang.String message)
message - Text to be presented in ProgressMonitor.ErrorMessage.public void kill()
public void cancel()
public ProgressMonitor.Status getStatus()
public boolean isRunning()
public java.lang.String getErrorMessage()
public java.lang.String getActivityMessage()
public void setActivityMessage(java.lang.String message)
message - The text to be displayed by ProgressMonitor.ActivityMessage while the task is running.public void appendActivityMessage(java.lang.String message)
message - The text to be displayed by ProgressMonitor.ActivityMessage while the task is running.public java.lang.String getCompletedMessage()
public void setCompletedMessage(java.lang.String message)
message - The text to be displayed by ProgressMonitor.ActivityMessage after the task has completed successfully.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||