Class 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.

    • 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 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:
        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 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:
        ProgressMonitor.beginTask(String, int)