Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_897 / libraries / libIverUtiles / src / com / iver / utiles / swing / threads / TaskMonitorTimerListener.java @ 10444

History | View | Annotate | Download (2.81 KB)

1
/*
2
 * Created on 06-mar-2006
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: TaskMonitorTimerListener.java 10444 2007-02-21 09:20:16Z  $
47
* $Log$
48
* Revision 1.2.4.1  2006-11-15 00:08:28  jjdelcerro
49
* *** empty log message ***
50
*
51
* Revision 1.4  2006/11/13 20:46:37  azabala
52
* *** empty log message ***
53
*
54
* Revision 1.3  2006/11/06 07:29:59  jaume
55
* organize imports
56
*
57
* Revision 1.2  2006/03/14 19:24:07  azabala
58
* *** empty log message ***
59
*
60
* Revision 1.1  2006/03/07 21:00:29  azabala
61
* *** empty log message ***
62
*
63
*
64
*/
65
package com.iver.utiles.swing.threads;
66

    
67
import java.awt.event.ActionEvent;
68
import java.awt.event.ActionListener;
69

    
70
import javax.swing.Timer;
71

    
72
/**
73
 * It receives timer events sended by a swing Timer and does:
74
 * a) Reads task advances from a IMonitorableTask.
75
 * b) refresh task status info of a ProgressMonitor.
76
 * @author azabala
77
 *
78
 */
79
public class TaskMonitorTimerListener implements ActionListener {
80
        private IProgressMonitorIF progressMonitor;
81
        private IMonitorableTask task;
82
        private Timer timer;
83
        
84
        public TaskMonitorTimerListener(IProgressMonitorIF progressMonitor,
85
                        IMonitorableTask task){
86
                this.progressMonitor = progressMonitor;
87
                this.task = task;
88
        }
89
        
90
        public void setTimer(Timer timer){
91
                this.timer = timer;
92
        }
93
        
94
        public void actionPerformed(ActionEvent arg0) {
95
                int currentStep = task.getCurrentStep();
96
                String statusNote = task.getNote();
97
        progressMonitor.setCurrentStep(currentStep);
98
        progressMonitor.setNote(statusNote);
99
        if(progressMonitor.isCanceled()){
100
                 progressMonitor.close();
101
             task.cancel();
102
             timer.stop();
103
        }
104
        if (task.isFinished()) {
105
           progressMonitor.close();
106
           timer.stop();
107
        }
108
        }
109

    
110
}
111