svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.utils / src / main / java / org / gvsig / utils / swing / threads / TaskMonitorTimerListener.java @ 40561
History | View | Annotate | Download (2.5 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/* CVS MESSAGES:
|
25 |
*
|
26 |
* $Id: TaskMonitorTimerListener.java 29631 2009-06-29 16:56:19Z jpiera $
|
27 |
* $Log$
|
28 |
* Revision 1.4 2006-11-13 20:46:37 azabala
|
29 |
* *** empty log message ***
|
30 |
*
|
31 |
* Revision 1.3 2006/11/06 07:29:59 jaume
|
32 |
* organize imports
|
33 |
*
|
34 |
* Revision 1.2 2006/03/14 19:24:07 azabala
|
35 |
* *** empty log message ***
|
36 |
*
|
37 |
* Revision 1.1 2006/03/07 21:00:29 azabala
|
38 |
* *** empty log message ***
|
39 |
*
|
40 |
*
|
41 |
*/
|
42 |
package org.gvsig.utils.swing.threads; |
43 |
|
44 |
import java.awt.event.ActionEvent; |
45 |
import java.awt.event.ActionListener; |
46 |
|
47 |
import javax.swing.Timer; |
48 |
|
49 |
/**
|
50 |
* It receives timer events sended by a swing Timer and does:
|
51 |
* a) Reads task advances from a IMonitorableTask.
|
52 |
* b) refresh task status info of a ProgressMonitor.
|
53 |
* @author azabala
|
54 |
*
|
55 |
*/
|
56 |
public class TaskMonitorTimerListener implements ActionListener { |
57 |
private IProgressMonitorIF progressMonitor;
|
58 |
private IMonitorableTask task;
|
59 |
private Timer timer; |
60 |
|
61 |
public TaskMonitorTimerListener(IProgressMonitorIF progressMonitor,
|
62 |
IMonitorableTask task){ |
63 |
this.progressMonitor = progressMonitor;
|
64 |
this.task = task;
|
65 |
} |
66 |
|
67 |
public void setTimer(Timer timer){ |
68 |
this.timer = timer;
|
69 |
} |
70 |
|
71 |
public void actionPerformed(ActionEvent arg0) { |
72 |
int currentStep = task.getCurrentStep();
|
73 |
String statusNote = task.getNote();
|
74 |
progressMonitor.setCurrentStep(currentStep); |
75 |
progressMonitor.setNote(statusNote); |
76 |
if(progressMonitor.isCanceled()){
|
77 |
progressMonitor.close(); |
78 |
task.cancel(); |
79 |
timer.stop(); |
80 |
} |
81 |
if (task.isFinished()) {
|
82 |
progressMonitor.close(); |
83 |
timer.stop(); |
84 |
} |
85 |
} |
86 |
|
87 |
} |
88 |
|