Statistics
| Revision:

svn-gvsig-desktop / tags / v10_RC2c / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / wizards / WFSWizard.java @ 8745

History | View | Annotate | Download (19.9 KB)

1
package com.iver.cit.gvsig.gui.wizards;
2

    
3
import java.awt.Component;
4
import java.awt.geom.Rectangle2D;
5
import java.net.MalformedURLException;
6
import java.net.URL;
7
import java.util.prefs.Preferences;
8

    
9
import javax.swing.DefaultComboBoxModel;
10
import org.gvsig.gui.beans.swing.JButton;
11
import javax.swing.JCheckBox;
12
import javax.swing.JLabel;
13
import javax.swing.JOptionPane;
14

    
15
import org.apache.log4j.Logger;
16
import org.cresques.cts.IProjection;
17
import org.cresques.cts.ProjectionPool;
18

    
19
import com.iver.andami.PluginServices;
20
import com.iver.andami.persistence.serverData.ServerDataPersistence;
21
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
22
import com.iver.cit.gvsig.fmap.layers.FLayer;
23
import com.iver.cit.gvsig.fmap.layers.FLyrWFS;
24
import com.iver.cit.gvsig.gui.WizardPanel;
25
import com.iver.cit.gvsig.gui.panels.WFSParamsPanel;
26
import com.iver.utiles.NotExistInXMLEntity;
27
import com.iver.utiles.XMLEntity;
28
import com.iver.utiles.swing.jcomboServer.JComboServer;
29
import com.iver.utiles.swing.jcomboServer.ServerData;
30

    
31
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
32
 *
33
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
34
 *
35
 * This program is free software; you can redistribute it and/or
36
 * modify it under the terms of the GNU General Public License
37
 * as published by the Free Software Foundation; either version 2
38
 * of the License, or (at your option) any later version.
39
 *
40
 * This program is distributed in the hope that it will be useful,
41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43
 * GNU General Public License for more details.
44
 *
45
 * You should have received a copy of the GNU General Public License
46
 * along with this program; if not, write to the Free Software
47
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
48
 *
49
 * For more information, contact:
50
 *
51
 *  Generalitat Valenciana
52
 *   Conselleria d'Infraestructures i Transport
53
 *   Av. Blasco Ib??ez, 50
54
 *   46010 VALENCIA
55
 *   SPAIN
56
 *
57
 *      +34 963862235
58
 *   gvsig@gva.es
59
 *      www.gvsig.gva.es
60
 *
61
 *    or
62
 *
63
 *   IVER T.I. S.A
64
 *   Salamanca 50
65
 *   46005 Valencia
66
 *   Spain
67
 *
68
 *   +34 963163400
69
 *   dac@iver.es
70
 */
71
/* CVS MESSAGES:
72
 *
73
 * $Id: WFSWizard.java 8745 2006-11-14 13:14:23Z  $
74
 * $Log$
75
 * Revision 1.14.2.3  2006-09-29 14:12:53  luisw2
76
 * CRSFactory.getCRS substitutes ProjectionPool.get
77
 *
78
 * Revision 1.14.2.2  2006/09/28 08:54:01  jorpiell
79
 * Ya se puede reproyectar
80
 *
81
 * Revision 1.14.2.1  2006/09/27 11:12:14  jorpiell
82
 * Hay que comprobar que se han devuelto un n?mero de features menor que el n?mero m?ximo permitido
83
 *
84
 * Revision 1.14  2006/09/03 13:25:04  jorpiell
85
 * Los servidores se guardan ahora en el plugin-persistence como WFS
86
 *
87
 * Revision 1.13  2006/08/30 07:42:29  jorpiell
88
 * Se le asigna a la capa creada una proyecci?n concreta. Si esto no se hace, al exportar a postigis se produce un error.
89
 *
90
 * Revision 1.12  2006/07/21 11:50:31  jaume
91
 * improved appearance
92
 *
93
 * Revision 1.11  2006/07/11 11:55:41  jorpiell
94
 * Se ha a?adido el fallo de tipo de dato en el log
95
 *
96
 * Revision 1.10  2006/06/15 11:17:06  jorpiell
97
 * Se ha encontrado la forma de comprobar cuando se prodicia un error de parseo al hacer un hasnext (en la feature). Se atrapa y se lanza la excepci?n hacia arriba
98
 *
99
 * Revision 1.9  2006/06/14 08:46:24  jorpiell
100
 * Se tiene en cuanta la opcion para refrescar las capabilities
101
 *
102
 * Revision 1.8  2006/05/25 16:22:59  jorpiell
103
 * Se limpia el panel cada vez que se conecta con un servidor distinto
104
 *
105
 * Revision 1.7  2006/05/25 16:01:51  jorpiell
106
 * Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
107
 *
108
 * Revision 1.6  2006/05/25 10:29:07  jorpiell
109
 * A?adido el checkbox para que se  haga uso de la cache
110
 *
111
 * Revision 1.5  2006/05/24 12:08:53  jorpiell
112
 * Cambiado el nombre de la pesta?a a WFS
113
 *
114
 * Revision 1.4  2006/05/23 13:21:59  jorpiell
115
 * Si hay alg?n problema en la carga se muestra un mensaje de error
116
 *
117
 * Revision 1.3  2006/05/23 08:09:53  jorpiell
118
 * Se ha cambiado la forma en la que se leian los valores seleccionados en los paneles y se ha cambiado el comportamiento de los botones
119
 *
120
 * Revision 1.2  2006/05/19 12:58:03  jorpiell
121
 * Modificados algunos paneles
122
 *
123
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
124
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
125
 *
126
 *
127
 */
