Revision 2607 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/task/impl/BaseTaskStatus.java
BaseTaskStatus.java | ||
---|---|---|
26 | 26 |
import java.util.ArrayList; |
27 | 27 |
import java.util.Date; |
28 | 28 |
import java.util.List; |
29 |
import org.apache.commons.lang3.StringUtils; |
|
29 | 30 |
|
30 | 31 |
import org.gvsig.tools.ToolsLocator; |
31 | 32 |
import org.gvsig.tools.observer.ObservableHelper; |
... | ... | |
51 | 52 |
long maxValue = 0; |
52 | 53 |
long curValue = 0; |
53 | 54 |
String message = null; |
55 |
boolean isRunning = true; |
|
54 | 56 |
|
55 | 57 |
@Override |
56 | 58 |
public Object clone() throws CloneNotSupportedException { |
... | ... | |
59 | 61 |
other.maxValue = this.maxValue; |
60 | 62 |
other.minValue = this.minValue; |
61 | 63 |
other.message = this.message; |
64 |
other.isRunning = this.isRunning; |
|
62 | 65 |
return other; |
63 | 66 |
} |
64 | 67 |
} |
... | ... | |
73 | 76 |
|
74 | 77 |
protected boolean isCancelled = false; |
75 | 78 |
protected boolean isAbortedByError = false; |
76 |
protected boolean isRunning = true; |
|
77 | 79 |
|
78 | 80 |
protected TaskStatusManager manager = null; |
79 | 81 |
|
... | ... | |
95 | 97 |
this.values = new SubtaskValues(); |
96 | 98 |
this.isCancelled = false; |
97 | 99 |
this.isAbortedByError = false; |
98 |
this.isRunning = true; |
|
99 | 100 |
this.isCancellable = false; |
100 | 101 |
this.isCancellationRequested = false; |
101 | 102 |
this.code = this.manager.getNewCode(); |
... | ... | |
115 | 116 |
this.values = new SubtaskValues(); |
116 | 117 |
this.isCancelled = false; |
117 | 118 |
this.isAbortedByError = false; |
118 |
this.isRunning = true; |
|
119 | 119 |
this.isCancellable = false; |
120 | 120 |
this.isCancellationRequested = false; |
121 | 121 |
this.touch(); |
... | ... | |
183 | 183 |
|
184 | 184 |
@Override |
185 | 185 |
public int getCompleted() { |
186 |
if (!this.isRunning) { |
|
186 |
if (!this.values.isRunning) {
|
|
187 | 187 |
return 100; |
188 | 188 |
} |
189 | 189 |
if (this.values.maxValue == this.values.minValue) { |
... | ... | |
226 | 226 |
|
227 | 227 |
@Override |
228 | 228 |
public void terminate() { |
229 |
if (!isRunning) { |
|
229 |
if (!this.values.isRunning) {
|
|
230 | 230 |
return; |
231 | 231 |
} |
232 |
this.isRunning = false; |
|
232 |
this.values.isRunning = false;
|
|
233 | 233 |
if (LOG.isDebugEnabled()) { |
234 | 234 |
long endMillis = System.currentTimeMillis(); |
235 | 235 |
LOG.debug("Terminated status {} execution in {} ms", getTitle(), endMillis - startMillis); |
236 | 236 |
} |
237 | 237 |
this.touch(); |
238 |
if (this.autoremove) { |
|
238 |
if (this.autoremove && (this.subtaskStack==null || this.subtaskStack.isEmpty()) ) {
|
|
239 | 239 |
this.remove(); |
240 | 240 |
} |
241 | 241 |
} |
242 | 242 |
|
243 | 243 |
@Override |
244 | 244 |
public void cancel() { |
245 |
if (!isRunning) { |
|
245 |
if (!values.isRunning) {
|
|
246 | 246 |
return; |
247 | 247 |
} |
248 | 248 |
this.isCancelled = true; |
249 |
this.isRunning = false; |
|
249 |
this.values.isRunning = false;
|
|
250 | 250 |
this.touch(); |
251 |
if (this.autoremove) { |
|
251 |
if (this.autoremove && (this.subtaskStack==null || this.subtaskStack.isEmpty()) ) {
|
|
252 | 252 |
this.remove(); |
253 | 253 |
} |
254 | 254 |
} |
255 | 255 |
|
256 | 256 |
@Override |
257 | 257 |
public void abort() { |
258 |
if (!isRunning) { |
|
258 |
if (!values.isRunning) {
|
|
259 | 259 |
return; |
260 | 260 |
} |
261 | 261 |
this.isAbortedByError = true; |
262 |
this.isRunning = false; |
|
263 |
this.touch(false); |
|
264 |
if (this.autoremove) { |
|
262 |
this.values.isRunning = false;
|
|
263 |
this.touch(false); ;
|
|
264 |
if (this.autoremove && (this.subtaskStack==null || this.subtaskStack.isEmpty()) ) {
|
|
265 | 265 |
this.remove(); |
266 | 266 |
} |
267 | 267 |
} |
... | ... | |
278 | 278 |
|
279 | 279 |
@Override |
280 | 280 |
public boolean isRunning() { |
281 |
return this.isRunning; |
|
281 |
return this.values.isRunning;
|
|
282 | 282 |
} |
283 | 283 |
|
284 | 284 |
@Override |
... | ... | |
349 | 349 |
|
350 | 350 |
@Override |
351 | 351 |
public void setTitle(String title) { |
352 |
if (this.title != null) { |
|
353 |
return; |
|
352 |
// if (this.title != null) { |
|
353 |
// return; |
|
354 |
// } |
|
355 |
if( !StringUtils.equals(title, this.title)) { |
|
356 |
this.title = title; |
|
357 |
this.touch(false); |
|
354 | 358 |
} |
355 |
this.title = title; |
|
356 | 359 |
} |
357 | 360 |
|
358 | 361 |
@Override |
Also available in: Unified diff