Revision 1719

View differences:

org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultJTasksStatusList.java
24 24
package org.gvsig.tools.swing.impl.task;
25 25

  
26 26
import java.awt.BorderLayout;
27
import java.awt.Component;
27 28
import java.awt.Dimension;
28 29
import java.util.ArrayList;
29 30
import java.util.HashMap;
30 31
import java.util.Iterator;
32
import java.util.LinkedHashMap;
31 33
import java.util.List;
32 34
import java.util.Map;
33 35
import java.util.Map.Entry;
......
56 58

  
57 59
    private static final long serialVersionUID = 7740032506050392725L;
58 60

  
59
    TaskStatusManager manager;
60
    Map<String, JTaskStatus> taskControls;
61
    JPanel listPanel;
61
    private TaskStatusManager manager;
62
    private Map<String, JTaskStatus> taskControls;
63
    private JPanel listPanel;
62 64

  
63 65
    public DefaultJTasksStatusList(TaskStatusManager manager) {
64 66
        this.manager = manager;
65
        this.taskControls = new HashMap<String, JTaskStatus>();
67
        this.taskControls = new LinkedHashMap<>();
66 68
        this.makeUI();
67 69
        this.manager.addObserver(this);
68 70
    }
69 71

  
72
    @Override
70 73
    public TaskStatusManager getManager() {
71 74
        return this.manager;
72 75
    }
......
80 83
        for (JTaskStatus taskStatus : controlsToAdd) {
81 84
            listPanel.add(taskStatus);
82 85
        }
83

  
86
        listPanel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
84 87
        JScrollPane scroller = new JScrollPane(listPanel);
88
        scroller.setAlignmentY(Component.BOTTOM_ALIGNMENT);
85 89
        scroller.setPreferredSize(new Dimension(300, 150));
86 90
        this.add(scroller, BorderLayout.CENTER);
87 91
    }
88 92

  
89 93
    private List<JTaskStatus> getControlsToAdd() {
90
        List<JTaskStatus> controlsToAdd = new ArrayList<JTaskStatus>();
94
        List<JTaskStatus> controlsToAdd = new ArrayList<>();
91 95
        TaskStatusSwingManager manager =
92 96
            ToolsSwingLocator.getTaskStatusSwingManager();
93 97

  
......
108 112
        return controlsToAdd;
109 113
    }
110 114

  
115
    @Override
