public interface ProgressMonitor
monitor.beginTask() try { .. do some work monitor.worked() monitor.subTask()/monitor.intermediateTask() .. do some work monitor.worked() } finally { monitor.finishTask(); }
subTask(String)
and indeterminateSubTask(String)
has nothing to do with logical
structure of the work, they just show task title to the user.
If task consists of multiple tasks then createSubTaskMonitor(int, boolean)
may be used. It
will create new ProgressMonitor, then can be passed to the subtask. Subtask doesn't know whether
it runs standalone or as a part of other task. Progressbar will be updated so that total progress is
shown, not just progress of the subtask
All ProgressMonitor implementations should be thread safe.Modifier and Type | Interface and Description |
---|---|
static interface |
ProgressMonitor.CancelListener |
Modifier and Type | Field and Description |
---|---|
static int |
ALL_TICKS
Can be used with
worked(int) and createSubTaskMonitor(int, boolean) to
express that the task should use all remaining ticks |
static int |
DEFAULT_TICKS
Ticks count used, when no other value is supplied
|
Modifier and Type | Method and Description |
---|---|
void |
addCancelListener(ProgressMonitor.CancelListener listener)
Add listener for user abort action
|
void |
appendLogMessage(String message)
Appends a message to the log managed by the progress monitor.
|
void |
beginTask(String title)
Starts this progress monitor.
|
void |
beginTask(String title,
int ticks)
Starts this progress monitor.
|
void |
cancel()
Abort current operation, usually called when user somehow requested an abort
|
ProgressMonitor |
createSubTaskMonitor(int ticks,
boolean internal)
Creates subtasks monitor.
|
void |
finishTask()
Finish this progress monitor, close the dialog or inform the parent progress monitor
that it can continue with other tasks.
|
ProgressTaskId |
getProgressTaskId()
Returns the task ID of the progress dialog
Should be used only by PleaseWaitRunnable
|
int |
getTicks()
Get the current number of work units
|
int |
getTicksCount()
Get the total number of work units
|
Component |
getWindowParent()
Return the parent windows of progress dialog
|
void |
indeterminateSubTask(String title)
Subtask that will show progress running back and forth
|
void |
invalidate()
Can be used if method receive ProgressMonitor but it's not interested progress monitoring.
|
boolean |
isCanceled()
Returns the state of user aborts
|
void |
removeCancelListener(ProgressMonitor.CancelListener listener)
Remove listener for user abort action
|
void |
setCustomText(String text)
Shows additional text
|
void |
setExtraText(String text)
Show extra text after normal task title.
|
void |
setProgressTaskId(ProgressTaskId taskId)
Set the task ID of the progress dialog
Should be used only by PleaseWaitRunnable.
|
void |
setTicks(int ticks)
Set the current number of work units
|
void |
setTicksCount(int ticks)
Set the total number of work units
|
void |
subTask(String title)
Normal subtask
|
void |
worked(int ticks)
Increase number of already done work units by ticks
|
static final int DEFAULT_TICKS
static final int ALL_TICKS
worked(int)
and createSubTaskMonitor(int, boolean)
to
express that the task should use all remaining ticksvoid beginTask(String title)
title
- title text of the taskvoid beginTask(String title, int ticks)
title
- title text of the taskticks
- number of work units (see setTicksCount(int ticks)
)void finishTask()
void invalidate()
beginTask(String)
and finishTask()
This method can be also used in finally section if method expects that some exception
might prevent it from passing progressMonitor away. If beginTask(String)
was
already called then this method does nothing.void setTicksCount(int ticks)
ticks
- Number of total work unitsint getTicksCount()
void setTicks(int ticks)
ticks
- Number of work units already doneint getTicks()
void worked(int ticks)
ticks
- number of ticks to addvoid indeterminateSubTask(String title)
title
- Can be null
, in that case task title is not changedvoid subTask(String title)
title
- Can be null
, in that case task title is not changedvoid setCustomText(String text)
void setExtraText(String text)
text
- ProgressMonitor createSubTaskMonitor(int ticks, boolean internal)
ticks
- Number of work units that should be done when subtask finishesinternal
- If true then subtask can't modify task title/custom textboolean isCanceled()
true
if user aborted operationvoid cancel()
void addCancelListener(ProgressMonitor.CancelListener listener)
listener
- the listener for cancel operationvoid removeCancelListener(ProgressMonitor.CancelListener listener)
listener
- the listener for cancel operationvoid appendLogMessage(String message)
message
- the log message. Ignored if null or white space only.void setProgressTaskId(ProgressTaskId taskId)
<> null
then "In background" button will be showntaskId
- the task IDProgressTaskId getProgressTaskId()
Component getWindowParent()