public class SubProgressMonitor extends ProgressMonitorDelegator
ProgressMonitor
.
The whole class is a copy of the Eclipse SubProgressMonitor.
try { pm.beginTask("Main Task", 100); doSomeWork(pm, 30); SubProgressMonitor subMonitor= new SubProgressMonitor(pm, 40); try { subMonitor.beginTask("", 300); doSomeWork(subMonitor, 300); } finally { subMonitor.done(); } doSomeWork(pm, 30); } finally { pm.done(); }
This class can be used without OSGi running.
This class may be instantiated or subclassed by clients.
Modifier and Type | Field and 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 to
subTask
should not have any effect. |
Constructor and Description |
---|
SubProgressMonitor(ProgressMonitor wrappedMonitor,
int ticks)
Creates a new sub-progress monitor for the given monitor.
|
SubProgressMonitor(ProgressMonitor wrappedMonitor,
int ticks,
int style)
Creates a new sub-progress monitor for the given monitor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
isCanceled, setCanceled, setTaskName
public static final int SUPPRESS_SUBTASK_LABEL
subTask
should not have any effect.#SubProgressMonitor(IProgressMonitor,int,int)
,
Constant Field Valuespublic static final int PREPEND_MAIN_LABEL_TO_SUBTASK
#SubProgressMonitor(IProgressMonitor,int,int)
,
Constant Field Valuespublic SubProgressMonitor(ProgressMonitor wrappedMonitor, int ticks)
monitor
- the parent progress monitorticks
- the number of work ticks allocated from the
parent monitorpublic SubProgressMonitor(ProgressMonitor wrappedMonitor, int ticks, int style)
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
SUPPRESS_SUBTASK_LABEL
,
PREPEND_MAIN_LABEL_TO_SUBTASK
public void beginTask(String name, int totalWork)
ProgressMonitor
beginTask
in interface ProgressMonitor
beginTask
in class ProgressMonitorDelegator
name
- 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 is UNKNOWN
the implementation is free to indicate progress in a way which
doesn't require the total number of work units in advance.public void done()
ProgressMonitor
done
in interface ProgressMonitor
done
in class ProgressMonitorDelegator
public void internalWorked(double work)
ProgressMonitor
Note: EclipseRCP is strange!
internalWorked
in interface ProgressMonitor
internalWorked
in class ProgressMonitorDelegator
work
- the amount of work donepublic void subTask(String name)
ProgressMonitor
subTask
in interface ProgressMonitor
subTask
in class ProgressMonitorDelegator
name
- the name (or description) of the subtaskpublic void worked(int work)
ProgressMonitor
worked
in interface ProgressMonitor
worked
in class ProgressMonitorDelegator
work
- the number of work units just completedCopyright © 2013-2014. All Rights Reserved.