Package com.bc.ceres.core
Class SubProgressMonitor
- java.lang.Object
-
- com.bc.ceres.core.ProgressMonitorWrapper
-
- com.bc.ceres.core.SubProgressMonitor
-
- All Implemented Interfaces:
ProgressMonitor
public class SubProgressMonitor extends ProgressMonitorWrapper
A progress monitor that uses a given amount of work ticks from a parent monitor. It can be used as follows:try { pm.beginTask("Main Task", 100); doSomeWork(pm, 30); SubProgressMonitor subMonitor= SubProgressMonitor.create(pm, 40); try { subMonitor.beginTask("", 300); doSomeWork(subMonitor, 300); } finally { subMonitor.done(); } doSomeWork(pm, 30); } finally { pm.done(); }This class may be instantiated or subclassed by clients.
This class has been more or less directly taken over from the Eclipse Core API.
-
-
Field Summary
Fields Modifier and Type Field Description static intPREPEND_MAIN_LABEL_TO_SUBTASKStyle constant indicating that the main task label should be prepended to the subtask label.static intSUPPRESS_SUBTASK_LABELStyle constant indicating that calls tosubTaskshould not have any effect.-
Fields inherited from interface com.bc.ceres.core.ProgressMonitor
NULL, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description SubProgressMonitor(ProgressMonitor monitor, int ticks)Creates a new sub-progress monitor for the given monitor.SubProgressMonitor(ProgressMonitor monitor, int ticks, int style)Creates a new sub-progress monitor for the given monitor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginTask(String taskName, int totalWork)This implementation of aProgressMonitormethod forwards to the wrapped progress monitor.static ProgressMonitorcreate(ProgressMonitor monitor, int ticks)Creates a progress monitor based on the passed in parent monitor.static ProgressMonitorcreateSynchronized(ProgressMonitor monitor, int ticks)Creates a progress monitor based on the passed in parent monitor.If the parent monitor isProgressMonitor.NULL,monitoris returned, otherwise a newSubProgressMonitoris created.voiddone()This implementation of aProgressMonitormethod forwards to the wrapped progress monitor.voidinternalWorked(double work)This implementation of aProgressMonitormethod forwards to the wrapped progress monitor.voidsetSubTaskName(String subTaskName)This implementation of aProgressMonitormethod forwards to the wrapped progress monitor.voidworked(int work)This implementation of aProgressMonitormethod forwards to the wrapped progress monitor.-
Methods inherited from class com.bc.ceres.core.ProgressMonitorWrapper
getWrappedProgressMonitor, isCanceled, setCanceled, setTaskName
-
-
-
-
Field Detail
-
SUPPRESS_SUBTASK_LABEL
public static final int SUPPRESS_SUBTASK_LABEL
Style constant indicating that calls tosubTaskshould not have any effect.
-
PREPEND_MAIN_LABEL_TO_SUBTASK
public static final int PREPEND_MAIN_LABEL_TO_SUBTASK
Style constant indicating that the main task label should be prepended to the subtask label.
-
-
Constructor Detail
-
SubProgressMonitor
public SubProgressMonitor(ProgressMonitor monitor, int ticks)
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
public SubProgressMonitor(ProgressMonitor monitor, int ticks, int style)
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 of-
SUPPRESS_SUBTASK_LABEL -
PREPEND_MAIN_LABEL_TO_SUBTASK
-
- See Also:
SUPPRESS_SUBTASK_LABEL,PREPEND_MAIN_LABEL_TO_SUBTASK
-
-
Method Detail
-
create
public static ProgressMonitor create(ProgressMonitor monitor, int ticks)
Creates a progress monitor based on the passed in parent monitor. If the parent monitor isProgressMonitor.NULL,monitoris returned, otherwise a newSubProgressMonitoris created.- Parameters:
monitor- the parent progress monitorticks- the number of work ticks allocated from the parent monitor- Returns:
- a progress monitor
-
createSynchronized
public static ProgressMonitor createSynchronized(ProgressMonitor monitor, int ticks)
Creates a progress monitor based on the passed in parent monitor.If the parent monitor isProgressMonitor.NULL,monitoris returned, otherwise a newSubProgressMonitoris created. In contrast to the monitor returned bycreate(ProgressMonitor, int)this one can be considered to be thread-safe.- Parameters:
monitor- the parent progress monitorticks- the number of work ticks allocated from the parent monitor- Returns:
- a progress monitor
-
beginTask
public void beginTask(String taskName, int totalWork)
Description copied from class:ProgressMonitorWrapperThis implementation of aProgressMonitormethod forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
beginTaskin interfaceProgressMonitor- Overrides:
beginTaskin classProgressMonitorWrapper- Parameters:
taskName- 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:
ProgressMonitor.beginTask(String, int)
-
done
public void done()
Description copied from class:ProgressMonitorWrapperThis implementation of aProgressMonitormethod forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
donein interfaceProgressMonitor- Overrides:
donein classProgressMonitorWrapper- See Also:
ProgressMonitor.done()
-
internalWorked
public void internalWorked(double work)
Description copied from class:ProgressMonitorWrapperThis implementation of aProgressMonitormethod forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
internalWorkedin interfaceProgressMonitor- Overrides:
internalWorkedin classProgressMonitorWrapper- Parameters:
work- the amount of work done- See Also:
ProgressMonitor.internalWorked(double)
-
setSubTaskName
public void setSubTaskName(String subTaskName)
Description copied from class:ProgressMonitorWrapperThis implementation of aProgressMonitormethod forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
setSubTaskNamein interfaceProgressMonitor- Overrides:
setSubTaskNamein classProgressMonitorWrapper- Parameters:
subTaskName- the name (or description) of the subtask- See Also:
ProgressMonitor.setSubTaskName(String)
-
worked
public void worked(int work)
Description copied from class:ProgressMonitorWrapperThis implementation of aProgressMonitormethod forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
workedin interfaceProgressMonitor- Overrides:
workedin classProgressMonitorWrapper- Parameters:
work- the number of work units just completed- See Also:
ProgressMonitor.worked(int)
-
-