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 Details

  • Constructor Details

    • 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 monitor
      ticks - 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 monitor
      ticks - the number of work ticks allocated from the parent monitor
      style - one of
      • SUPPRESS_SUBTASK_LABEL
      • PREPEND_MAIN_LABEL_TO_SUBTASK
      See Also:
  • Method Details

    • create

      public static ProgressMonitor create(ProgressMonitor monitor, int ticks)
      Creates a progress monitor based on the passed in parent monitor. If the parent monitor is ProgressMonitor.NULL, monitor is returned, otherwise a new SubProgressMonitor is created.
      Parameters:
      monitor - the parent progress monitor
      ticks - 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 is ProgressMonitor.NULL, monitor is returned, otherwise a new SubProgressMonitor is created. In contrast to the monitor returned by create(ProgressMonitor, int) this one can be considered to be thread-safe.
      Parameters:
      monitor - the parent progress monitor
      ticks - 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 a ProgressMonitor method forwards to the wrapped progress monitor. Clients may override this method to do additional processing.
      Specified by:
      beginTask in interface ProgressMonitor
      Overrides:
      beginTask in class ProgressMonitorWrapper
      Parameters:
      taskName - the name (or description) of the main task
      totalWork - 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.
      See Also:
    • done

      public void done()
      Description copied from class: ProgressMonitorWrapper
      This implementation of a ProgressMonitor method forwards to the wrapped progress monitor. Clients may override this method to do additional processing.
      Specified by:
      done in interface ProgressMonitor
      Overrides:
      done in class ProgressMonitorWrapper
      See Also:
    • internalWorked

      public void internalWorked(double work)
      Description copied from class: ProgressMonitorWrapper
      This implementation of a ProgressMonitor method forwards to the wrapped progress monitor. Clients may override this method to do additional processing.
      Specified by:
      internalWorked in interface ProgressMonitor
      Overrides:
      internalWorked in class ProgressMonitorWrapper
      Parameters:
      work - the amount of work done
      See Also:
    • setSubTaskName

      public void setSubTaskName(String subTaskName)
      Description copied from class: ProgressMonitorWrapper
      This implementation of a ProgressMonitor method forwards to the wrapped progress monitor. Clients may override this method to do additional processing.
      Specified by:
      setSubTaskName in interface ProgressMonitor
      Overrides:
      setSubTaskName in class ProgressMonitorWrapper
      Parameters:
      subTaskName - the name (or description) of the subtask
      See Also:
    • worked

      public void worked(int work)
      Description copied from class: ProgressMonitorWrapper
      This implementation of a ProgressMonitor method forwards to the wrapped progress monitor. Clients may override this method to do additional processing.
      Specified by:
      worked in interface ProgressMonitor
      Overrides:
      worked in class ProgressMonitorWrapper
      Parameters:
      work - the number of work units just completed
      See Also: