root / branches / F2 / extensions / extJCRS / src / org / gvsig / crs / gui / listeners / ImportNewCrsDialogListener.java @ 18259
History | View | Annotate | Download (5.62 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 |
* Listeners para el manejo de las importaciones de las partes correspondientes
|
63 |
* a los crs definidos por el usuario
|
64 |
*
|
65 |
* @author Jose Luis Gomez Martinez (joseluis.gomez@uclm.es)
|
66 |
*
|
67 |
*/
|
68 |
|
69 |
public class ImportNewCrsDialogListener implements ActionListener, |
70 |
ListSelectionListener, MouseListener { |
71 |
|
72 |
ImportNewCrsDialog dialog = null;
|
73 |
|
74 |
public ImportNewCrsDialogListener(ImportNewCrsDialog d) {
|
75 |
dialog = d; |
76 |
} |
77 |
|
78 |
public void actionPerformed(ActionEvent e) { |
79 |
if (e.getSource() == dialog.getJButtonAccept()){
|
80 |
PluginServices.getMDIManager().closeWindow(dialog); |
81 |
} |
82 |
|
83 |
if (e.getSource() == dialog.getJButtonCancel()) {
|
84 |
dialog.setCode(-1);
|
85 |
PluginServices.getMDIManager().closeWindow(dialog); |
86 |
} |
87 |
} |
88 |
|
89 |
public void valueChanged(ListSelectionEvent e) { |
90 |
if (e.getSource() == dialog.getEpsgPanel().getJTable().getSelectionModel()){
|
91 |
String[] not_soported= new String[6];// = {"engineering", "vertical", "compound", "geocentric"}; |
92 |
boolean soported = true; |
93 |
ListSelectionModel lsm = (ListSelectionModel)e.getSource(); |
94 |
if (dialog.getOption().equals(PluginServices.getText(this, "projection"))) { |
95 |
not_soported[0] = "engineering"; |
96 |
not_soported[1]= "vertical"; |
97 |
not_soported[2] = "compound"; |
98 |
not_soported[3] ="geocentric"; |
99 |
not_soported[4]= "geographic 3D"; |
100 |
not_soported[5] = "geographic 2D"; |
101 |
} else {
|
102 |
not_soported[0] = "engineering"; |
103 |
not_soported[1]= "vertical"; |
104 |
not_soported[2] = "compound"; |
105 |
not_soported[3] ="geocentric"; |
106 |
not_soported[4]= "geographic 3D"; |
107 |
} |
108 |
|
109 |
if (lsm.isSelectionEmpty()) {
|
110 |
dialog.getEpsgPanel().setCodeCRS(-1);
|
111 |
dialog.getJButtonAccept().setEnabled(false);
|
112 |
dialog.getEpsgPanel().getInfoCrs().setEnabled(false);
|
113 |
dialog.setCode(-1);
|
114 |
} |
115 |
else {
|
116 |
dialog.getEpsgPanel().selectedRowTable = lsm.getMinSelectionIndex(); |
117 |
String crs_kind = (String)dialog.getEpsgPanel().sorter.getValueAt(dialog.getEpsgPanel().selectedRowTable,2); |
118 |
for (int i = 0; i < not_soported.length; i++) { |
119 |
if (crs_kind.equals(not_soported[i]))
|
120 |
soported = false;
|
121 |
} |
122 |
if (soported){
|
123 |
int code = Integer.parseInt((String)dialog.getEpsgPanel().sorter.getValueAt(dialog.getEpsgPanel().selectedRowTable,0)); |
124 |
dialog.setCode(code); |
125 |
dialog.getEpsgPanel().setCodeCRS(code); |
126 |
dialog.getJButtonAccept().setEnabled(true);
|
127 |
dialog.getEpsgPanel().getInfoCrs().setEnabled(true);
|
128 |
|
129 |
} |
130 |
else {
|
131 |
if (dialog.getOption().equals(PluginServices.getText(this, "projection"))) { |
132 |
JOptionPane.showMessageDialog(dialog, PluginServices.getText(this,"crs_not_projected"), "Warning...", |
133 |
JOptionPane.WARNING_MESSAGE);
|
134 |
} else {
|
135 |
JOptionPane.showMessageDialog(dialog, PluginServices.getText(this,"crs_not_soported"), "Warning...", |
136 |
JOptionPane.WARNING_MESSAGE);
|
137 |
} |
138 |
dialog.setCode(-1);
|
139 |
dialog.getEpsgPanel().setCodeCRS(-1);
|
140 |
dialog.getJButtonAccept().setEnabled(false);
|
141 |
dialog.getEpsgPanel().getInfoCrs().setEnabled(false);
|
142 |
} |
143 |
} |
144 |
} |
145 |
|
146 |
} |
147 |
|
148 |
public void mouseClicked(MouseEvent e) { |
149 |
if (e.getSource() == dialog.getEpsgPanel().getJTable()){
|
150 |
if (e.getClickCount() == 2){ |
151 |
PluginServices.getMDIManager().closeWindow(dialog); |
152 |
} |
153 |
} |
154 |
} |
155 |
|
156 |
public void mouseEntered(MouseEvent e) { |
157 |
// TODO Auto-generated method stub
|
158 |
|
159 |
} |
160 |
|
161 |
public void mouseExited(MouseEvent e) { |
162 |
// TODO Auto-generated method stub
|
163 |
|
164 |
} |
165 |
|
166 |
public void mousePressed(MouseEvent e) { |
167 |
// TODO Auto-generated method stub
|
168 |
|
169 |
} |
170 |
|
171 |
public void mouseReleased(MouseEvent e) { |
172 |
// TODO Auto-generated method stub
|
173 |
|
174 |
} |
175 |
|
176 |
} |