128
/**
129
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
130
 */
131
public class WFSWizard extends WizardPanel {
132
        private int page = 0;
133
        private boolean connected = false;
134
        private JComboServer cmbHost = null;
135
        private JButton btnConnect = null;
136
        private javax.swing.JPanel jPanel = null;
137
        private javax.swing.JLabel jLabel1 = null;
138
        private javax.swing.JLabel lblTitle = null;
139
        private javax.swing.JScrollPane jScrollPane = null;
140
        private javax.swing.JTextArea txtAbstract = null;
141
        private javax.swing.JPanel panelPage1 = null;
142
        private JButton btnSiguiente = null;
143
        private JButton btnAnterior = null;
144
        private javax.swing.JPanel jPanel1 = null;
145
        private WizardListenerSupport listenerSupport = new WizardListenerSupport();
146
        private WFSParamsPanel wfsParamsPanel = null;
147
        private WFSWizardData dataSource = null;
148
        private JLabel lblServerType = null;
149
        private JLabel lblServerTypeValue = null;
150
        private JCheckBox chkCaching = null;
151
        private static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wfs-wizard" );
152
        private boolean refreshing = fPrefs.getBoolean("refresh_capabilities", false);
153

    
154
        /**
155
         * This is the default constructor
156
         */
157
        public WFSWizard() {
158
                super();
159
                initialize();
160
        }
161

    
162
        /**
163
         * This method initializes this
164
         */
165
        private void initialize() {
166
                setTabName("WFS");
167
                lblServerType = new JLabel();
168
                lblServerType.setBounds(20, 444, 100, 20);
169
                lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
170
                lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
171
                lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11));
172
                lblServerType.setText(PluginServices.getText(this, "server_type")+":");
173
                lblServerTypeValue = new JLabel();
174
                lblServerTypeValue.setBounds(128, 444, 148, 20);
175
                lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11));
176
                lblServerTypeValue.setText("-");
177
                this.setLayout(null);
178
                this.setPreferredSize(new java.awt.Dimension(750, 320));
179
                this.setVisible(true);
180
                this.setSize(518, 468);
181
                this.add(getPanelPage1(), null);
182
                this.add(getPanelPage2(), null);
183
                this.add(getBtnAnterior(), null);
184
                this.add(getBtnSiguiente(), null);
185
                this.add(lblServerType, null);
186
                this.add(lblServerTypeValue, null);
187
                activarVisualizarBotones();
188
        }
189

    
190
        /**
191
         * Adds the host addres to a persistent data storage.
192
         *
193
         * con addHost guardamos la informaci?n del combo de servidores en un
194
         * almac?n persistente
195
         *
196
         * @param host
197
         */
198
        private void addHost(String host) {
199
                host = host.trim();
200
                ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WFS);
201
                persistence.addServerData(new ServerData(host, ServerData.SERVER_TYPE_WFS));
202
        }
203

    
204
        /**
205
         * Fills up the initial WCSWizard controls.
206
         *
207
         * Rellena los primeros controles del WCS Wizard
208
         *
209
         * jaume
210
         */
211
        private void rellenarControles() {
212
                try {
213
                        String host = cmbHost.getModel().getSelectedItem().toString();
214

    
215
                        dataSource.setHost(new URL(host), refreshing);
216
                        addHost(host);
217
                        getLblTitle().setText(dataSource.getTitle());
218
                        getTxtAbstract().setText(dataSource.getAbstract());
219
                        lblServerTypeValue.setText(dataSource.getServerType());
220
                        wfsParamsPanel.setWizardData(dataSource);
221

    
222
                        connected = true;
223
                        activarVisualizarBotones();
224
                } catch (Exception e) {
225
                        listenerSupport.callError(e);
226
                        e.printStackTrace();
227
                }
228
        }
229

    
230
        /**
231
         * Enables or disables the Next and Previous buttons according with the current
232
         * page and the enabled pages.
233
         */
234
        private void activarVisualizarBotones() {
235
                if (page == 0) {
236
                        getBtnAnterior().setEnabled(false);
237
                        getBtnSiguiente().setVisible(true);
238
                        if (connected) {
239
                                getBtnSiguiente().setEnabled(true);
240
                        } else {
241
                                getBtnSiguiente().setEnabled(false);
242
                        }
243
                } else if (page < wfsParamsPanel.getNumTabs()) {
244
                        getBtnSiguiente().setEnabled(true);
245
                        getBtnSiguiente().setVisible(true);
246
                        getBtnAnterior().setEnabled(true);
247
                        getBtnAnterior().setVisible(true);
248
                        if (wfsParamsPanel.nextPageEnabled()==-1){
249
                            getBtnSiguiente().setEnabled(false);
250
                        }
251
                        listenerSupport.callStateChanged(wfsParamsPanel.isCorretlyConfigured());
252
                } else if (page == wfsParamsPanel.getNumTabs()) {
253
                        getBtnSiguiente().setVisible(false);
254
                        getBtnSiguiente().setEnabled(false);
255
                        listenerSupport.callStateChanged(wfsParamsPanel
256
                                        .isCorretlyConfigured());
257
                }
258

    
259
        }
260

    
261

    
262

    
263
        /**
264
         * This method initializes txtHost from the persistent data storage
265
         *
266
         * @return javax.swing.JTextField
267
         */
268
        private javax.swing.JComboBox getTxtHost() {
269
                if (cmbHost == null) {
270
                        cmbHost = new JComboServer();
271
                        cmbHost.setModel(new DefaultComboBoxModel());
272
                        cmbHost.setPreferredSize(new java.awt.Dimension(350, 20));
273
                        cmbHost.setBounds(11, 26, 454, 20);
274
                        cmbHost.setEditable(true);
275

    
276
                        ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WFS);
277
                        ServerData[] servers = persistence.getArrayOfServerData();
278

    
279
                        if (servers.length == 0){
280
                                PluginServices ps = PluginServices.getPluginServices(this);
281
                                XMLEntity xml = ps.getPersistentXML();
282
                                try {
283
                                        String[] oldServers = xml.getStringArrayProperty("wfs-servers");
284
                                        servers = new ServerData[oldServers.length];
285
                                        for (int i=0; i<oldServers.length; i++) {
286
                                                servers[i] = new ServerData(oldServers[i],ServerData.SERVER_TYPE_WMS);
287
                                        }
288
                                        xml.remove("wfs-servers");
289
                                        ps.setPersistentXML(xml);
290
                                } catch (NotExistInXMLEntity e) {
291
                                        // Old servers doesn't exist
292
                                        servers = new ServerData[1];
293
                                        servers[0] = new ServerData("http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap",ServerData.SERVER_TYPE_WFS);
294
                                }
295

    
296
                                for (int i=0 ; i<servers.length ; i++){
297
                                        persistence.addServerData(servers[i]);
298
                                }
299
                                persistence.setPersistent();
300
                        }
301

    
302
                        cmbHost.setServerList(servers);
303
                }
304
                return cmbHost;
305
        }
306

    
307

    
308
        /**
309
         * This method initializes btnDetalles
310
         *
311
         * @return JButton
312
         */
313
        private JButton getBtnConnect() {
314
                if (btnConnect == null) {
315
                        btnConnect = new JButton();
316
                        btnConnect.setPreferredSize(new java.awt.Dimension(100, 20));
317
                        btnConnect.setBounds(366, 50, 100, 20);
318
                        btnConnect.setText(PluginServices.getText(this, "connect"));
319
                        btnConnect.addActionListener(new java.awt.event.ActionListener() {
320
                                public void actionPerformed(java.awt.event.ActionEvent e) {
321
                                        rellenarControles();
322
                                }
323
                        });
324
                }
325

    
326
                return btnConnect;
327
        }
328

    
329
        /**
330
         * This method initializes jPanel
331
         *
332
         * @return javax.swing.JPanel
333
         */
334
        private javax.swing.JPanel getJPanel() {
335
                if (jPanel == null) {
336
                        jPanel = new javax.swing.JPanel();
337
                        jPanel.setLayout(null);
338
                        jPanel.setPreferredSize(new java.awt.Dimension(470, 130));
339
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
340
                                        PluginServices.getText(this, "descripcion"),
341
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
342
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
343
                                        null));
344
                        jPanel.setBounds(2, 96, 477, 324);
345
                        jPanel.add(getJLabel1(), null);
346
                        jPanel.add(getLblTitle(), null);
347
                        jPanel.add(getJScrollPane(), null);
348
                }
349

    
350
                return jPanel;
351
        }
352

    
353
        /**
354
         * This method initializes jLabel1
355
         *
356
         * @return javax.swing.JLabel
357
         */
358
        private javax.swing.JLabel getJLabel1() {
359
                if (jLabel1 == null) {
360
                        jLabel1 = new javax.swing.JLabel();
361
                        jLabel1.setText(PluginServices.getText(this, "nombre") + ":");
362
                        jLabel1.setBounds(37, 26, 40, 15);
363
                }
364

    
365
                return jLabel1;
366
        }
367

    
368
        /**
369
         * This method initializes lblTitle
370
         *
371
         * @return javax.swing.JLabel
372
         */
373
        private javax.swing.JLabel getLblTitle() {
374
                if (lblTitle == null) {
375
                        lblTitle = new javax.swing.JLabel();
376
                        lblTitle.setText("-");
377
                        lblTitle.setPreferredSize(new java.awt.Dimension(350, 16));
378
                        lblTitle.setBounds(82, 26, 350, 16);
379
                }
380

    
381
                return lblTitle;
382
        }
383

    
384
        /**
385
         * This method initializes jScrollPane
386
         *
387
         * @return javax.swing.JScrollPane
388
         */
389
        private javax.swing.JScrollPane getJScrollPane() {
390
                if (jScrollPane == null) {
391
                        jScrollPane = new javax.swing.JScrollPane();
392
                        jScrollPane.setViewportView(getTxtAbstract());
393
                        jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60));
394
                        jScrollPane.setBounds(10, 47, 450, 267);
395
                }
396

    
397
                return jScrollPane;
398
        }
399

    
400
        /**
401
         * This method initializes txtAbstract
402
         *
403
         * @return javax.swing.JTextArea
404
         */
405
        private javax.swing.JTextArea getTxtAbstract() {
406
                if (txtAbstract == null) {
407
                        txtAbstract = new javax.swing.JTextArea();
408
                        txtAbstract.setWrapStyleWord(true);
409
                        txtAbstract.setColumns(30);
410
                        txtAbstract.setLineWrap(true);
411
                }
412

    
413
                return txtAbstract;
414
        }
415

    
416
        /**
417
         * This method initializes panelPage1
418
         *
419
         * @return javax.swing.JPanel
420
         */
421
        private javax.swing.JPanel getPanelPage1() {
422
                if (panelPage1 == null) {
423
                        panelPage1 = new javax.swing.JPanel();
424
                        panelPage1.setLayout(null);
425
                        panelPage1.setPreferredSize(new java.awt.Dimension(480, 220));
426
                        panelPage1.setVisible(true);
427
                        panelPage1.setBounds(15, 5, 480, 427);
428
                        panelPage1.add(getJPanel1(), null);
429
                        panelPage1.add(getJPanel(), null);
430
                }
431

    
432
                return panelPage1;
433
        }
434

    
435
        /**
436
         * This method initializes panelPage2
437
         *
438
         * @return javax.swing.JPanel
439
         */
440
        private javax.swing.JPanel getPanelPage2() {
441
                if (wfsParamsPanel == null) {
442
                        wfsParamsPanel = new WFSParamsPanel();
443
                        wfsParamsPanel.setListenerSupport(this.listenerSupport);
444
                        wfsParamsPanel.setBounds(0, 5, 510, 428);
445
                        wfsParamsPanel.getJTabbedPane().addMouseListener(
446
                                        new java.awt.event.MouseAdapter() {
447
                                                public void mouseClicked(java.awt.event.MouseEvent e) {
448
                                                        page = wfsParamsPanel.currentPage() + 1;
449
                                                        activarVisualizarBotones();
450
                                                }
451
                                        });
452
                }
453

    
454
                return wfsParamsPanel;
455
        }
456

    
457

    
458

    
459
        /**
460
         * This method initializes btnSiguiente
461
         *
462
         * @return JButton
463
         */
464
        private JButton getBtnSiguiente() {
465
                if (btnSiguiente == null) {
466
                        btnSiguiente = new JButton();
467
                        btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30));
468
                        btnSiguiente.setBounds(395, 444, 100, 20);
469
                        btnSiguiente.setText(PluginServices.getText(this, "siguiente"));
470
                        btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
471
                                public void actionPerformed(java.awt.event.ActionEvent e) {
472
                                        if (page > 0) {
473
                                                // si page es mayor que cero, vamos enfocando las
474
                                                // sucesivas SOLAPAS del wfsParamsPanel
475
                                                wfsParamsPanel.avanzaTab();
476
                                                page = wfsParamsPanel.getIndiceSolapaActual();
477
                                        }
478
                                        page++;
479

    
480
                                        getPanelPage1().setVisible(false);
481
                                        getPanelPage2().setVisible(true);
482
                                        activarVisualizarBotones();
483
                                }
484
                        });
485
                }
486
                return btnSiguiente;
487
        }
488

    
489
        /**
490
         * This method initializes btnAnterior
491
         *
492
         * @return JButton
493
         */
494
        private JButton getBtnAnterior() {
495
                if (btnAnterior == null) {
496
                        btnAnterior = new JButton();
497
                        btnAnterior.setBounds(292, 444, 100, 20);
498
                        btnAnterior.setText(PluginServices.getText(this, "anterior"));
499
                        btnAnterior.setPreferredSize(new java.awt.Dimension(100, 30));
500
                        btnAnterior.addActionListener(new java.awt.event.ActionListener() {
501
                                public void actionPerformed(java.awt.event.ActionEvent e) {
502
                                        page --;
503
                                        if (page > 0) {
504
                                                // Tenemos que retroceder en el wfsParamsPanel
505
                                                wfsParamsPanel.retrocedeTab();
506
                                                page = wfsParamsPanel.getIndiceSolapaActual() + 1;
507
                                                activarVisualizarBotones();
508
                                        } else if (page==0){
509
                                                activarVisualizarBotones();
510
                                                page = 1;
511
                                                wfsParamsPanel.cleanupWizard();
512
                                                getLblTitle().setText("-");
513
                                                getTxtAbstract().setText("");
514
                                                wfsParamsPanel.retrocedeTab();
515
                                                getPanelPage1().setVisible(true);
516
                                                getPanelPage2().setVisible(false);
517
                                                getBtnSiguiente().setEnabled(false);
518
                                                connected = false;
519
                                        }
520
                                        listenerSupport.callStateChanged(wfsParamsPanel.isCorretlyConfigured());
521
                                }
522
                        });
523
                }
524
                return btnAnterior;
525
        }
526

    
527
        /**
528
         * This method initializes jPanel1
529
         *
530
         * @return javax.swing.JPanel
531
         */
532
        private javax.swing.JPanel getJPanel1() {
533
                if (jPanel1 == null) {
534
                        jPanel1 = new javax.swing.JPanel();
535
                        jPanel1.setLayout(null);
536
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
537
                                        null, PluginServices.getText(this, "server"),
538
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
539
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
540
                        jPanel1.setBounds(2, 5, 477, 85);
541
                        jPanel1.add(getTxtHost(), null);
542
                        jPanel1.add(getBtnConnect(), null);
543
                        jPanel1.add(getChkCaching(), null);
544
                }
545

    
546
                return jPanel1;
547
        }
548

    
549
        /**
550
         * Adds the gvSIG's wizard listener
551
         *
552
         * @param listener
553
         */
554
        public void addWizardListener(WizardListener listener) {
555
                listenerSupport.addWizardListener(listener);
556
        }
557

    
558
        /**
559
         * Removes the gvSIG's wizard listener
560
         *
561
         * @param listener
562
         */
