root / tags / v1_0_2_Build_916 / libraries / libIverUtiles / src / com / iver / utiles / swing / threads / TaskMonitorTimerListener.java @ 12327
History | View | Annotate | Download (2.81 KB)
1 | 4311 | azabala | /*
|
---|---|---|---|
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$
|
||
47 | * $Log$
|
||
48 | 8765 | jjdelcerro | * Revision 1.2.4.1 2006-11-15 00:08:28 jjdelcerro
|
49 | 4311 | azabala | * *** empty log message ***
|
50 | *
|
||
51 | 8765 | jjdelcerro | * 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 | 4419 | azabala | * Revision 1.1 2006/03/07 21:00:29 azabala
|
61 | * *** empty log message ***
|
||
62 | 4311 | azabala | *
|
63 | 4419 | azabala | *
|
64 | 4311 | azabala | */
|
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 | 4419 | azabala | * a) Reads task advances from a IMonitorableTask.
|
75 | 4311 | azabala | * b) refresh task status info of a ProgressMonitor.
|
76 | * @author azabala
|
||
77 | *
|
||
78 | */
|
||
79 | public class TaskMonitorTimerListener implements ActionListener { |
||
80 | 4419 | azabala | private IProgressMonitorIF progressMonitor;
|
81 | private IMonitorableTask task;
|
||
82 | 4311 | azabala | private Timer timer; |
83 | |||
84 | 4419 | azabala | public TaskMonitorTimerListener(IProgressMonitorIF progressMonitor,
|
85 | IMonitorableTask task){ |
||
86 | 4311 | azabala | 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 | 4419 | azabala | progressMonitor.setCurrentStep(currentStep); |
98 | 4311 | azabala | progressMonitor.setNote(statusNote); |
99 | 8765 | jjdelcerro | if(progressMonitor.isCanceled()){
|
100 | progressMonitor.close(); |
||
101 | task.cancel(); |
||
102 | timer.stop(); |
||
103 | 4311 | azabala | } |
104 | 8765 | jjdelcerro | if (task.isFinished()) {
|
105 | progressMonitor.close(); |
||
106 | timer.stop(); |
||
107 | } |
||
108 | 4311 | azabala | } |
109 | |||
110 | } |