|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectProgressController
@ThreadSafe public abstract class ProgressController
Monitors the progress of some lengthly operation, and allows cancellation. This abstract class makes no assumption about the output device. Additionally, this class provides support for non-fatal warning and exception reports.
All implementations should be multi-thread safe, even the ones that provide feedback to a user interface thread.
Usage example:
float scale = 100f / maximumCount;
controller.started();
for (int counter=0; counter<maximumCount; counter++) {
if (controller.isCanceled()) {
break;
}
controller.progress(scale * counter);
try {
// Do some work...
} catch (NonFatalException e) {
controller.exceptionOccurred(e);
}
}
controller.complete();
| utility/geotk-utility (download) | View source code for this class |
| Constructor Summary | |
|---|---|
protected |
ProgressController()
Constructs a progress controller which will format messages in the system default locale. |
| Method Summary | |
|---|---|
void |
cancel()
Indicates that this job should be canceled. |
abstract void |
completed()
Notifies this controller that the operation has finished. |
void |
completed(ProcessEvent event)
Notifies this controller that the operation has finished and sets the states of this controller according the given event. |
abstract void |
exceptionOccurred(Throwable exception)
Reports an exception. |
void |
failed(ProcessEvent event)
Notifies this controller that the operation has failed and sets the states of this controller according the given event. |
Locale |
getLocale()
Returns the locale used for formatting messages. |
float |
getProgress()
Returns the current progress as a percent completed. |
InternationalString |
getTask()
Returns the description of the current task being performed, or null if none. |
boolean |
isCanceled()
Returns true if this job is canceled. |
void |
progressing(ProcessEvent event)
Updates the task and progress state, and reports the exception if any. |
void |
setProgress(float percent)
Notifies this controller of progress in the lengthly operation. |
void |
setTask(CharSequence task)
Sets the description of the current task being performed. |
abstract void |
started()
Notifies this controller that the operation begins. |
void |
started(ProcessEvent event)
Notifies this controller that the operation begins and sets the states of this controller according the given event. |
abstract void |
warningOccurred(String source,
String location,
String warning)
Reports a warning. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected ProgressController()
| Method Detail |
|---|
public Locale getLocale()
getLocale in interface Localizedpublic InternationalString getTask()
null if none.
It is assumed that if the task is null applications may simply report that the
process is "in progress" or "working" as represented in the
current locale.
null if none.public void setTask(CharSequence task)
task - Description of the task being performed as a String or
InternationalString, or null if none.public abstract void started()
public void started(ProcessEvent event)
started(),
then invokes progressing(event).
started in interface ProcessListenerevent - The progress event, or null if none.public float getProgress()
public void setProgress(float percent)
percent - The progress as a value between 0 and 100 inclusive.public void progressing(ProcessEvent event)
ProcessEvent.getTask() value unless the later
method returned null, in which case this ProgressController task
is left unchanged.ProcessEvent.getProgress() value unless the
later method returned Float.NaN, in which case this ProgressController
progress state is left unchanged.ProcessEvent.getException() returns a non-null value, then that value is
given to exceptionOccurred(Throwable).
progressing in interface ProcessListenerevent - The progress event, or null if none.public abstract void completed()
public void completed(ProcessEvent event)
progressing(event), then
invokes completed().
completed in interface ProcessListenerevent - The progress event, or null if none.public void failed(ProcessEvent event)
progressing(event). Note that
the above progressing method pass the exception declared by the event (if any) to the exceptionOccurred(Throwable)
method.
failed in interface ProcessListenerevent - The progress event, or null if none.public void cancel()
public boolean isCanceled()
true if this job is canceled.
true if this job is canceled.
public abstract void warningOccurred(String source,
String location,
String warning)
source - Name of the warning source, or null if none. This is typically the
name of the file being parsed, or the URL of the data being processed.location - Text to write on the left side of the warning message, or null if none.
This is typically the line number where the error occurred in the source
file or the feature ID of the feature that produced the message.warning - The warning message.public abstract void exceptionOccurred(Throwable exception)
exception - The exception to report.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||