SubMonitor
instead@Deprecated public class SubProgressMonitor extends ProgressMonitorWrapper
SubMonitor
instead.
Consider the following example:
void someMethod(IProgressMonitor pm) { pm.beginTask("Main Task", 100); SubProgressMonitor subMonitor1= new SubProgressMonitor(pm, 60); try { doSomeWork(subMonitor1); } finally { subMonitor1.done(); } SubProgressMonitor subMonitor2= new SubProgressMonitor(pm, 40); try { doSomeMoreWork(subMonitor2); } finally { subMonitor2.done(); } }
The above code should be refactored to this:
void someMethod(IProgressMonitor pm) { SubMonitor subMonitor = SubMonitor.convert(pm, "Main Task", 100); doSomeWork(subMonitor.split(60)); doSomeMoreWork(subMonitor.split(40)); }
The process for converting code which used SubProgressMonitor into SubMonitor is:
IProgressMonitor.beginTask(java.lang.String, int)
on the root monitor should be replaced by a call
to SubMonitor.convert(org.eclipse.core.runtime.IProgressMonitor)
. Keep the returned SubMonitor around as a local variable and refer
to it instead of the root monitor for the remainder of the method.SubProgressMonitor(IProgressMonitor, int)
should be replaced by calls to
SubMonitor.split(int)
.SubMonitor.split(int, int)
using SubMonitor.SUPPRESS_SUBTASK
as the second argument.SubMonitor
.
Please see the SubMonitor
documentation for further examples.
This class can be used without OSGi running.
This class may be instantiated or subclassed by clients.
Modifier and Type | Field and Description |
---|---|
static int |
PREPEND_MAIN_LABEL_TO_SUBTASK
Deprecated.
Style constant indicating that the main task label
should be prepended to the subtask label.
|
static int |
SUPPRESS_SUBTASK_LABEL
Deprecated.
Style constant indicating that calls to
subTask
should not have any effect. |
UNKNOWN
Constructor and Description |
---|
SubProgressMonitor(IProgressMonitor monitor,
int ticks)
Deprecated.
Creates a new sub-progress monitor for the given monitor.
|
SubProgressMonitor(IProgressMonitor monitor,
int ticks,
int style)
Deprecated.
Creates a new sub-progress monitor for the given monitor.
|
Modifier and Type | Method and Description |
---|---|
void |
beginTask(String name,
int totalWork)
Deprecated.
Starts a new main task.
|
void |
done()
Deprecated.
This implementation of a
IProgressMonitor
method forwards to the wrapped progress monitor. |
void |
internalWorked(double work)
Deprecated.
This implementation of a
IProgressMonitor
method forwards to the wrapped progress monitor. |
void |
subTask(String name)
Deprecated.
This implementation of a
IProgressMonitor
method forwards to the wrapped progress monitor. |
void |
worked(int work)
Deprecated.
This implementation of a
IProgressMonitor
method forwards to the wrapped progress monitor. |
clearBlocked, getWrappedProgressMonitor, isCanceled, setBlocked, setCanceled, setTaskName
public static final int SUPPRESS_SUBTASK_LABEL
subTask
should not have any effect. This is equivalent to SubMonitor.SUPPRESS_SUBTASK
public static final int PREPEND_MAIN_LABEL_TO_SUBTASK
public SubProgressMonitor(IProgressMonitor monitor, int ticks)
monitor
- the parent progress monitorticks
- the number of work ticks allocated from the
parent monitorpublic SubProgressMonitor(IProgressMonitor monitor, int ticks, int style)
monitor
- the parent progress monitorticks
- the number of work ticks allocated from the
parent monitorstyle
- one of
SUPPRESS_SUBTASK_LABEL
PREPEND_MAIN_LABEL_TO_SUBTASK
SUPPRESS_SUBTASK_LABEL
,
PREPEND_MAIN_LABEL_TO_SUBTASK
public void beginTask(String name, int totalWork)
PREPEND_MAIN_LABEL_TO_SUBTASK
is specified, then the given string will be prepended to
every string passed to subTask(String)
.
beginTask
in interface IProgressMonitor
beginTask
in class ProgressMonitorWrapper
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.IProgressMonitor.beginTask(String, int)
public void done()
ProgressMonitorWrapper
IProgressMonitor
method forwards to the wrapped progress monitor.
Clients may override this method to do additional
processing.done
in interface IProgressMonitor
done
in class ProgressMonitorWrapper
IProgressMonitor.done()
public void internalWorked(double work)
ProgressMonitorWrapper
IProgressMonitor
method forwards to the wrapped progress monitor.
Clients may override this method to do additional
processing.internalWorked
in interface IProgressMonitor
internalWorked
in class ProgressMonitorWrapper
work
- the amount of work doneIProgressMonitor.internalWorked(double)
public void subTask(String name)
ProgressMonitorWrapper
IProgressMonitor
method forwards to the wrapped progress monitor.
Clients may override this method to do additional
processing.subTask
in interface IProgressMonitor
subTask
in class ProgressMonitorWrapper
name
- the name (or description) of the subtaskIProgressMonitor.subTask(String)
public void worked(int work)
ProgressMonitorWrapper
IProgressMonitor
method forwards to the wrapped progress monitor.
Clients may override this method to do additional
processing.worked
in interface IProgressMonitor
worked
in class ProgressMonitorWrapper
work
- a non-negative number of work units just completedIProgressMonitor.worked(int)
Copyright (c) 2000, 2016 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.