|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Observable | +--uk.org.ogsadai.client.databrowser.DBProgressModel
Observable progress model for monitoring progress of a task. Notifies observers of the state of the progess of tasks. In this case the observer is the DBProgressView
which displays the state of the progress.
The model should be instantiated and then call method startTask
at the start of a long running task, status
at stages within the task and finishTask
on completion. The task itself should be executed in a GUIThread
thread to keep the GUI responsive.
For tasks of known length the status
can be set in two ways. If the subtask number is specified in the status
method call then the progress view is told the subtask value. This should be used for tasks with many subtasks or where the status
is set in a loop, eg:
startTask("Parsing document", 10000); ... for (int i ...) if (i%100==0) status("Parsing line", i) ... finishTask();
If the subtask number is not specified for a task of known length then it should be incremented by DBProgressView
.
DBProgressView
Field Summary | |
private static java.lang.String |
COPYRIGHT_NOTICE Copyright statement |
static int |
FINISHED |
static int |
INDETERMINATE |
private int |
mNumberOfTasks |
private DBProgressView |
mProgressView |
private int |
mSubtask |
private java.lang.String |
mTaskname |
private static java.lang.String |
NO_SUBTASKNAME |
private static java.lang.String |
NO_TASKNAME |
static int |
STARTED |
Fields inherited from class java.util.Observable |
|
Constructor Summary | |
DBProgressModel(javax.swing.JDialog dialog) Construct the progress model to be displayed over a parent JDialog . |
|
DBProgressModel(javax.swing.JFrame frame) Construct the progress model to be displayed over a parent JFrame . |
Method Summary | |
void |
finishTask() Finish the task |
int |
getNumberOfTasks() |
int |
getSubTask() |
java.lang.String |
getTaskname() |
private void |
setSubTask(int subtask) Set the current subtask number |
void |
startTask(java.lang.String taskname) Start a task of unspecified length. |
void |
startTask(java.lang.String taskname, int numberOfTasks) Start a task of specified length |
void |
status(java.lang.String message) Report the current status of the task. |
void |
status(java.lang.String message, int subtask) Report the current status of the task and the number of the subtask. |
private void |
updateObservers(java.lang.Object obj) Update the observers of the progess model. |
private void |
updateStatus(java.lang.String message, int subtask) Sends the observers the current status of the task. |
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String COPYRIGHT_NOTICE
public static final int INDETERMINATE
public static final int STARTED
public static final int FINISHED
private static final java.lang.String NO_TASKNAME
private static final java.lang.String NO_SUBTASKNAME
private DBProgressView mProgressView
private int mSubtask
private java.lang.String mTaskname
private int mNumberOfTasks
Constructor Detail |
public DBProgressModel(javax.swing.JFrame frame)
JFrame
.
frame
- The parent GUIpublic DBProgressModel(javax.swing.JDialog dialog)
JDialog
.
dialog
-Method Detail |
private void updateObservers(java.lang.Object obj)
obj
- The updated valuepublic void startTask(java.lang.String taskname)
taskname
- The name of the taskpublic void startTask(java.lang.String taskname, int numberOfTasks)
taskname
- The name of the tasknumberOfTasks
- The length of the taskpublic void status(java.lang.String message)
message
- The status reportpublic void status(java.lang.String message, int subtask)
message
-subtask
-private void updateStatus(java.lang.String message, int subtask)
message
-subtask
-public void finishTask()
public java.lang.String getTaskname()
public int getNumberOfTasks()
private void setSubTask(int subtask)
subtask
- The number of the current subtaskpublic int getSubTask()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |