Package org.eclipse.core.runtime
Class SubProgressMonitor
java.lang.Object
org.eclipse.core.runtime.ProgressMonitorWrapper
org.eclipse.core.runtime.SubProgressMonitor
- All Implemented Interfaces:
IProgressMonitor,IProgressMonitorWithBlocking
Deprecated.
A progress monitor that uses a given amount of work ticks from a parent
monitor. Code that currently uses this utility should be rewritten to use
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:
- Calls to
IProgressMonitor.beginTask(java.lang.String, int)on the root monitor should be replaced by a call toSubMonitor.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. - All calls to
SubProgressMonitor(IProgressMonitor, int)should be replaced by calls toSubMonitor.split(int). - If a SubProgressMonitor is constructed using the SUPPRESS_SUBTASK_LABEL
flag, replace it with the two-argument version of
SubMonitor.split(int, int)usingSubMonitor.SUPPRESS_SUBTASKas the second argument. - It is not necessary to call done on an instance of
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDeprecated.Style constant indicating that the main task label should be prepended to the subtask label.static final intDeprecated.Style constant indicating that calls tosubTaskshould not have any effect.Fields inherited from interface org.eclipse.core.runtime.IProgressMonitor
UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionSubProgressMonitor(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.Starts a new main task.voiddone()Deprecated.This implementation of aIProgressMonitormethod forwards to the wrapped progress monitor.voidinternalWorked(double work) Deprecated.This implementation of aIProgressMonitormethod forwards to the wrapped progress monitor.voidDeprecated.This implementation of aIProgressMonitormethod forwards to the wrapped progress monitor.voidworked(int work) Deprecated.This implementation of aIProgressMonitormethod forwards to the wrapped progress monitor.Methods inherited from class org.eclipse.core.runtime.ProgressMonitorWrapper
clearBlocked, getWrappedProgressMonitor, isCanceled, setBlocked, setCanceled, setTaskNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.core.runtime.IProgressMonitor
slice
-
Field Details
-
SUPPRESS_SUBTASK_LABEL
public static final int SUPPRESS_SUBTASK_LABELDeprecated.Style constant indicating that calls tosubTaskshould not have any effect. This is equivalent toSubMonitor.SUPPRESS_SUBTASK- See Also:
-
PREPEND_MAIN_LABEL_TO_SUBTASK
public static final int PREPEND_MAIN_LABEL_TO_SUBTASKDeprecated.Style constant indicating that the main task label should be prepended to the subtask label.- See Also:
-
-
Constructor Details
-
SubProgressMonitor
Deprecated.Creates a new sub-progress monitor for the given monitor. The sub progress monitor uses the given number of work ticks from its parent monitor.- Parameters:
monitor- the parent progress monitorticks- the number of work ticks allocated from the parent monitor
-
SubProgressMonitor
Deprecated.Creates a new sub-progress monitor for the given monitor. The sub progress monitor uses the given number of work ticks from its parent monitor.- Parameters:
monitor- the parent progress monitorticks- the number of work ticks allocated from the parent monitorstyle- one ofSUPPRESS_SUBTASK_LABELPREPEND_MAIN_LABEL_TO_SUBTASK
- See Also:
-
-
Method Details
-
beginTask
Deprecated.Starts a new main task. Since this progress monitor is a sub progress monitor, the given name will NOT be used to update the progress bar's main task label. That means the given string will be ignored. If stylePREPEND_MAIN_LABEL_TO_SUBTASKis specified, then the given string will be prepended to every string passed tosubTask(String).- Specified by:
beginTaskin interfaceIProgressMonitor- Overrides:
beginTaskin classProgressMonitorWrapper- Parameters:
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 isUNKNOWNthe implementation is free to indicate progress in a way which doesn't require the total number of work units in advance.- See Also:
-
done
public void done()Deprecated.Description copied from class:ProgressMonitorWrapperThis implementation of aIProgressMonitormethod forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
donein interfaceIProgressMonitor- Overrides:
donein classProgressMonitorWrapper- See Also:
-
internalWorked
public void internalWorked(double work) Deprecated.Description copied from class:ProgressMonitorWrapperThis implementation of aIProgressMonitormethod forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
internalWorkedin interfaceIProgressMonitor- Overrides:
internalWorkedin classProgressMonitorWrapper- Parameters:
work- the amount of work done- See Also:
-
subTask
Deprecated.Description copied from class:ProgressMonitorWrapperThis implementation of aIProgressMonitormethod forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
subTaskin interfaceIProgressMonitor- Overrides:
subTaskin classProgressMonitorWrapper- Parameters:
name- the name (or description) of the subtask- See Also:
-
worked
public void worked(int work) Deprecated.Description copied from class:ProgressMonitorWrapperThis implementation of aIProgressMonitormethod forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
workedin interfaceIProgressMonitor- Overrides:
workedin classProgressMonitorWrapper- Parameters:
work- a non-negative number of work units just completed- See Also:
-
SubMonitorinstead