111 116
    public void update(Observable observable, Object notification) {
112 117
        if (!(observable instanceof TaskStatusManager)) {
113 118
            return;
114 119
        }
115
        if (notification == null) {
120
        if (notification == null || this.manager.isEmpty() ) {
116 121
            // remove task
117
            Iterator<Entry<String, JTaskStatus>> taskStatusIterator =
118
                this.taskControls.entrySet().iterator();
119
            while (taskStatusIterator.hasNext()) {
120
                Entry<String, JTaskStatus> entry = taskStatusIterator.next();
121
                if (this.manager.get(entry.getKey()) == null) {
122
                    listPanel.remove(entry.getValue());
123
                }
124
            }
125
            listPanel.validate();
126
            return;
122
            listPanel.removeAll();
123
            this.taskControls.clear();
124
            listPanel.revalidate();
127 125
        }
128 126
        List<JTaskStatus> controlsToAdd = this.getControlsToAdd();
129
        for (JTaskStatus taskStatus : controlsToAdd) {
130
            listPanel.add(taskStatus);
127
        if( !controlsToAdd.isEmpty() ) {
128
            listPanel.removeAll();
129
            for (JTaskStatus taskStatus : this.taskControls.values()) {
130
                taskStatus.setAlignmentY(Component.BOTTOM_ALIGNMENT);
131
                listPanel.add(taskStatus);
132
            }
133
            listPanel.revalidate();
131 134
        }
132

  
133 135
    }
134 136
}
135 137

  
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/task/TaskStatusManager.java
72 72
	 */
73 73
	public Map getAll();
74 74

  
75
        public boolean isEmpty();
76
        
75 77
	/**
76 78
	 * Return a new code to a TaskStatus.
77 79
	 * 
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/task/impl/BaseTaskStatus.java
35 35
import org.slf4j.Logger;
36 36
import org.slf4j.LoggerFactory;
37 37

  
38

  
39 38
/**
40 39
 * @author gvSIG Team
41 40
 * @version $Id$
......
44 43
public class BaseTaskStatus implements SimpleTaskStatus {
45 44

  
46 45
    private static final Logger LOG = LoggerFactory
47
        .getLogger(BaseTaskStatus.class);
46
            .getLogger(BaseTaskStatus.class);
48 47

  
49 48
    protected class SubtaskValues {
50
		long minValue = 0;
49

  
50
        long minValue = 0;
51 51
        long maxValue = 0;
52 52
        long curValue = 0;
53 53
        String message = null;
54
        
55
        public Object clone() {
56
        	SubtaskValues other = new SubtaskValues();
57
        	other.curValue = this.curValue;
58
        	other.maxValue = this.maxValue;
59
        	other.minValue = this.minValue;
60
        	other.message = this.message;
61
        	return other;
54

  
55
        @Override
56
        public Object clone() throws CloneNotSupportedException {
57
            SubtaskValues other = new SubtaskValues();
58
            other.curValue = this.curValue;
59
            other.maxValue = this.maxValue;
60
            other.minValue = this.minValue;
61
            other.message = this.message;
62
            return other;
62 63
        }
63 64
    }
64
    
65

  
65 66
    protected Date lastModification = null;
66 67

  
67 68
    protected SubtaskValues values;
68
    protected List subtaskStack = null ;
69
    
69
    protected List subtaskStack = null;
70

  
70 71
    protected String title = null;
71 72
    protected String code = null;
72
    
73

  
73 74
    protected boolean isCancelled = false;
74 75
    protected boolean isAbortedByError = false;
75 76
    protected boolean isRunning = true;
76
    
77

  
77 78
    protected TaskStatusManager manager = null;
78 79

  
79
	protected boolean isCancellable;
80
    protected boolean isCancellable;
80 81

  
81
	protected boolean isCancellationRequested;
82
    protected boolean isCancellationRequested;
82 83

  
83
	protected ObservableHelper observers = null;
84
    protected ObservableHelper observers = null;
84 85

  
85
	protected boolean autoremove;
86
    protected boolean autoremove;
86 87

  
87 88
    private long startMillis;
88
    
89

  
90
    @SuppressWarnings("OverridableMethodCallInConstructor")
89 91
    public BaseTaskStatus(String title) {
90
    	this.manager =  ToolsLocator.getTaskStatusManager();
91
    	this.autoremove = true;
92
        this.manager = ToolsLocator.getTaskStatusManager();
93
        this.autoremove = true;
92 94
        this.title = title;
93 95
        this.values = new SubtaskValues();
94 96
        this.isCancelled = false;
......
100 102
        this.observers = new ObservableHelper();
101 103
        this.touch();
102 104
    }
103
    
105

  
104 106
    public BaseTaskStatus(String tittle, long minValue, long maxValue) {
105
    	this(tittle);
107
        this(tittle);
106 108
        this.values.minValue = minValue;
107 109
        this.values.maxValue = maxValue;
108 110
    }
109 111

  
110 112
    @Override
111 113
    public void restart() {
112
    	this.autoremove = true;
114
        this.autoremove = true;
113 115
        this.values = new SubtaskValues();
114 116
        this.isCancelled = false;
115 117
        this.isAbortedByError = false;
......
118 120
        this.isCancellationRequested = false;
119 121
        this.touch();
120 122
    }
121
    
123

  
122 124
    @Override
123 125
    public void setRangeOfValues(long min, long max) {
124 126
        this.values.minValue = min;
125 127
        this.values.maxValue = max;
126 128
    }
127
    
129

  
128 130
    protected void touch() {
129 131
        touch(true);
130 132
    }
131 133

  
132 134
    protected void touch(boolean clearmsg) {
133
    	Date now = new Date();
134
        if( clearmsg ) {
135
            if( this.lastModification!=null && (now.getTime() - this.lastModification.getTime()) > 4000 ) {
136
                    this.values.message = null;
135
        Date now = new Date();
136
        if (clearmsg) {
137
            if (this.lastModification != null && (now.getTime() - this.lastModification.getTime()) > 4000) {
138
                this.values.message = null;
137 139
            }
138 140
        }
139 141
        this.lastModification = now;
140 142
        this.notifyObservers();
141 143
    }
142
    
144

  
143 145
    protected void notifyObservers() {
144 146
        this.manager.update(this);
145 147
        this.observers.notifyObservers(this, null);
146 148
    }
147
    
149

  
150
    @Override
148 151
    public Date getLastModification() {
149
    	return this.lastModification;
152
        return this.lastModification;
150 153
    }
151
    
154

  
155
    @Override
152 156
    public void message(String message) {
153
    	this.values.message = message;
154
    	this.touch(false);
157
        this.values.message = message;
158
        this.touch(false);
155 159
    }
156
    
160

  
161
    @Override
157 162
    public String getTitle() {
158 163
        return this.title;
159 164
    }
160 165

  
166
    @Override
161 167
    public String getCode() {
162 168
        return this.code;
163 169
    }
164 170

  
171
    @Override
165 172
    public void setCurValue(long value) {
166 173
        //LOG.debug("setCurValue: '"+value+"'.");
167 174
        this.values.curValue = value;
168
        this.touch();
175
        this.touch(false);
169 176
    }
170
    
177

  
178
    @Override
171 179
    public int getCompleted() {
172
        if( !this.isRunning ) {
180
        if (!this.isRunning) {
173 181
            return 100;
174 182
        }
175
        if( this.values.maxValue == this.values.minValue ) {
176
        	// No se puede calcular ya que no se ha indicado el numero de elementos
177
        	// sobre los que se esta trabajando, asi que devoobemos el 100%.
178
        	return 100;
183
        if (this.values.maxValue == this.values.minValue) {
184
            // No se puede calcular ya que no se ha indicado el numero de elementos
185
            // sobre los que se esta trabajando, asi que devoobemos el 100%.
186
            return 100;
179 187
        }
180 188
        try {
181
            return (int) (((this.values.curValue-this.values.minValue)*100)/(this.values.maxValue-this.values.minValue));
182
        } catch( Exception e) {
189
            return (int) (((this.values.curValue - this.values.minValue) * 100) / (this.values.maxValue - this.values.minValue));
190
        } catch (Exception e) {
183 191
            return 100;
184 192
        }
185 193
    }
186 194

  
195
    @Override
187 196
    public String getLabel() {
188
    	String progress;
189
    	
190
        if( this.values.maxValue == this.values.minValue ) {
191
        	// No se puede calcular ya que no se ha indicado el numero de elementos
192
        	// sobre los que se esta trabajando.
193
        	if( this.values.curValue > 0 ) {
194
        		progress = " (" + this.values.curValue + ")";
195
        	} else {
196
        		progress = "";
197
        	}
197
        String progress;
198

  
199
        if (this.values.maxValue == this.values.minValue) {
200
            // No se puede calcular ya que no se ha indicado el numero de elementos
201
            // sobre los que se esta trabajando.
202
            if (this.values.curValue > 0) {
203
                progress = " (" + this.values.curValue + ")";
204
            } else {
205
                progress = "";
206
            }
198 207
        } else {
199
            progress = " (" + (this.values.curValue-this.values.minValue) + " / " + (this.values.maxValue-this.values.minValue) + ")" ;
208
            progress = " (" + (this.values.curValue - this.values.minValue) + " / " + (this.values.maxValue - this.values.minValue) + ")";
200 209
        }
201
    	if( this.values.message == null ) {
210
        if (this.values.message == null) {
202 211
            return progress;
203
    	} else {
212
        } else {
204 213
            return this.values.message + progress;
205
    	}
214
        }
206 215
    }
207 216

  
217
    @Override
208 218
    public void terminate() {
209
    	if( !isRunning ) {
210
    		return;
211
    	}
219
        if (!isRunning) {
220
            return;
221
        }
212 222
        this.isRunning = false;
213 223
        if (LOG.isDebugEnabled()) {
214 224
            long endMillis = System.currentTimeMillis();
215
            LOG.debug("Terminated status {} execution in {} ms", getTitle(),
216
                new Long(endMillis - startMillis));
225
            LOG.debug("Terminated status {} execution in {} ms", getTitle(), endMillis - startMillis);
217 226
        }
218 227
        this.touch();
228
        if (this.autoremove) {
229
            this.remove();
230
        }
219 231
    }
220
    
232

  
233
    @Override
221 234
    public void cancel() {
222
    	if( !isRunning ) {
223
    		return;
224
    	}
235
        if (!isRunning) {
236
            return;
237
        }
225 238
        this.isCancelled = true;
226 239
        this.isRunning = false;
227 240
        this.touch();
241
        if (this.autoremove) {
242
            this.remove();
243
        }
228 244
    }
229 245

  
246
    @Override
230 247
    public void abort() {
231
    	if( !isRunning ) {
232
    		return;
233
    	}
248
        if (!isRunning) {
249
            return;
250
        }
234 251
        this.isAbortedByError = true;
235 252
        this.isRunning = false;
236 253
        this.touch();
254
        if (this.autoremove) {
255
            this.remove();
256
        }
237 257
    }
238
    
258

  
259
    @Override
239 260
    public boolean isCancelled() {
240 261
        return this.isCancelled;
241 262
    }
242 263

  
264
    @Override
243 265
    public boolean isAborted() {
244 266
        return this.isAbortedByError;
245 267
    }
246 268

  
269
    @Override
247 270
    public boolean isRunning() {
248 271
        return this.isRunning;
249 272
    }
250 273

  
251
	public TaskStatusManager getManager() {
252
		return this.manager;
253
	}
274
    @Override
275
    public TaskStatusManager getManager() {
276
        return this.manager;
277
    }
254 278

  
255
	public boolean isIndeterminate() {
256
		return this.values.minValue == this.values.maxValue;
257
	}
279
    @Override
280
    public boolean isIndeterminate() {
281
        return this.values.minValue == this.values.maxValue;
282
    }
258 283

  
259
	public void add() {
260
		this.manager.add(this);
284
    @Override
285
    public void add() {
286
        this.manager.add(this);
261 287
        if (LOG.isDebugEnabled()) {
262 288
            startMillis = System.currentTimeMillis();
263 289
        }
264
	}
290
    }
265 291

  
266
	public void remove() {
267
		this.manager.remove(this);
268
	}
292
    @Override
293
    public void remove() {
294
        this.manager.remove(this);
295
    }
269 296

  
270
	public boolean isCancellable() {
271
		return this.isCancellable;
272
	}
297
    @Override
298
    public boolean isCancellable() {
299
        return this.isCancellable;
300
    }
273 301

  
274
	public void setCancellable(boolean cancellable) {
275
		this.isCancellable = cancellable;
276
	}
302
    @Override
303
    public void setCancellable(boolean cancellable) {
304
        this.isCancellable = cancellable;
305
    }
277 306

  
278
	synchronized public boolean isCancellationRequested() {
279
		return this.isCancellationRequested;
280
	}
307
    @Override
308
    synchronized public boolean isCancellationRequested() {
309
        return this.isCancellationRequested;
310
    }
281 311

  
282
	synchronized public void cancelRequest() {
283
		this.isCancellationRequested = true;
284
	}
312
    @Override
313
    synchronized public void cancelRequest() {
314
        this.isCancellationRequested = true;
315
    }
285 316

  
286
	synchronized public void addObserver(Observer o) {
287
		this.observers.addObserver(o);
288
	}
317
    @Override
318
    synchronized public void addObserver(Observer o) {
319
        this.observers.addObserver(o);
320
    }
289 321

  
290
	synchronized public void deleteObserver(Observer o) {
291
		this.observers.deleteObserver(o);
292
	}
322
    @Override
323
    synchronized public void deleteObserver(Observer o) {
324
        this.observers.deleteObserver(o);
325
    }
293 326

  
294
	synchronized public void deleteObservers() {
295
		this.observers.deleteObservers();
296
	}
327
    @Override
328
    synchronized public void deleteObservers() {
329
        this.observers.deleteObservers();
330
    }
297 331

  
298
	public void setTittle(String tittle) {
332
    @Override
333
    public void setTittle(String tittle) {
299 334
        setTitle(tittle);
300 335
    }
301 336

  
337
    @Override
302 338
    public void setTitle(String title) {
303 339
        if (this.title != null) {
304 340
            return;
......
306 342
        this.title = title;
307 343
    }
308 344

  
309
	public void setAutoremove(boolean autoremove) {
310
		this.autoremove = autoremove;
311
	}
345
    @Override
346
    public void setAutoremove(boolean autoremove) {
347
        this.autoremove = autoremove;
348
    }
312 349

  
313
	public boolean getAutoRemove() {
314
		return this.autoremove;
315
	}
350
    @Override
351
    public boolean getAutoRemove() {
352
        return this.autoremove;
353
    }
316 354

  
317
	public void push() {
318
		if( this.subtaskStack == null ) {
319
			this.subtaskStack = new ArrayList();
320
		}
321
		this.subtaskStack.add(0, this.values);
322
		this.values = (SubtaskValues) this.values.clone();
323
	}
355
    @Override
356
    public void push() {
357
        if (this.subtaskStack == null) {
358
            this.subtaskStack = new ArrayList();
359
        }
360
        this.subtaskStack.add(0, this.values);
361
        try {
362
            this.values = (SubtaskValues) this.values.clone();
363
        } catch (CloneNotSupportedException ex) {
364
        }
365
    }
324 366

  
325
	public void pop() {
326
		if( this.subtaskStack == null && this.subtaskStack.isEmpty() ) {
327
			return;
328
		}
329
		this.values = (SubtaskValues) this.subtaskStack.get(0);
330
		this.subtaskStack.remove(0);
331
		touch();
332
	}
367
    @Override
368
    public void pop() {
369
        if (this.subtaskStack == null && this.subtaskStack.isEmpty()) {
370
            return;
371
        }
372
        this.values = (SubtaskValues) this.subtaskStack.get(0);
373
        this.subtaskStack.remove(0);
374
        touch();
375
    }
333 376

  
334
	public void setIndeterminate() {
335
		this.values.maxValue = 0;
336
		this.values.minValue = 0;
337
		this.values.curValue = 0;
338
	}
377
    @Override
378
    public void setIndeterminate() {
379
        this.values.maxValue = 0;
380
        this.values.minValue = 0;
381
        this.values.curValue = 0;
382
    }
339 383

  
340 384
}
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/task/impl/DefaultTaskStatusManager.java
37 37
/**
38 38
 * @author gvSIG Team
39 39
 * @version $Id$
40
 * 
40
 *
41 41
 */
42 42
public class DefaultTaskStatusManager implements TaskStatusManager {
43 43

  
44
	private static final int MAXTASKS_TO_AUTOREMOVE = 15;
44
    private static final int MAXTASKS_TO_AUTOREMOVE = 15;
45 45

  
46
	private static long codeCounter = 1;
46
    private static long codeCounter = 1;
47 47

  
48
	private Map tasksStatus = null;
49
	private ObservableHelper observers = null;
48
    private Map tasksStatus = null;
49
    private ObservableHelper observers = null;
50 50

  
51
	public DefaultTaskStatusManager() {
52
		this.tasksStatus = new LinkedHashMap();
53
		this.observers = new ObservableHelper();
54
	}
51
    public DefaultTaskStatusManager() {
52
        this.tasksStatus = new LinkedHashMap();
53
        this.observers = new ObservableHelper();
54
    }
55 55

  
56
	synchronized public void add(TaskStatus taskStatus) {
57
		this.tasksStatus.put(taskStatus.getCode(), taskStatus);
58
		this.update(taskStatus);
59
	}
56
    @Override
57
    synchronized public void add(TaskStatus taskStatus) {
58
        this.tasksStatus.put(taskStatus.getCode(), taskStatus);
59
        this.update(taskStatus);
60
    }
60 61

  
61
	synchronized public TaskStatus get(String code) {
62
		return (TaskStatus) (this.tasksStatus.get(code));
63
	}
62
    @Override
63
    synchronized public TaskStatus get(String code) {
64
        return (TaskStatus) (this.tasksStatus.get(code));
65
    }
64 66

  
65
	synchronized public void remove(String code) {
66
		this.tasksStatus.remove(code);
67
		this.update((TaskStatus) this.tasksStatus.get(code));
68
	}
67
    @Override
68
    synchronized public void remove(String code) {
69
        this.tasksStatus.remove(code);
70
        this.update((TaskStatus) this.tasksStatus.get(code));
71
    }
69 72

  
70
	synchronized public void remove(TaskStatus taskStatus) {
71
		this.tasksStatus.remove(taskStatus.getCode());
72
		this.update(null);
73
	}
73
    @Override
74
    synchronized public void remove(TaskStatus taskStatus) {
75
        this.tasksStatus.remove(taskStatus.getCode());
76
        this.update(null);
77
    }
74 78

  
75
	public String getNewCode() {
76
		return Long.toBinaryString(codeCounter++);
77
	}
79
    @Override
80
    public String getNewCode() {
81
        return Long.toBinaryString(codeCounter++);
82
    }
78 83

  
79
	synchronized public Map getAll() {
80
		return Collections.unmodifiableMap(this.tasksStatus);
81
	}
84
    @Override
85
    synchronized public Map getAll() {
86
        return Collections.unmodifiableMap(this.tasksStatus);
87
    }
82 88

  
83
	synchronized public void addObserver(Observer o) {
84
		this.observers.addObserver(o);
85
	}
89
    @Override
90
    synchronized public boolean isEmpty() {
91
        return this.tasksStatus.isEmpty();
92
    }
86 93

  
87
	synchronized public void deleteObserver(Observer o) {
88
		this.observers.deleteObserver(o);
89
	}
94
    @Override
95
    synchronized public void addObserver(Observer o) {
96
        this.observers.addObserver(o);
97
    }
90 98

  
91
	synchronized public void deleteObservers() {
92
		this.observers.deleteObservers();
93
	}
99
    @Override
100
    synchronized public void deleteObserver(Observer o) {
101
        this.observers.deleteObserver(o);
102
    }
94 103

  
95
	synchronized public void update(TaskStatus taskstatus) {
96
		if (taskstatus != null
97
				&& this.tasksStatus.get(taskstatus.getCode()) == null) {
98
			// This TaskStatus not is registered in this manager.
99
			return;
100
		}
101
		this.observers.notifyObservers(this, taskstatus);
102
		if (taskstatus != null) {
103
			if (!taskstatus.isRunning()) {
104
				if (taskstatus instanceof SimpleTaskStatus) {
105
					if (((SimpleTaskStatus) taskstatus).getAutoRemove()) {
106
						if (this.tasksStatus.size() > MAXTASKS_TO_AUTOREMOVE) {
107
							((SimpleTaskStatus) taskstatus).remove();
108
						}
109
					}
110
				}
111
			}
112
		}
113
	}
104
    @Override
105
    synchronized public void deleteObservers() {
106
        this.observers.deleteObservers();
107
    }
114 108

  
115
	public SimpleTaskStatus creteDefaultSimpleTaskStatus(String tittle) {
109
    @Override
110
    synchronized public void update(TaskStatus taskstatus) {
111
        if (taskstatus != null
112
                && this.tasksStatus.get(taskstatus.getCode()) == null) {
113
            // This TaskStatus not is registered in this manager.
114
            return;
115
        }
116
        this.observers.notifyObservers(this, taskstatus);
117
        if (taskstatus != null) {
118
            if (!taskstatus.isRunning()) {
119
                if (taskstatus instanceof SimpleTaskStatus) {
120
                    if (((SimpleTaskStatus) taskstatus).getAutoRemove()) {
121
                        if (this.tasksStatus.size() > MAXTASKS_TO_AUTOREMOVE) {
122
                            ((SimpleTaskStatus) taskstatus).remove();
123
                        }
124
                    }
125
                }
126
            }
127
        }
128
    }
129

  
130
    @Override
131
    public SimpleTaskStatus creteDefaultSimpleTaskStatus(String tittle) {
116 132
        return createDefaultSimpleTaskStatus(tittle);
117 133
    }
118 134

  
135
    @Override
119 136
    public SimpleTaskStatus createDefaultSimpleTaskStatus(String title) {
120 137
        return new BaseTaskStatus(title);
121
	}
138
    }
122 139

  
123
	synchronized public TaskStatus getRunningTaskStatusMostRecent() {
124
		TaskStatus mostRecent = null;
125
		Iterator taskStatusIterator = this.tasksStatus.values().iterator();
126
		while( taskStatusIterator.hasNext() ) {
127
			TaskStatus current = (TaskStatus) taskStatusIterator.next();
128
			if ( current.isRunning() ) {
129
				if( mostRecent==null || current.getLastModification().compareTo(mostRecent.getLastModification())>0 ) {
130
					mostRecent = current;
131
				}
132
			}
133
		}
134
		return mostRecent;
135
	}
140
    @Override
141
    synchronized public TaskStatus getRunningTaskStatusMostRecent() {
142
        TaskStatus mostRecent = null;
143
        Iterator taskStatusIterator = this.tasksStatus.values().iterator();
144
        while (taskStatusIterator.hasNext()) {
145
            TaskStatus current = (TaskStatus) taskStatusIterator.next();
146
            if (current.isRunning()) {
147
                if (mostRecent == null || current.getLastModification().compareTo(mostRecent.getLastModification()) > 0) {
148
                    mostRecent = current;
149
                }
150
            }
151
        }
152
        return mostRecent;
153
    }
136 154

  
137 155
}

Also available in: Unified diff