public final class ProgressHandle extends Object implements AutoCloseable
org.netbeans.api.progres.ProgressUIHandle
class from org.netbeans.api.progress.nb
module.Modifier and Type | Method and Description |
---|---|
void |
close()
Calls
ProgressHandle.finish() |
static ProgressHandle |
createHandle(String displayName)
Create a progress ui handle for a long lasting task.
|
static ProgressHandle |
createHandle(String displayName,
Cancellable allowToCancel)
Create a progress ui handle for a long lasting task.
|
static ProgressHandle |
createSystemHandle(String displayName,
Cancellable allowToCancel)
Create a cancelable handle for a task that is not triggered by explicit user action.
|
void |
finish()
Finish the task, remove the task's component from the progress bar UI.
|
void |
progress(int workunit)
Notify the user about completed workunits.
|
void |
progress(String message)
Notify the user about progress by showing message with details.
|
void |
progress(String message,
int workunit)
Notify the user about completed workunits and show additional detailed message.
|
void |
setDisplayName(String newDisplayName)
Change the display name of the progress task.
|
void |
setInitialDelay(int millis)
Set a custom initial delay for the progress task to appear in the status bar.
|
void |
start()
start the progress indication for indeterminate task.
|
void |
start(int workunits)
start the progress indication for a task with known number of steps.
|
void |
start(int workunits,
long estimate)
start the progress indication for a task with known number of steps and known
time estimate for completing the task.
|
void |
suspend(String message)
Current task can switch to silent suspend mode where the progress bar stops moving, hides completely or partially.
|
void |
switchToDeterminate(int workunits)
Currently indeterminate task can be switched to show percentage completed.
|
void |
switchToDeterminate(int workunits,
long estimate)
Currently indeterminate task can be switched to show the time estimate til completion.
|
void |
switchToIndeterminate()
Currently determinate task (with percentage or time estimate) can be
switched to indeterminate mode.
|
public static ProgressHandle createHandle(String displayName)
displayName
- to be shown in the progress UIProgressHandle
, initialized but not started.public static ProgressHandle createHandle(String displayName, Cancellable allowToCancel)
allowToCancel
- either null, if the task cannot be cancelled or
an instance of Cancellable
that will be called when user
triggers cancel of the task.displayName
- to be shown in the progress UIProgressHandle
, initialized but not started.public static ProgressHandle createSystemHandle(String displayName, Cancellable allowToCancel)
displayName
- to be shown in the progress UIallowToCancel
- either null, if the task cannot be cancelled or
an instance of Cancellable
that will be called when user
triggers cancel of the task.ProgressHandle
, initialized but not started.public final void start()
start
method can be called just once.public final void start(int workunits)
start
method can be called just once.workunits
- total number of workunits that will be processedpublic final void start(int workunits, long estimate)
start
method can be called just once.workunits
- total number of workunits that will be processedestimate
- estimated time to process the task in secondspublic final void switchToIndeterminate()
start
method and before calling finish
method (the task has to be running).public final void suspend(String message)
start
method and before calling finish
method (the task has to be running).
Useful to make progress in status bar less intrusive.
for very long running tasks, eg. running an ant script that executes user application, debugs user application etc.
Any incoming progress wakes up the progress bar to previous state.message
- a message to display in the silent modepublic final void switchToDeterminate(int workunits)
start
method and before calling finish
method (the task has to be running).
A common usecase is to calculate the amount of work in the beginning showing
in indeterminate mode and later switch to the progress with known stepsworkunits
- a definite number of complete units of work out of the totalpublic final void switchToDeterminate(int workunits, long estimate)
start
method and before calling finish
method (the task has to be running).
A common usecase is to calculate the amount of work in the beginning
in indeterminate mode and later switch to the progress with the calculated estimate.workunits
- a definite number of complete units of work out of the totalestimate
- estimated time to process the task, in secondspublic final void close()
ProgressHandle.finish()
close
in interface AutoCloseable
public final void finish()
start
method (the task has to be running).public final void progress(int workunit)
start
method and before calling finish
method (the task has to be running).workunit
- a cumulative number of workunits completed so farpublic final void progress(String message)
start
method and before calling finish
method (the task has to be running).message
- details about the status of the taskpublic final void progress(String message, int workunit)
start
method and before calling finish
method (the task has to be running).message
- details about the status of the taskworkunit
- a cumulative number of workunits completed so farpublic final void setInitialDelay(int millis)
Progress bars that are placed in custom dialogs do always appear right away without a delay.
millis
- number of miliseconds to wait before the progress appears in status bar.public final void setDisplayName(String newDisplayName)
newDisplayName
- a new name to set for the task