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 int
PREPEND_MAIN_LABEL_TO_SUBTASK
Style constant indicating that the main task label should be prepended to the subtask label.static int
SUPPRESS_SUBTASK_LABEL
Style constant indicating that calls tosubTask
should 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 void
beginTask(String taskName, int totalWork)
This implementation of aProgressMonitor
method forwards to the wrapped progress monitor.static ProgressMonitor
create(ProgressMonitor monitor, int ticks)
Creates a progress monitor based on the passed in parent monitor.static ProgressMonitor
createSynchronized(ProgressMonitor monitor, int ticks)
Creates a progress monitor based on the passed in parent monitor.If the parent monitor isProgressMonitor.NULL
,monitor
is returned, otherwise a newSubProgressMonitor
is created.void
done()
This implementation of aProgressMonitor
method forwards to the wrapped progress monitor.void
internalWorked(double work)
This implementation of aProgressMonitor
method forwards to the wrapped progress monitor.void
setSubTaskName(String subTaskName)
This implementation of aProgressMonitor
method forwards to the wrapped progress monitor.void
worked(int work)
This implementation of aProgressMonitor
method 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 tosubTask
should 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
,monitor
is returned, otherwise a newSubProgressMonitor
is 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
,monitor
is returned, otherwise a newSubProgressMonitor
is 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:ProgressMonitorWrapper
This implementation of aProgressMonitor
method forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
beginTask
in interfaceProgressMonitor
- Overrides:
beginTask
in 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 isUNKNOWN
the 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:ProgressMonitorWrapper
This implementation of aProgressMonitor
method forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
done
in interfaceProgressMonitor
- Overrides:
done
in classProgressMonitorWrapper
- See Also:
ProgressMonitor.done()
-
internalWorked
public void internalWorked(double work)
Description copied from class:ProgressMonitorWrapper
This implementation of aProgressMonitor
method forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
internalWorked
in interfaceProgressMonitor
- Overrides:
internalWorked
in classProgressMonitorWrapper
- Parameters:
work
- the amount of work done- See Also:
ProgressMonitor.internalWorked(double)
-
setSubTaskName
public void setSubTaskName(String subTaskName)
Description copied from class:ProgressMonitorWrapper
This implementation of aProgressMonitor
method forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
setSubTaskName
in interfaceProgressMonitor
- Overrides:
setSubTaskName
in 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:ProgressMonitorWrapper
This implementation of aProgressMonitor
method forwards to the wrapped progress monitor. Clients may override this method to do additional processing.- Specified by:
worked
in interfaceProgressMonitor
- Overrides:
worked
in classProgressMonitorWrapper
- Parameters:
work
- the number of work units just completed- See Also:
ProgressMonitor.worked(int)
-
-