Statistics
| Revision:

root / branches / F2 / extensions / extJCRS / src / org / gvsig / crs / gui / listeners / ImportNewCrsDialogListener.java @ 12202

History | View | Annotate | Download (5.5 KB)

1
/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ibáñez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
34
 *   Campus Universitario s/n
35
 *   02071 Alabacete
36
 *   Spain
37
 *
38
 *   +34 967 599 200
39
 */
40

    
41
package org.gvsig.crs.gui.listeners;
42

    
43
import java.awt.event.ActionEvent;
44
import java.awt.event.ActionListener;
45
import java.awt.event.ItemListener;
46
import java.awt.event.MouseEvent;
47
import java.awt.event.MouseListener;
48

    
49
import javax.swing.JOptionPane;
50
import javax.swing.ListSelectionModel;
51
import javax.swing.event.ListSelectionEvent;
52
import javax.swing.event.ListSelectionListener;
53

    
54
import org.gvsig.crs.ICrs;
55
import org.gvsig.crs.gui.dialog.ImportNewCrsDialog;
56
import org.gvsig.crs.persistence.CrsData;
57
import org.gvsig.crs.persistence.RecentCRSsPersistence;
58

    
59
import com.iver.andami.PluginServices;
60

    
61
/**
62
 * 
63
 * @author Jose Luis Gomez Martinez (joseluis.gomez@uclm.es)
64
 *
65
 */
66

    
67
public class ImportNewCrsDialogListener implements ActionListener,
68
ListSelectionListener, MouseListener {
69

    
70
        ImportNewCrsDialog dialog = null;        
71
        
72
        public ImportNewCrsDialogListener(ImportNewCrsDialog d) {
73
                dialog = d;
74
        }
75

    
76
        public void actionPerformed(ActionEvent e) {
77
                if (e.getSource() == dialog.getJButtonAccept()){                        
78
                        PluginServices.getMDIManager().closeWindow(dialog);
79
                }
80
                
81
                if (e.getSource() == dialog.getJButtonCancel()) {
82
                        dialog.setCode(-1);
83
                        PluginServices.getMDIManager().closeWindow(dialog);
84
                }                
85
        }
86

    
87
        public void valueChanged(ListSelectionEvent e) {
88
                if (e.getSource() == dialog.getEpsgPanel().getJTable().getSelectionModel()){
89
                        String[] not_soported= new String[6];// = {"engineering", "vertical", "compound", "geocentric"};
90
                        boolean soported = true;
91
                        ListSelectionModel lsm = (ListSelectionModel)e.getSource();
92
                        if (dialog.getOption().equals(PluginServices.getText(this, "projected"))) {
93
                                not_soported[0] = "engineering";
94
                                not_soported[1]= "vertical";
95
                                not_soported[2] = "compound";
96
                                not_soported[3] ="geocentric";
97
                                not_soported[4]= "geographic 3D";
98
                                not_soported[5] = "geographic 2D";
99
                        } else {
100
                                not_soported[0] = "engineering";
101
                                not_soported[1]= "vertical";
102
                                not_soported[2] = "compound";
103
                                not_soported[3] ="geocentric";
104
                                not_soported[4]= "geographic 3D";                                
105
                        }
106
                        
107
                if (lsm.isSelectionEmpty()) {                        
108
                        dialog.getEpsgPanel().setCodeCRS(-1);
109
                        dialog.getJButtonAccept().setEnabled(false);                
110
                        dialog.getEpsgPanel().getInfoCrs().setEnabled(false);
111
                        dialog.setCode(-1);                             
112
                } 
113
                else {                        
114
                        dialog.getEpsgPanel().selectedRowTable = lsm.getMinSelectionIndex();
115
                        String crs_kind = (String)dialog.getEpsgPanel().sorter.getValueAt(dialog.getEpsgPanel().selectedRowTable,2);                        
116
                        for (int i = 0; i < not_soported.length; i++) {
117
                                if (crs_kind.equals(not_soported[i]))
118
                                        soported = false;                                
119
                        }
120
                        if (soported){
121
                                int code = Integer.parseInt((String)dialog.getEpsgPanel().sorter.getValueAt(dialog.getEpsgPanel().selectedRowTable,0));
122
                                dialog.setCode(code);
123
                                dialog.getEpsgPanel().setCodeCRS(code);
124
                                dialog.getJButtonAccept().setEnabled(true);
125
                            dialog.getEpsgPanel().getInfoCrs().setEnabled(true);
126
                            
127
                        }
128
                        else {
129
                                if (dialog.getOption().equals(PluginServices.getText(this, "projected"))) {
130
                                        JOptionPane.showMessageDialog(dialog, PluginServices.getText(this,"crs_not_projected"), "Warning...",
131
                                                                JOptionPane.WARNING_MESSAGE);
132
                                } else {                                
133
                                        JOptionPane.showMessageDialog(dialog, PluginServices.getText(this,"crs_not_soported"), "Warning...",
134
                                                        JOptionPane.WARNING_MESSAGE);
135
                                }
136
                                dialog.setCode(-1);
137
                                dialog.getEpsgPanel().setCodeCRS(-1);
138
                                dialog.getJButtonAccept().setEnabled(false);
139
                                dialog.getEpsgPanel().getInfoCrs().setEnabled(false);
140
                        }                        
141
                }
142
                }
143
                
144
        }
145

    
146
        public void mouseClicked(MouseEvent e) {
147
                if (e.getSource() == dialog.getEpsgPanel().getJTable()){
148
                        if (e.getClickCount() == 2){                                
149
                                PluginServices.getMDIManager().closeWindow(dialog);        
150
                    }
151
                }
152
        }
153

    
154
        public void mouseEntered(MouseEvent e) {
155
                // TODO Auto-generated method stub
156
                
157
        }
158

    
159
        public void mouseExited(MouseEvent e) {
160
                // TODO Auto-generated method stub
161
                
162
        }
163

    
164
        public void mousePressed(MouseEvent e) {
165
                // TODO Auto-generated method stub
166
                
167
        }
168

    
169
        public void mouseReleased(MouseEvent e) {
170
                // TODO Auto-generated method stub
171
                
172
        }
173

    
174
}