public final class ProgressMonitor extends TextOutputCallback
This progress monitor allows to specify the total number of units of work to be completed, and then marking them as being completed.
final List<Task> tasks = ...;
final UpgradeContext context = ...;
final LocalizableMessage msg = ...;
ProgressMonitor.reportProgressMonitor(upgradeContext, msg, tasks.size(), monitor -> {
for (Task t : tasks) {
monitor.worked(1);
}
});
final UpgradeContext context = ...;
final LocalizableMessage msg = ...;
ProgressMonitor.reportProgress(upgradeContext, msg, 100, monitor -> {
try {
// do first task, which takes a third the of the total time
monitor.worked(33);
// do second task, which takes the remaining time
} catch (final Exception e) {
// do something else with the exception
}
});
Inspired by Eclipse's org.eclipse.core.runtime.SubMonitor
class.
ERROR, INFORMATION, WARNING
Modifier and Type | Method and Description |
---|---|
void |
complete()
Marks and prints that all the work has been completed.
|
void |
error()
Marks and prints that there was an error.
|
int |
getProgress()
Returns an integer which represents the task's progress percentage, i.e.
|
void |
worked(int work)
Marks and prints additional completed work.
|
getMessage, getMessageType
public int getProgress()
public void worked(int work) throws com.forgerock.opendj.cli.ClientException
work
- the additional work completedcom.forgerock.opendj.cli.ClientException
- if the progress cannot be printedpublic void complete() throws com.forgerock.opendj.cli.ClientException
com.forgerock.opendj.cli.ClientException
- if the progress cannot be printedpublic void error() throws com.forgerock.opendj.cli.ClientException
com.forgerock.opendj.cli.ClientException
- if the progress cannot be printedCopyright 2010-2022 ForgeRock AS.