public interface ProgressMonitor
ProgressMonitor
interface is implemented by objects that
monitor the progress of an activity; the methods in this interface are
invoked by code that performs the activity.
All activity is broken down into a linear sequence of tasks against which
progress is reported. When a task begins, a beginTask(String, int)
notification is reported, followed by any number and mixture of progress
reports (worked(int)
). When the task is eventually completed, a
done()
notification is reported.
A request to cancel an operation can be signaled using the cancel()
method. Operations taking a progress monitor are expected to poll the monitor
(using isCanceled()
) periodically and abort at their earliest
convenience. Operation can however choose to ignore cancelation requests.
Since notification is synchronous with the activity itself, the listener should provide a fast and robust implementation. If the handling of notifications would involve blocking operations, or operations which might throw uncaught exceptions, the notifications should be queued, and the actual processing deferred (or perhaps delegated to a separate thread).
Modifier and Type | Field and Description |
---|---|
static ProgressMonitor |
DUMMY
A default no-op implementation of
ProgressMonitor . |
static int |
UNKNOWN
Constant indicating an unknown amount of work.
|
Modifier and Type | Method and Description |
---|---|
void |
beginTask(String name,
int totalWork)
Notifies that a task is beginning.
|
void |
cancel()
Indicates that cancelation has been requested (but not necessarily
acknowledged).
|
void |
done()
Notifies that the work is done; that is, either the task is completed or
the user canceled it.
|
boolean |
isCanceled()
Returns whether cancelation of current operation has been requested.
|
void |
setTaskName(String name)
Sets the task name to the given value.
|
void |
worked(int progress)
Notifies that a given number of work unit of the task has been completed.
|
static final ProgressMonitor DUMMY
ProgressMonitor
.static final int UNKNOWN
void beginTask(String name, int totalWork)
name
- the name (or description) of the main tasktotalWork
- the total number of work units into which the main task is
been subdivided. If the value is UNKNOWN
the
implementation is free to indicate progress in a way which
doesn't require the total number of work units in advance.void worked(int progress)
progress
- the number of work units just completedvoid setTaskName(String name)
name
- the name (or description) of the main taskbeginTask(java.lang.String, int)
void done()
boolean isCanceled()
true
if cancellation has been requested, and
false
otherwisecancel()
void cancel()
isCanceled()
Copyright © 2003–2021 XDEV Software. All rights reserved.