com.sodius.mdw.core.util.progress
Class SubProgressMonitor

java.lang.Object
  extended by com.sodius.mdw.core.util.progress.ProgressMonitorWrapper
      extended by com.sodius.mdw.core.util.progress.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.

This class may be instantiated or subclassed by clients.


Field Summary
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 to subTask should not have any effect.
 
Fields inherited from interface com.sodius.mdw.core.util.progress.ProgressMonitor
UNKNOWN
 
Constructor Summary
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
 void beginTask(String name, int totalWork)
          Notifies that the main task is beginning.
 void done()
          Notifies that the work is done; that is, either the main task is completed or the user canceled it.
 void internalWorked(double work)
          Internal method to handle scaling correctly.
 void subTask(String name)
          Notifies that a subtask of the main task is beginning.
 void worked(int work)
          Notifies that a given number of work unit of the main task has been completed.
 
Methods inherited from class com.sodius.mdw.core.util.progress.ProgressMonitorWrapper
getWrappedProgressMonitor, isCanceled, setCanceled, setTaskName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUPPRESS_SUBTASK_LABEL

public static final int SUPPRESS_SUBTASK_LABEL
Style constant indicating that calls to subTask should not have any effect.

See Also:
SubProgressMonitor(ProgressMonitor, int, int), Constant Field Values

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.

See Also:
SubProgressMonitor(ProgressMonitor, int, int), Constant Field Values
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

beginTask

public void beginTask(String name,
                      int totalWork)
Description copied from interface: ProgressMonitor
Notifies that the main task is beginning. This must only be called once on a given progress monitor instance.

Specified by:
beginTask in interface ProgressMonitor
Overrides:
beginTask in class ProgressMonitorWrapper
Parameters:
name - 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.

done

public void done()
Description copied from interface: ProgressMonitor
Notifies that the work is done; that is, either the main task is completed or the user canceled it. This method may be called more than once (implementations should be prepared to handle this case).

Specified by:
done in interface ProgressMonitor
Overrides:
done in class ProgressMonitorWrapper

internalWorked

public void internalWorked(double work)
Description copied from interface: ProgressMonitor
Internal method to handle scaling correctly. This method must not be called by a client. Clients should always use the method worked(int).

Specified by:
internalWorked in interface ProgressMonitor
Overrides:
internalWorked in class ProgressMonitorWrapper
Parameters:
work - the amount of work done

subTask

public void subTask(String name)
Description copied from interface: ProgressMonitor
Notifies that a subtask of the main task is beginning. Subtasks are optional; the main task might not have subtasks.

Specified by:
subTask in interface ProgressMonitor
Overrides:
subTask in class ProgressMonitorWrapper
Parameters:
name - the name (or description) of the subtask

worked

public void worked(int work)
Description copied from interface: ProgressMonitor
Notifies that a given number of work unit of the main task has been completed. Note that this amount represents an installment, as opposed to a cumulative amount of work done to date.

Specified by:
worked in interface ProgressMonitor
Overrides:
worked in class ProgressMonitorWrapper
Parameters:
work - the number of work units just completed