563
        public void removeWizardListener(WizardListener listener) {
564
                listenerSupport.removeWizardListener(listener);
565
        }
566

    
567
        /**
568
         * Returns the Wizard's data source
569
         *
570
         * @return
571
         */
572
        public WFSWizardData getDataSource() {
573
                return dataSource;
574
        }
575

    
576
        /**
577
         * sets the wizard's data source
578
         *
579
         * @param source
580
         */
581
        public void setDataSource(WFSWizardData source) {
582
                dataSource = source;
583
        }
584

    
585
        /**
586
         * Returns the rectangle that contains all the others
587
         *
588
         * Obtiene el rect?ngulo que contiene a todos los otros
589
         *
590
         * @param rects[]  rectangulos
591
         *
592
         * @return Rectangle2D
593
         */
594
        public static Rectangle2D getRectangle(Rectangle2D[] rects) {
595
                Rectangle2D ret = rects[0];
596

    
597
                for (int i = 1; i < rects.length; i++) {
598
                        ret.add(rects[i]);
599
                }
600

    
601
                return ret;
602
        }
603

    
604
        /**
605
         * Returns the host typed in the host text field or null if nothing is typed
606
         * or it is not a valid URL.
607
         *
608
         * Devuelve el host que est? escrito en el cuadro de texto del host o null
609
         * en caso de que no haya nada escrito o est? mal escrito
610
         *
611
         * @return URL del host
612
         */
613
        public URL getHost() {
614
                try {
615
                        return new URL(cmbHost.getModel().getSelectedItem().toString());
616
                } catch (MalformedURLException e) {
617
                        return null;
618
                }
619
        }
620

    
621

    
622
        public void initWizard() {
623
                setDataSource(new WFSWizardData());
624
        }
625

    
626
        public void execute() {
627
        }
628

    
629
        /* (non-Javadoc)
630
         * @see com.iver.cit.gvsig.gui.WizardPanel#getLayer()
631
         */
632
        public FLayer getLayer() {
633
                FLyrWFS layer = (FLyrWFS)wfsParamsPanel.getLayer();
634
                layer.setHost(this.getHost());
635
                layer.setWfsDriver(dataSource.getDriver());
636
                layer.setOnlineResource(dataSource.getOnlineResource());
637
                com.iver.cit.gvsig.gui.View activeView = 
638
                        (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveWindow();
639
                layer.setProjection(CRSFactory.getCRS(layer.getSrs()));
640
                IProjection wfsProjection = CRSFactory.getCRS(layer.getSrs());
641
                IProjection layerProjection = activeView.getMapControl().getProjection(); 
642
                if (!(wfsProjection.equals(layerProjection))){
643
                        layer.setCoordTrans(wfsProjection.getCT(layerProjection));
644
                }
645
                try {
646
                        layer.load();
647
                        if (layer.getNumfeatures() == layer.getWfsDriver().getRowCount()) {
648
                                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),
649
                                                 PluginServices.getText(this,"maxFeatures_aviso"));        
650
                         }
651
                } catch (Exception e) {
652
                        // TODO Auto-generated catch block
653
                        Logger.getLogger(getClass().getName()).error(e.getMessage());
654
                        JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),
655
                                         PluginServices.getText(this,"cantLoad"));
656
                        return null;
657
                }
658

    
659
                return layer;
660
        }
661

    
662
        /**
663
         * This method initializes chkCaching
664
         *
665
         * @return javax.swing.JCheckBox
666
         */
667
        private JCheckBox getChkCaching() {
668
                if (chkCaching == null) {
669
                        chkCaching = new JCheckBox();
670
                        chkCaching.setBounds(7, 51, 349, 20);
671
                        chkCaching.setText(PluginServices.getText(this, "refresh_capabilities"));
672
                        chkCaching.setToolTipText(PluginServices.getText(this, "refresh_capabilities_tooltip"));
673
                        chkCaching.setSelected(refreshing);
674
                        chkCaching.addItemListener(new java.awt.event.ItemListener() {
675
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
676
                                        refreshing = chkCaching.isSelected();
677
                                }
678
                        });
679
                        chkCaching.addActionListener(new java.awt.event.ActionListener() {
680
                                public void actionPerformed(java.awt.event.ActionEvent e) {
681
                                        fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
682
                                }
683
                        });
684

    
685
                }
686
                return chkCaching;
687
        }
688

    
689

    
690

    
691
}