public final class ProgressHandle extends Object implements AutoCloseable
This class was adapted to contain only non-Swing part of the Progress API. If you need
to use progress UI components, please work with org.netbeans.api.progres.ProgressUIHandle
class from org.netbeans.api.progress.nb
module.
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_VIEW
The action command generated by user "activation" of a
ProgressHandle 's
representation. |
Modifier and Type | Method and Description |
---|---|
boolean |
addDefaultAction(Action action)
Adds an action to the progress indicator.
|
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 |
createHandle(String displayName,
Cancellable allowToCancel,
Action viewAction)
Creates a potentially cancellable handle, which can deliver an event if the user 'triggers' the handle.
|
static ProgressHandle |
createSystemHandle(String displayName,
Cancellable allowToCancel)
Create a cancelable handle for a task that is not triggered by explicit user action.
|
static ProgressHandle |
createSystemHandle(String displayName,
Cancellable allowToCancel,
Action viewAction)
Creates a possibly cancellable handle, not initiated by the user, e.g.
|
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 final String ACTION_VIEW
ProgressHandle
's
representation.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 static ProgressHandle createHandle(String displayName, Cancellable allowToCancel, Action viewAction)
Controller
implementation. The user may make an action on the handle (other than cancel), which will
be reflected back. Typically used to focus or display some part of the UI.
If triggerCallback
is provided, it should handle at least ProgressHandle.ACTION_VIEW
action command
ActionEvent.getActionCommand()
.viewAction
- callback on user's trigger.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 static ProgressHandle createSystemHandle(String displayName, Cancellable allowToCancel, Action viewAction)
ProgressHandle.createHandle(java.lang.String, org.openide.util.Cancellable, javax.swing.Action)
for more details.displayName
- to be shown in the progress UIallowToCancel
- either null
, if the task cannot be cancelled or an Cancellable
instance
that will be called when the user requests cancel.viewAction
- listener that will be triggered when the progress is 'activated'.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 taskpublic final boolean addDefaultAction(Action action)
action
- describes the action