|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ProgressListener
Monitor the progress of some lengthly operation, and allows cancelation.
This interface makes no assumption about the output device. Additionnaly, this interface 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.
Here an example showing how to cancel:
Iterator iterator = null;
try {
float size = size();
float position = 0;
progress.started();
for (iterator = iterator(); !progress.isCanceled() && iterator.hasNext(); progress.progress(++position/size)) {
try {
Feature feature = (Feature) iterator.next();
visitor.visit(feature);
}
catch (Exception erp) {
progress.exceptionOccurred(erp);
}
}
progress.complete();
}
finally {
close (iterator);
}
Note the use of try and catch to report exceptions.
Method Summary | |
---|---|
void |
complete()
Notifies this listener that the operation has finished. |
void |
dispose()
Releases any resources used by this listener. |
void |
exceptionOccurred(Throwable exception)
Reports an exception. |
String |
getDescription()
Deprecated. Please use getTask().toString() |
InternationalString |
getTask()
Return the current task being performed, or null if none. |
boolean |
isCanceled()
Is this job canceled? |
void |
progress(float percent)
Notifies this listener of progress in the lengthly operation. |
void |
setCanceled(boolean cancel)
Indicate that progress should is canceled. |
void |
setDescription(String description)
Deprecated. please use setTask |
void |
setTask(InternationalString task)
Set the current task being performed. |
void |
started()
Notifies this listener that the operation begins. |
void |
warningOccurred(String source,
String margin,
String warning)
Reports a warning. |
Method Detail |
---|
String getDescription()
null
if none.
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.
void setTask(InternationalString task)
This task may be user visible and is represented as an international string for locale support.
task
- void setDescription(String description)
description
- The new description, or null
if none.void started()
void progress(float percent)
void complete()
void dispose()
boolean isCanceled()
void setCanceled(boolean cancel)
void warningOccurred(String source, String margin, String warning)
source
- Name of the warning source, or null
if none. This is typically the
filename in process of being parsed.margin
- Text to write on the left side of the warning message, or null
if none.
This is typically the line number where the error occured in the source
file.warning
- The warning message.void exceptionOccurred(Throwable exception)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |