1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.progress;
|
---|
3 |
|
---|
4 | import java.awt.Component;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * The progress of a sub task
|
---|
8 | */
|
---|
9 | public class ChildProgress extends AbstractProgressMonitor {
|
---|
10 |
|
---|
11 | private final AbstractProgressMonitor parent;
|
---|
12 | private final boolean internal;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Creates a new {@link ChildProgress}
|
---|
16 | * @param parent The parent task that creates this progress
|
---|
17 | * @param cancelHandler The cancel handler to notify when this task is canceled
|
---|
18 | * @param internal this is an internal task that will not modify the text that is displayed to the user
|
---|
19 | */
|
---|
20 | public ChildProgress(AbstractProgressMonitor parent, CancelHandler cancelHandler, boolean internal) {
|
---|
21 | super(cancelHandler);
|
---|
22 | this.parent = parent;
|
---|
23 | this.internal = internal;
|
---|
24 | }
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Gets the parent task
|
---|
28 | * @return The parent task
|
---|
29 | */
|
---|
30 | public final AbstractProgressMonitor getParent() {
|
---|
31 | return parent;
|
---|
32 | }
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * See if this is an internal task
|
---|
36 | * @return True if this task should not modify the text that is displayed to the user
|
---|
37 | */
|
---|
38 | public final boolean isInternal() {
|
---|
39 | return internal;
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override
|
---|
43 | protected void updateProgress(double value) {
|
---|
44 | parent.childSetProgress(this, value);
|
---|
45 | }
|
---|
46 |
|
---|
47 | @Override
|
---|
48 | protected void doBeginTask() {
|
---|
49 | // Do nothing
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | protected void doSetCustomText(String title) {
|
---|
54 | if (!internal) {
|
---|
55 | parent.childSetCustomText(this, title);
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | @Override
|
---|
60 | protected void doSetTitle(String title) {
|
---|
61 | if (!internal) {
|
---|
62 | parent.childSetTitle(this, title);
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Override
|
---|
67 | protected void doSetIntermediate(boolean value) {
|
---|
68 | if (!internal) {
|
---|
69 | parent.childSetIntermediate(this, value);
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | @Override
|
---|
74 | protected void doFinishTask() {
|
---|
75 | parent.childFinished(this);
|
---|
76 | }
|
---|
77 |
|
---|
78 | @Override
|
---|
79 | public void setProgressTaskId(ProgressTaskId taskId) {
|
---|
80 | parent.setProgressTaskId(taskId);
|
---|
81 | }
|
---|
82 |
|
---|
83 | @Override
|
---|
84 | public ProgressTaskId getProgressTaskId() {
|
---|
85 | return parent.getProgressTaskId();
|
---|
86 | }
|
---|
87 |
|
---|
88 | @Override
|
---|
89 | public Component getWindowParent() {
|
---|
90 | return parent.getWindowParent();
|
---|
91 | }
|
---|
92 | }
|
---|