Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / panels / EPSGpanel.java @ 8594

History | View | Annotate | Download (20.8 KB)

1
package org.gvsig.crs.gui.panels;
2
import java.awt.Color;
3
import java.awt.Component;
4
import java.awt.Dimension;
5
import java.awt.FlowLayout;
6
import java.awt.GridLayout;
7
import java.awt.event.ActionEvent;
8
import java.awt.event.ActionListener;
9
import java.awt.event.KeyEvent;
10
import java.awt.event.KeyListener;
11
import java.awt.event.MouseAdapter;
12
import java.awt.event.MouseEvent;
13
import java.sql.ResultSet;
14
import java.sql.SQLException;
15
import java.util.ArrayList;
16

    
17
import javax.swing.BorderFactory;
18
import javax.swing.JButton;
19
import javax.swing.JLabel;
20
import javax.swing.JOptionPane;
21
import javax.swing.JPanel;
22
import javax.swing.JRadioButton;
23
import javax.swing.JScrollPane;
24
import javax.swing.JTable;
25
import javax.swing.JTextField;
26
import javax.swing.ListSelectionModel;
27
import javax.swing.event.DocumentEvent;
28
import javax.swing.event.DocumentListener;
29
import javax.swing.table.DefaultTableModel;
30
import javax.swing.table.TableColumn;
31

    
32
import org.cresques.cts.IProjection;
33
import org.gvsig.crs.CrsException;
34
import org.gvsig.crs.CrsFactory;
35
import org.gvsig.crs.EpsgConnection;
36
import org.gvsig.crs.ICrs;
37
import org.gvsig.crs.Query;
38
import org.gvsig.crs.ogr.Epsg2wkt;
39
import org.gvsig.crs.ogr.GetCRSepsg;
40

    
41
import com.iver.andami.PluginServices;
42
import com.iver.cit.gvsig.gui.TableSorter;
43

    
44
public class EPSGpanel extends JPanel implements KeyListener, ActionListener{
45

    
46
        /**
47
         * 
48
         */
49
        private static final long serialVersionUID = 1L;
50
        public JPanel EPSGpanel = null;
51
                
52
        String cadWKT = "";
53
        
54
        int iteracion = 0;
55
        boolean tecla_valida = false;
56
        String cad_valida = "";        
57
        
58
        int transf = 0;
59
        public int epsg_code  = 0;
60
        boolean source_yn = false;
61
        int source_cod = 0;
62
        int method_code = 0;
63
        int datum_code = 0;
64
        int projection_conv_code = 0;
65
        public String crs_kind = null;
66
        int[] valid_method_code = {9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810, 
67
                        9811, 9812, 9813, 9814, 9815, 9816, 9817, 9602, 9659, 9818, 9819, 9820, 9822, 
68
                        9827};
69
        
70
        String[] soported_crs = {"projected","geographic 2D","geographic 3D", "engineering", "vertical", "compound", "geocentric"};
71
        String[] not_soported_crs = {};
72
        
73
        private JRadioButton codeRadioButton = null;
74
        private JRadioButton nameRadioButton = null;
75
        private JRadioButton areaRadioButton = null;
76
        private JPanel groupRadioButton = null;
77
        
78
        public EpsgConnection connect = null;
79
        
80
        private JButton infoCrs = null;
81
        private JButton searchButton = null;
82
        private JTextField searchTextField = null;
83
        public JTable jTable = null;
84
        private JScrollPane jScrollPane = null;
85
        public DefaultTableModel dtm = null;        
86
        public String key;
87
        public int selectedRowTable = -1;
88
                
89
        private int codeCRS = -1;
90
        public TableSorter sorter = null;
91
                
92
        public EPSGpanel(){
93
                initialize();
94
        }
95
        
96
        private void initialize(){
97
                this.setLayout(new GridLayout(3,3));
98
                this.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
99
                                
100
                this.add(getGroupRadioButton(), null);                        
101
                this.add(getSearchButton(), null);
102
                this.add(getSearchTextField(), null);
103
                this.add(getInfoCrs(), null);
104
                this.add(getJScrollPane(), null);                
105
        }
106
        
107
        public void connection(){
108
                connect = new EpsgConnection();
109
                connect.setConnectionEPSG();
110
        }
111
        
112
/*        public JPanel getJPanelEPSG() {         //TODO Eliminar esta funci?n.
113
                if (EPSGpanel == null){
114
                        EPSGpanel = new JPanel();
115
                        EPSGpanel.setLayout(new GridLayout(3,3));
116
                        EPSGpanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
117
                                        
118
                        EPSGpanel.add(getGroupRadioButton(), null);                        
119
                        EPSGpanel.add(getSearchButton(), null);
120
                        EPSGpanel.add(getSearchTextField(), null);
121
                        EPSGpanel.add(getInfoCrs(), null);
122
                        EPSGpanel.add(getJScrollPane(), null);                        
123
                }        
124
                return EPSGpanel;
125
        }*/
126
        
127
        
128
            
129
        private JRadioButton getCodeRadioButton() {
130
                if (codeRadioButton == null) {
131
                        codeRadioButton = new JRadioButton();
132
                        codeRadioButton.setText(PluginServices.getText(this,"por_codigo"));//setText("By Code EPSG");
133
                        codeRadioButton.setSelected(true);
134
                        codeRadioButton.addActionListener(this);
135
                }
136
                return codeRadioButton;
137
        }
138
                  
139
        private JRadioButton getNameRadioButton() {
140
                if (nameRadioButton == null) {
141
                        nameRadioButton = new JRadioButton();
142
                        nameRadioButton.setText(PluginServices.getText(this,"por_nombre"));
143
                        nameRadioButton.addActionListener(this);
144
                }
145
                return nameRadioButton;
146
        }
147
        
148
        private JRadioButton getAreaRadioButton() {
149
                if (areaRadioButton == null) {
150
                        areaRadioButton = new JRadioButton();
151
                        areaRadioButton.setText(PluginServices.getText(this,"por_area"));
152
                        areaRadioButton.addActionListener(this);
153
                }
154
                return areaRadioButton;
155
        }
156
         
157
        private JPanel getGroupRadioButton() {
158
                if (groupRadioButton == null) {
159
                        groupRadioButton = new JPanel();
160
                        groupRadioButton.setLayout(new GridLayout(1,0));
161
                        groupRadioButton.setPreferredSize(new Dimension(500,30));
162
                        groupRadioButton.add(getLabel());
163
                        groupRadioButton.add(getCodeRadioButton());
164
                        groupRadioButton.add(getNameRadioButton());
165
                        groupRadioButton.add(getAreaRadioButton());
166
                }
167
                return groupRadioButton;
168
        }
169
        
170
        private JLabel getLabel(){
171
                JLabel criterio = new JLabel();
172
                criterio.setPreferredSize(new Dimension(100, 20));
173
                criterio.setText(PluginServices.getText(this, "criterio_busqueda")+":");
174
                return criterio;
175
        }
176

    
177
        private void searchButton() {
178
                boolean not_valid = false;
179
                boolean not_numeric = false;
180
                searchTextField.setBackground(Color.white);
181
                
182
                if (searchTextField.getText().equals("")) {
183
                        searchTextField.setBackground(new Color(255,204,204));
184
                        JOptionPane.showMessageDialog(this, PluginServices.getText(this,"fill_name"), "Warning...", JOptionPane.WARNING_MESSAGE);
185
                }                
186
                
187
                else {
188
            //Eliminar filas en cada nueva bsqueda
189
                        int numRow = dtm.getRowCount();
190
                        while (numRow != 0) {
191
                                numRow = numRow - 1;
192
                                dtm.removeRow(numRow);
193
                        }
194
                        
195
                        if (codeRadioButton.isSelected() && (searchTextField.getText().length()!=searchTextField.getText().replaceAll("[^0-9]", "").length())){
196
                                not_numeric = true;
197
                        }
198
                        
199
                        //Dependiendo de la opcion se realizada una busqueda
200
                        ResultSet result = null;
201
                        ResultSet result2 = null;
202
                        /*
203
                         * variable que indicara si la busqueda se hace primero en epsg_coordinatereferencesystem
204
                         * o en epsg_area; esto es debido a que HSQLDB no soporta la b?squeda simult?nea en ambas
205
                         * tablas, por lo cual hay que separar la b?squeda
206
                         */
207
                        int bus = 2;                          
208
                        if (codeRadioButton.isSelected() && !not_numeric) {
209
                                bus=0;
210
                                key = searchTextField.getText();
211
                                int code = Integer.parseInt(key);
212
                                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " +
213
                                                                  "source_geogcrs_code, projection_conv_code  " +
214
                                                                  "FROM epsg_coordinatereferencesystem " +                                      
215
                                      "WHERE coord_ref_sys_code = " + code;
216
                                                                
217
                                result = Query.select(sentence,connect.getConnection());        
218
                                
219
                        }
220
                        
221
                        else if (nameRadioButton.isSelected()) {
222
                                bus=0;
223
                                key = searchTextField.getText();
224
                                String key2 = key.substring(0,1);
225
                                String key3 = key.substring(1,key.length());
226
                                key2 = key2.toUpperCase();
227
                                
228
                                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, " +
229
                                                                        "area_of_use_code, source_geogcrs_code, projection_conv_code " +
230
                                                                          "FROM epsg_coordinatereferencesystem " +                                      
231
                                                                          "WHERE (coord_ref_sys_name LIKE '%" + key + "%') OR (coord_ref_sys_name LIKE '%"+ 
232
                                                                          key.toUpperCase() +"%') " +
233
                                                                          "OR (coord_ref_sys_name LIKE '%" + key2+key3 +"%')";
234
                                result = Query.select(sentence,connect.getConnection());
235
                        }
236
                        
237
                        else if (areaRadioButton.isSelected()) {
238
                                bus=1;
239
                                key = searchTextField.getText();
240
                                String key2 = key.substring(0,1);
241
                                String key3 = key.substring(1,key.length());
242
                                key2 = key2.toUpperCase();                                
243
                                
244
                                String sentence = "SELECT area_name, area_of_use, area_code " +
245
                                      "FROM epsg_area " +
246
                                      "WHERE (area_name LIKE '%" + key + "%') OR (area_of_use LIKE '%" + key + "%') "+
247
                                      "OR (area_name LIKE '%" + key.toUpperCase() + "%') OR (area_of_use LIKE '%" + key.toUpperCase() + "%') "+
248
                                      "OR (area_name LIKE '%" + key2+key3 + "%') OR (area_of_use LIKE '%" + key2+key3 + "%') ";
249
                                result = Query.select(sentence,connect.getConnection());                                
250
                        }
251
                        
252
                        if (bus==0){
253
                                try {
254
                                        while(result.next()) {
255
                                                Object[]data = new Object[5];
256
                                                data[0] = String.valueOf(result.getInt("coord_ref_sys_code"));
257
                                                data[1] = result.getString("coord_ref_sys_name");
258
                                                crs_kind = result.getString("coord_ref_sys_kind");
259
                                                data[2] = crs_kind;
260
                                                projection_conv_code = result.getInt("projection_conv_code");
261
                                                
262
                                                int area_of_use_code = Integer.parseInt(result.getString("area_of_use_code"));
263
                                                                                
264
                                                String sentence = "SELECT area_name, area_of_use FROM epsg_area " +
265
                                                                                "WHERE area_code = "+ area_of_use_code ;
266
                                                
267
                                                result2 = Query.select(sentence,connect.getConnection());
268
                                                while(result2.next()){
269
                                                        data[3] = result2.getString("area_name");
270
                                                        data[4] = result2.getString("area_of_use");                                        
271
                                                }
272
                                                if (data[0]!=null && validCRS(projection_conv_code) && valid(crs_kind)){
273
                                                        dtm.addRow(data);
274
                                                }
275
                                        }
276
                                }
277
                                
278
                                catch (SQLException e1) {
279
                                        e1.printStackTrace();
280
                                }
281
                        }
282
                        else if (bus==1){
283
                                try {
284
                                        while(result.next()) {
285
                                                Object[]data = new Object[5];
286
                                                data[3] = result.getString("area_name");
287
                                                data[4] = result.getString("area_of_use");        
288
                                                                                        
289
                                                int area_of_use_code = Integer.parseInt(result.getString("area_code"));
290
                                                                                
291
                                                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, " +
292
                                                                                "coord_ref_sys_kind, source_geogcrs_code, projection_conv_code " +
293
                                                                                "FROM epsg_coordinatereferencesystem " +
294
                                                                                "WHERE area_of_use_code = "+ area_of_use_code ;
295
                                                
296
                                                result2 = Query.select(sentence,connect.getConnection());
297
                                                while(result2.next()){
298
                                                        data[0] = String.valueOf(result2.getInt("coord_ref_sys_code"));
299
                                                        data[1] = result2.getString("coord_ref_sys_name");
300
                                                        data[2] = result2.getString("coord_ref_sys_kind");
301
                                                        crs_kind = (String)data[2];
302
                                                        projection_conv_code = result2.getInt("projection_conv_code");
303
                                                                                
304
                                                }
305
                                                /*
306
                                                 * Buscaremos solo aquellos CRS cuyas proyecciones esten entre las
307
                                                 * 16 soportadas por proj4 para ello creamos un metodo para validar
308
                                                 * si esta entre estas proyecciones
309
                                                 */                                                
310
                                                if (data[0]!=null && validCRS(projection_conv_code) && valid(crs_kind)){
311
                                                        dtm.addRow(data);
312
                                                }        
313
                                                if (notValid(crs_kind)){
314
                                                        not_valid = true;
315
                                                }
316
                                        }
317
                                } 
318
                                
319
                                catch (SQLException e1) {
320
                                        e1.printStackTrace();
321
                                }
322
                        }
323
                        int numr = dtm.getRowCount();                        
324
                        if (not_valid){
325
                                JOptionPane.showMessageDialog(this, PluginServices.getText(this,"crs_not_soported"), "Warning...",
326
                                                JOptionPane.WARNING_MESSAGE);
327
                                not_valid = false;
328
                        }
329
                        else if (not_numeric) {
330
                                JOptionPane.showMessageDialog(EPSGpanel.this, 
331
                                                PluginServices.getText(this,"numeric_format"), 
332
                                                "Warning...", JOptionPane.WARNING_MESSAGE);
333
                                searchTextField.setText("");
334
                        }
335
                        else if (numr == 0){
336
                        JOptionPane.showMessageDialog(this, PluginServices.getText(this,"no_results"), "Warning...",
337
                                        JOptionPane.WARNING_MESSAGE);
338
                        }
339
                        else{
340
                                this.getJTable().setRowSelectionInterval(0,0);                                
341
                        }
342
                }                
343
        }        
344
        
345
        /*
346
         * metodo auxiliar que hara la comprobacion de si el CRS buscado pertenecera
347
         * a los no soportados por proj4
348
         */
349
        private boolean notValid(String kind){                
350
                for (int i = 0; i< not_soported_crs.length; i++){
351
                        if (kind.equals(not_soported_crs[i])){
352
                                return true;
353
                        }
354
                }
355
                return false;
356
        }
357
        
358
        /*
359
         * Metodo que comprueba si el CRS buscado pertenece a algun tipo de los que soporta
360
         * la aplicacion
361
         */
362
        private boolean valid(String kind){                
363
                for (int i = 0; i< soported_crs.length; i++){
364
                        if (kind.equals(soported_crs[i])){
365
                                return true;
366
                        }
367
                }
368
                return false;
369
        }
370
        
371
        /*
372
         * metodo auxiliar que nos servira para comprobar si la proyeccion del CRS seleccionado
373
         * esta entre las 16 con las que trabaja proj4
374
         */
375
        private boolean validCRS(int projection_conv_code2) {
376
                if (projection_conv_code2 == 0) return true;
377
                String sentence = "SELECT coord_op_method_code " +
378
                                                        "FROM epsg_coordoperation " +
379
                                                        "WHERE coord_op_code = " + projection_conv_code;
380
                ResultSet result = Query.select(sentence,connect.getConnection());
381
                try {
382
                        while (result.next()){
383
                                method_code = result.getInt("coord_op_method_code");
384
                        }
385
                } catch (SQLException e) {
386
                        e.printStackTrace();
387
                }
388
                
389
                for (int i = 0; i< valid_method_code.length; i++){
390
                        if (method_code == valid_method_code[i] ){
391
                                return true;
392
                        }
393
                }                
394
                return false;
395
        }
396

    
397

    
398
        private JButton getSearchButton() {
399
                if (searchButton == null) {
400
                        searchButton = new JButton();
401
                        searchButton.setPreferredSize(new Dimension(75,20));
402
                        searchButton.setText(PluginServices.getText(this,"buscar"));
403
                        searchButton.setMnemonic('S');
404
                        searchButton.setToolTipText("Search of a CRS by selected criterion");
405
                        searchButton.addActionListener(this);                        
406
                }
407
                return searchButton;
408
        }        
409
        
410
        private JTextField getSearchTextField() {
411
                if (searchTextField == null) {
412
                        searchTextField = new JTextField();
413
                        searchTextField.setPreferredSize(new Dimension(300,20));
414
                        searchTextField.addKeyListener(this);                        
415
                }
416
                
417
                return searchTextField;
418
        }
419
        
420
        public JTable getJTable() {
421
                if (jTable == null) {
422
                        String[] columnNames= {PluginServices.getText(this,"codigo"),
423
                                        PluginServices.getText(this,"nombre"),
424
                                        PluginServices.getText(this,"tipo"),
425
                                        PluginServices.getText(this,"area"),
426
                                        PluginServices.getText(this,"descripcion")};
427
                        Object[][]data = {};                        
428
                        dtm = new DefaultTableModel(data, columnNames)
429
                         {
430
                                public boolean isCellEditable(int row, int column) {
431
                                        return false;
432
                                }
433
                                /*
434
                                 * metodo necesario para cuando utilizamos tablas ordenadas
435
                                 * ya que sino al ordenar por algun campo no se queda con el orden
436
                                 * actual al seleccionar una fila (non-Javadoc)
437
                                 * @see javax.swing.table.TableModel#getColumnClass(int)
438
                                 */
439
                                public Class getColumnClass(int column)
440
                                {
441
                                        return getValueAt(0, column).getClass();
442
                                }
443
                                };
444
                        sorter = new TableSorter(dtm);                        
445

    
446
                        jTable = new JTable(sorter);
447
                        sorter.setTableHeader(jTable.getTableHeader());                        
448
                        jTable.setCellSelectionEnabled(false);
449
                        jTable.setRowSelectionAllowed(true);
450
                        jTable.setColumnSelectionAllowed(false);
451
                        jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
452
                        TableColumn column = null;
453
                        for (int i = 0; i < 5; i++) {
454
                            column = jTable.getColumnModel().getColumn(i);
455
                            if (i == 0) {
456
                                column.setPreferredWidth(40); //code column is shorter                                     
457
                            }else if (i == 2) {
458
                                    column.setPreferredWidth(80);
459
                            }
460
                            else {                            
461
                                column.setPreferredWidth(160);
462
                            }
463
                        }        
464
                }
465
                
466
                return jTable;
467
                
468
        }
469
        
470
        public void setCodeCRS(int code) {
471
                codeCRS = code;
472
        }
473
        
474
        public int getCodeCRS() {
475
                return codeCRS;
476
        }        
477
        
478
        private JScrollPane getJScrollPane() {
479
                if (jScrollPane == null) {
480
                        jScrollPane = new JScrollPane();
481
                        jScrollPane.setPreferredSize(new Dimension(500,150));
482
                        jScrollPane.setBorder(
483
                                    BorderFactory.createCompoundBorder(
484
                                        BorderFactory.createCompoundBorder(
485
                                                        BorderFactory.createTitledBorder(PluginServices.getText(this,"coordinate_reference_systems")),
486
                                                        BorderFactory.createEmptyBorder(5,5,5,5)),
487
                                                        jScrollPane.getBorder()));
488
                        jScrollPane.setViewportView(getJTable());
489
                }
490
                return jScrollPane;
491
        }
492
        
493
        public JButton getInfoCrs() {
494
                if(infoCrs == null) {
495
                        infoCrs = new JButton();
496
                        infoCrs.setPreferredSize(new Dimension(75,20));
497
                        infoCrs.setText(PluginServices.getText(this,"infocrs"));                        
498
                        infoCrs.setMnemonic('I');
499
                        infoCrs.setEnabled(false);
500
                        infoCrs.setToolTipText("Mostrar la informacion del Crs selecionado");
501
                        infoCrs.addActionListener(this);
502
                }
503
                return infoCrs;
504
        }
505
        
506
        
507
        public ICrs getProjection() {
508
                try {
509
                        String txt = getWKT();                        
510
                        ICrs crs = new CrsFactory().getCRS(epsg_code, txt); 
511
                        return crs ;
512
                } catch (CrsException e) {
513
                        e.printStackTrace();
514
                }
515
                return null;
516
        }
517
        
518
        
519
        public void setWKT(){
520
                Epsg2wkt wkt = null;
521
                                                
522
                epsg_code = getCodeCRS();
523
                if (epsg_code != -1){                
524
                        /*
525
                         * ahora que he escogido, recojo toda la informacion que me va a hacer falta
526
                         */
527
                        String sentence = "SELECT source_geogcrs_code, projection_conv_code, " +
528
                                        "coord_ref_sys_kind, datum_code " +
529
                                                        "FROM epsg_coordinatereferencesystem " +
530
                                                        "WHERE coord_ref_sys_code = "+ epsg_code ;
531
                        ResultSet result = Query.select(sentence,connect.getConnection());
532
                        
533
                        try {
534
                                result.next();
535
                                source_cod = result.getInt("source_geogcrs_code");
536
                                projection_conv_code = result.getInt("projection_conv_code");
537
                                crs_kind = result.getString("coord_ref_sys_kind");
538
                                datum_code = result.getInt("datum_code");
539
                        } catch (SQLException e1) {
540
                                e1.printStackTrace();
541
                        }
542
                        
543
                        if (datum_code != 0){
544
                                source_yn = true;
545
                                GetCRSepsg ep = new GetCRSepsg(epsg_code, source_yn, source_cod, projection_conv_code, connect);
546
                                ep.Getepsgdata();
547
                        }
548
                        else if (source_cod != 0){
549
                                source_yn = false;
550
                        }
551
                        else source_yn = true;
552
                        
553
                        GetCRSepsg ep = new GetCRSepsg(epsg_code, source_yn, source_cod, projection_conv_code, connect);
554
                        ep.Getepsgdata();
555
                        
556
                        if (crs_kind.equals("geographic 2D") || crs_kind.equals("geographic 3D")){
557
                                wkt = new Epsg2wkt(ep , "geog");                        
558
                        }
559
                        else if (crs_kind.equals("projected")){
560
                                wkt = new Epsg2wkt(ep, "proj");
561
                        }
562
                        else if (crs_kind.equals("compound")){
563
                                wkt = new Epsg2wkt(ep,"comp");
564
                        }
565
                        else if (crs_kind.equals("geocentric")){
566
                                wkt = new Epsg2wkt(ep,"geoc");
567
                        }
568
                }
569
                else {
570
                        JOptionPane.showMessageDialog(this, 
571
                                        PluginServices.getText(this,"crs_no_selected."), 
572
                                        "Warning...", JOptionPane.WARNING_MESSAGE);
573
                        
574
                }
575
                cadWKT = wkt.getWKT();
576
        }
577
                
578
        public String getWKT(){
579
                return cadWKT;
580
        }
581
        
582
        public void setProjection(IProjection crs) {
583
                //setCrs((ICrs) crs);
584
        }
585
        
586
        /*
587
         * Metodo para cargar en el CRS de la capa el CRS de la vista.
588
         * Se utilizar? a la hora de arrancar la definici?n del CRS de la nueva capa
589
         */
590
        public void loadViewCRS(int code){
591
                connection();
592
                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " +
593
                                                  "source_geogcrs_code, projection_conv_code  " +
594
                                                  "FROM epsg_coordinatereferencesystem " +                                      
595
                                        "WHERE coord_ref_sys_code = " + code;
596
                ResultSet result = Query.select(sentence,connect.getConnection());
597
                
598
                try {
599
                        result.next();
600
                        Object[]data = new Object[5];
601
                        data[0] = String.valueOf(result.getInt("coord_ref_sys_code"));
602
                        data[1] = result.getString("coord_ref_sys_name");
603
                        crs_kind = result.getString("coord_ref_sys_kind");
604
                        data[2] = crs_kind;
605
                        projection_conv_code = result.getInt("projection_conv_code");
606
                        
607
                        int area_of_use_code = Integer.parseInt(result.getString("area_of_use_code"));
608
                                                        
609
                        sentence = "SELECT area_name, area_of_use FROM epsg_area " +
610
                                                        "WHERE area_code = "+ area_of_use_code ;
611
                        
612
                        ResultSet result2 = Query.select(sentence,connect.getConnection());
613
                        result2.next();
614
                        data[3] = result2.getString("area_name");
615
                        data[4] = result2.getString("area_of_use");                                        
616
                        
617
                        dtm.addRow(data);                                        
618
                }
619
                
620
                catch (SQLException e1) {
621
                        e1.printStackTrace();
622
                }
623
        }
624

    
625
        public void keyPressed(KeyEvent e) {
626
                // TODO Auto-generated method stub                
627
                if (e.getSource() == this.getSearchTextField()) {
628
                        if (e.getKeyCode() == 10) {
629
                                searchButton();
630
                        }                        
631
                }                
632
        }
633

    
634
        public void keyReleased(KeyEvent e) {
635
                // TODO Auto-generated method stub                
636
        }
637

    
638
        public void keyTyped(KeyEvent e) {
639
                // TODO Auto-generated method stub
640
                
641
        }
642

    
643
        public void actionPerformed(ActionEvent e) {
644
                // TODO Auto-generated method stub
645
                if (e.getSource() == this.getCodeRadioButton()) {
646
                        searchTextField.setText("");
647
                        codeRadioButton.setSelected(true);
648
                        nameRadioButton.setSelected(false);
649
                        areaRadioButton.setSelected(false);
650
                }
651
                
652
                if (e.getSource() == this.getNameRadioButton()) {
653
                        searchTextField.setText("");
654
                        nameRadioButton.setSelected(true);
655
                        codeRadioButton.setSelected(false);
656
                        areaRadioButton.setSelected(false);
657
                }
658

    
659
                if (e.getSource() == this.getAreaRadioButton()) {
660
                        searchTextField.setText("");
661
                        areaRadioButton.setSelected(true);
662
                        codeRadioButton.setSelected(false);
663
                        nameRadioButton.setSelected(false);
664
                }
665
                
666
                if (e.getSource() == this.getSearchButton()) {
667
                        searchTextField.setBackground(Color.white);
668
                        if (searchTextField.getText().equals("")) {
669
                                searchTextField.setBackground(new Color(255,204,204));
670
                                JOptionPane.showMessageDialog(EPSGpanel.this, 
671
                                                PluginServices.getText(this,"fill_name"), 
672
                                                "Warning...", JOptionPane.WARNING_MESSAGE);
673
                        }
674
                        else {
675
                                searchButton();
676
                        }
677
                }
678
                
679
                if (e.getSource() == this.getInfoCrs()) {
680
                        InfoCRSPanel info = new InfoCRSPanel(getProjection());
681
                        info.setSize(new Dimension(550,350));
682
                        info.setLayout(new GridLayout(0,1));
683
                        info.setLayout(new FlowLayout(FlowLayout.LEFT,10,5));
684
                        PluginServices.getMDIManager().addWindow(info);
685
                }
686
        }
687
}