Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / wizards / WFSWizard.java @ 9888

History | View | Annotate | Download (21.8 KB)

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

    
3
import java.awt.FlowLayout;
4
import java.awt.event.KeyAdapter;
5
import java.awt.event.KeyEvent;
6
import java.awt.geom.Rectangle2D;
7
import java.net.MalformedURLException;
8
import java.net.URL;
9
import java.util.prefs.Preferences;
10

    
11
import javax.swing.DefaultComboBoxModel;
12
import org.gvsig.gui.beans.swing.JButton;
13
import javax.swing.JCheckBox;
14
import javax.swing.JLabel;
15
import javax.swing.JPanel;
16

    
17
import com.iver.andami.PluginServices;
18
import com.iver.andami.persistence.serverData.ServerDataPersistence;
19
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver;
20
import com.iver.cit.gvsig.fmap.layers.FLayer;
21
import com.iver.cit.gvsig.fmap.layers.FLyrWFSFactory;
22
import com.iver.cit.gvsig.gui.WizardPanel;
23
import com.iver.cit.gvsig.gui.panels.WFSParamsPanel;
24
import com.iver.utiles.NotExistInXMLEntity;
25
import com.iver.utiles.XMLEntity;
26
import com.iver.utiles.swing.jcomboServer.JComboServer;
27
import com.iver.utiles.swing.jcomboServer.ServerData;
28

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

    
177
        /**
178
         * This is the default constructor
179
         */
180
        public WFSWizard() {
181
                super();
182
                initialize();
183
        }
184

    
185
        /**
186
         * This method initializes this
187
         */
188
        private void initialize() {
189
                setTabName("WFS");
190
                lblServerType = new JLabel();
191
                lblServerType.setBounds(20, 444, 100, 20);
192
                lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
193
                lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
194
                lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11));
195
                lblServerType.setText(PluginServices.getText(this, "server_type")+":");
196
                lblServerTypeValue = new JLabel();
197
                lblServerTypeValue.setBounds(128, 444, 148, 20);
198
                lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11));
199
                lblServerTypeValue.setText("-");
200
                this.setLayout(null);
201
                this.setPreferredSize(new java.awt.Dimension(750, 320));
202
                this.setVisible(true);
203
                this.setSize(518, 468);
204
                this.add(getPanelPage1(), null);
205
                this.add(getPanelPage2(), null);
206
                this.add(getBtnAnterior(), null);
207
                this.add(getBtnSiguiente(), null);
208
                this.add(lblServerType, null);
209
                this.add(lblServerTypeValue, null);
210
                activarVisualizarBotones();
211
        }
212

    
213
        /**
214
         * Adds the host addres to a persistent data storage.
215
         *
216
         * con addHost guardamos la informaci?n del combo de servidores en un
217
         * almac?n persistente
218
         *
219
         * @param host
220
         */
221
        private void addHost(String host) {
222
                host = host.trim();
223
                ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WFS);
224
                persistence.addServerData(new ServerData(host, ServerData.SERVER_TYPE_WFS));
225
        }
226

    
227
        /**
228
         * Fills up the initial WCSWizard controls.
229
         *
230
         * Rellena los primeros controles del WCS Wizard
231
         *
232
         * jaume
233
         */
234
        private void rellenarControles() {
235
                try {
236
                        String host = cmbHost.getModel().getSelectedItem().toString();
237

    
238
                        dataSource.setHost(new URL(host), refreshing);
239
                        addHost(host);
240
                        getLblTitle().setText(dataSource.getTitle());
241
                        getTxtAbstract().setText(dataSource.getAbstract());
242
                        lblServerTypeValue.setText(dataSource.getServerType());
243
                        wfsParamsPanel.setWizardData(dataSource);
244

    
245
                        connected = true;
246
                        activarVisualizarBotones();
247
                } catch (Exception e) {
248
                        listenerSupport.callError(e);
249
                        e.printStackTrace();
250
                }
251
        }
252

    
253
        /**
254
         * Enables or disables the Next and Previous buttons according with the current
255
         * page and the enabled pages.
256
         */
257
        private void activarVisualizarBotones() {
258
                if (page == 0) {
259
                        getBtnAnterior().setEnabled(false);
260
                        getBtnSiguiente().setVisible(true);
261
                        if (connected) {
262
                                getBtnSiguiente().setEnabled(true);
263
                        } else {
264
                                getBtnSiguiente().setEnabled(false);
265
                        }
266
                } else if (page < wfsParamsPanel.getNumTabs()) {
267
                        getBtnSiguiente().setEnabled(true);
268
                        getBtnSiguiente().setVisible(true);
269
                        getBtnAnterior().setEnabled(true);
270
                        getBtnAnterior().setVisible(true);
271
                        if (wfsParamsPanel.nextPageEnabled()==-1){
272
                            getBtnSiguiente().setEnabled(false);
273
                        }
274
                        listenerSupport.callStateChanged(wfsParamsPanel.isCorretlyConfigured());
275
                } else if (page == wfsParamsPanel.getNumTabs()) {
276
                        getBtnSiguiente().setVisible(false);
277
                        getBtnSiguiente().setEnabled(false);
278
                        listenerSupport.callStateChanged(wfsParamsPanel
279
                                        .isCorretlyConfigured());
280
                }
281

    
282
        }
283

    
284

    
285

    
286
        /**
287
         * This method initializes txtHost from the persistent data storage
288
         *
289
         * @return javax.swing.JTextField
290
         */
291
        private javax.swing.JComboBox getTxtHost() {
292
                if (cmbHost == null) {
293
                        cmbHost = new JComboServer();
294
                        cmbHost.setModel(new DefaultComboBoxModel());
295
                        cmbHost.setPreferredSize(new java.awt.Dimension(350, 20));
296
                        cmbHost.setBounds(11, 26, 454, 20);
297
                        cmbHost.setEditable(true);
298

    
299
                        ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WFS);
300
                        ServerData[] servers = persistence.getArrayOfServerData();
301

    
302
                        if (servers.length == 0){
303
                                PluginServices ps = PluginServices.getPluginServices(this);
304
                                XMLEntity xml = ps.getPersistentXML();
305
                                try {
306
                                        String[] oldServers = xml.getStringArrayProperty("wfs-servers");
307
                                        servers = new ServerData[oldServers.length];
308
                                        for (int i=0; i<oldServers.length; i++) {
309
                                                servers[i] = new ServerData(oldServers[i],ServerData.SERVER_TYPE_WMS);
310
                                        }
311
                                        xml.remove("wfs-servers");
312
                                        ps.setPersistentXML(xml);
313
                                } catch (NotExistInXMLEntity e) {
314
                                        // Old servers doesn't exist
315
                                        servers = new ServerData[1];
316
                                        servers[0] = new ServerData("http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap",ServerData.SERVER_TYPE_WFS);
317
                                }
318

    
319
                                for (int i=0 ; i<servers.length ; i++){
320
                                        persistence.addServerData(servers[i]);
321
                                }
322
                                persistence.setPersistent();
323
                        }
324

    
325
                        cmbHost.setServerList(servers);
326
                        
327
                        // Allows that user can start the connection to the written server pressing the 'Enter' key
328
                        cmbHost.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
329
                                /*
330
                                 * (non-Javadoc)
331
                                 * @see java.awt.event.KeyAdapter#keyReleased(java.awt.event.KeyEvent)
332
                                 */
333
                                public void keyReleased(KeyEvent e) {
334
                                        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
335
                                                rellenarControles();
336
                                                getBtnSiguiente().requestFocus(); // Sets focus to the 'next' button
337
                                        }
338
                                }
339
                        });
340
                }
341
                return cmbHost;
342
        }
343

    
344

    
345
        /**
346
         * This method initializes btnDetalles
347
         *
348
         * @return JButton
349
         */
350
        private JButton getBtnConnect() {
351
                if (btnConnect == null) {
352
                        btnConnect = new JButton();
353
                        btnConnect.setPreferredSize(new java.awt.Dimension(100, 20));
354
                        btnConnect.setBounds(366, 50, 100, 20);
355
                        btnConnect.setText(PluginServices.getText(this, "connect"));
356
                        btnConnect.addActionListener(new java.awt.event.ActionListener() {
357
                                public void actionPerformed(java.awt.event.ActionEvent e) {
358
                                        btnConnect.setEnabled(false); // This avoids multiple contiguous actions 
359
                                        rellenarControles();
360
                                        btnConnect.setEnabled(true); // This avoids multiple contiguous actions
361
                                }
362
                        });
363
                        
364
                        // If user press the 'Enter' key -> advance
365
                        btnConnect.addKeyListener(new KeyAdapter() {
366
                                /*
367
                                 *  (non-Javadoc)
368
                                 * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
369
                                 */
370
                                public void keyReleased(KeyEvent e) {
371
                                        // TODO Auto-generated method stub
372
                                        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
373
                                                btnConnect.doClick();
374
                                                getBtnSiguiente().requestFocus();
375
                                        }
376
                                }                
377
                        });
378
                }
379

    
380
                return btnConnect;
381
        }
382

    
383
        /**
384
         * This method initializes jPanel
385
         *
386
         * @return javax.swing.JPanel
387
         */
388
        private javax.swing.JPanel getJPanel() {
389
                if (jPanel == null) {
390
                        jPanel = new javax.swing.JPanel();
391
                        jPanel.setLayout(null);
392
                        jPanel.setPreferredSize(new java.awt.Dimension(470, 130));
393
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
394
                                        PluginServices.getText(this, "descripcion"),
395
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
396
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
397
                                        null));
398
                        jPanel.setBounds(2, 96, 477, 324);
399
                        jPanel.add(getJScrollPane(), null);
400
                        jPanel.add(getPnlName(), null);
401
                }
402

    
403
                return jPanel;
404
        }
405
        
406
        /**
407
         * This method initializes pnlName
408
         *
409
         * @return javax.swing.JPanel
410
         */
411
        private JPanel getPnlName() {
412
                if (pnlName == null) {
413
                        pnlName = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0));
414
                        pnlName.setBounds(new java.awt.Rectangle(9,19,452,24));
415
                        pnlName.add(getJLabel1(), null);
416
                        pnlName.add(getLblTitle(), null);
417
                }
418
                return pnlName;
419
        }
420

    
421
        /**
422
         * This method initializes jLabel1
423
         *
424
         * @return javax.swing.JLabel
425
         */
426
        private javax.swing.JLabel getJLabel1() {
427
                if (jLabel1 == null) {
428
                        jLabel1 = new javax.swing.JLabel();
429
                        jLabel1.setText(PluginServices.getText(this, "nombre") + ":");
430
                        jLabel1.setBounds(15, 26, 65, 15);
431
                }
432

    
433
                return jLabel1;
434
        }
435

    
436
        /**
437
         * This method initializes lblTitle
438
         *
439
         * @return javax.swing.JLabel
440
         */
441
        private javax.swing.JLabel getLblTitle() {
442
                if (lblTitle == null) {
443
                        lblTitle = new javax.swing.JLabel();
444
                        lblTitle.setText("-");
445
                        lblTitle.setPreferredSize(new java.awt.Dimension(350, 16));
446
                        lblTitle.setBounds(82, 26, 350, 16);
447
                }
448

    
449
                return lblTitle;
450
        }
451

    
452
        /**
453
         * This method initializes jScrollPane
454
         *
455
         * @return javax.swing.JScrollPane
456
         */
457
        private javax.swing.JScrollPane getJScrollPane() {
458
                if (jScrollPane == null) {
459
                        jScrollPane = new javax.swing.JScrollPane();
460
                        jScrollPane.setViewportView(getTxtAbstract());
461
                        jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60));
462
                        jScrollPane.setBounds(10, 47, 457, 267);
463
                }
464

    
465
                return jScrollPane;
466
        }
467

    
468
        /**
469
         * This method initializes txtAbstract
470
         *
471
         * @return javax.swing.JTextArea
472
         */
473
        private javax.swing.JTextArea getTxtAbstract() {
474
                if (txtAbstract == null) {
475
                        txtAbstract = new javax.swing.JTextArea();
476
                        txtAbstract.setWrapStyleWord(true);
477
                        txtAbstract.setColumns(30);
478
                        txtAbstract.setLineWrap(true);
479
                }
480

    
481
                return txtAbstract;
482
        }
483

    
484
        /**
485
         * This method initializes panelPage1
486
         *
487
         * @return javax.swing.JPanel
488
         */
489
        private javax.swing.JPanel getPanelPage1() {
490
                if (panelPage1 == null) {
491
                        panelPage1 = new javax.swing.JPanel();
492
                        panelPage1.setLayout(null);
493
                        panelPage1.setPreferredSize(new java.awt.Dimension(480, 220));
494
                        panelPage1.setVisible(true);
495
                        panelPage1.setBounds(15, 5, 480, 427);
496
                        panelPage1.add(getJPanel1(), null);
497
                        panelPage1.add(getJPanel(), null);
498
                }
499

    
500
                return panelPage1;
501
        }
502

    
503
        /**
504
         * This method initializes panelPage2
505
         *
506
         * @return javax.swing.JPanel
507
         */
508
        private javax.swing.JPanel getPanelPage2() {
509
                if (wfsParamsPanel == null) {
510
                        wfsParamsPanel = new WFSParamsPanel();
511
                        wfsParamsPanel.setListenerSupport(this.listenerSupport);
512
                        wfsParamsPanel.setBounds(0, 5, 510, 428);
513
                        wfsParamsPanel.getJTabbedPane().addMouseListener(
514
                                        new java.awt.event.MouseAdapter() {
515
                                                public void mouseClicked(java.awt.event.MouseEvent e) {
516
                                                        page = wfsParamsPanel.currentPage() + 1;
517
                                                        activarVisualizarBotones();
518
                                                }
519
                                        });
520
                }
521

    
522
                return wfsParamsPanel;
523
        }
524

    
525

    
526

    
527
        /**
528
         * This method initializes btnSiguiente
529
         *
530
         * @return JButton
531
         */
532
        private JButton getBtnSiguiente() {
533
                if (btnSiguiente == null) {
534
                        btnSiguiente = new JButton();
535
                        btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30));
536
                        btnSiguiente.setBounds(395, 444, 100, 20);
537
                        btnSiguiente.setText(PluginServices.getText(this, "siguiente"));
538
                        btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
539
                                public void actionPerformed(java.awt.event.ActionEvent e) {
540
                                        if (page > 0) {
541
                                                // si page es mayor que cero, vamos enfocando las
542
                                                // sucesivas SOLAPAS del wfsParamsPanel
543
                                                wfsParamsPanel.avanzaTab();
544
                                                page = wfsParamsPanel.getIndiceSolapaActual();
545
                                        }
546
                                        page++;
547

    
548
                                        getPanelPage1().setVisible(false);
549
                                        getPanelPage2().setVisible(true);
550
                                        activarVisualizarBotones();
551
                                }
552
                        });                        
553
                }
554
                return btnSiguiente;
555
        }
556

    
557
        /**
558
         * This method initializes btnAnterior
559
         *
560
         * @return JButton
561
         */
562
        private JButton getBtnAnterior() {
563
                if (btnAnterior == null) {
564
                        btnAnterior = new JButton();
565
                        btnAnterior.setBounds(292, 444, 100, 20);
566
                        btnAnterior.setText(PluginServices.getText(this, "anterior"));
567
                        btnAnterior.setPreferredSize(new java.awt.Dimension(100, 30));
568
                        btnAnterior.addActionListener(new java.awt.event.ActionListener() {
569
                                public void actionPerformed(java.awt.event.ActionEvent e) {
570
                                        page --;
571
                                        if (page > 0) {
572
                                                // Tenemos que retroceder en el wfsParamsPanel
573
                                                wfsParamsPanel.retrocedeTab();
574
                                                page = wfsParamsPanel.getIndiceSolapaActual() + 1;
575
                                                activarVisualizarBotones();
576
                                        } else if (page==0){
577
                                                activarVisualizarBotones();
578
                                                page = 1;
579
                                                wfsParamsPanel.cleanupWizard();
580
                                                getLblTitle().setText("-");
581
                                                getTxtAbstract().setText("");
582
                                                wfsParamsPanel.retrocedeTab();
583
                                                getPanelPage1().setVisible(true);
584
                                                getPanelPage2().setVisible(false);
585
                                                getBtnSiguiente().setEnabled(false);
586
                                                connected = false;
587
                                        }
588
                                        listenerSupport.callStateChanged(wfsParamsPanel.isCorretlyConfigured());
589
                                }
590
                        });
591
                }
592
                return btnAnterior;
593
        }
594

    
595
        /**
596
         * This method initializes jPanel1
597
         *
598
         * @return javax.swing.JPanel
599
         */
600
        private javax.swing.JPanel getJPanel1() {
601
                if (jPanel1 == null) {
602
                        jPanel1 = new javax.swing.JPanel();
603
                        jPanel1.setLayout(null);
604
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
605
                                        null, PluginServices.getText(this, "server"),
606
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
607
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
608
                        jPanel1.setBounds(2, 5, 477, 85);
609
                        jPanel1.add(getTxtHost(), null);
610
                        jPanel1.add(getBtnConnect(), null);
611
                        jPanel1.add(getChkCaching(), null);        
612
                }
613

    
614
                return jPanel1;
615
        }
616

    
617
        /**
618
         * Adds the gvSIG's wizard listener
619
         *
620
         * @param listener
621
         */
622
        public void addWizardListener(WizardListener listener) {
623
                listenerSupport.addWizardListener(listener);
624
        }
625

    
626
        /**
627
         * Removes the gvSIG's wizard listener
628
         *
629
         * @param listener
630
         */
631
        public void removeWizardListener(WizardListener listener) {
632
                listenerSupport.removeWizardListener(listener);
633
        }
634

    
635
        /**
636
         * Returns the Wizard's data source
637
         *
638
         * @return
639
         */
640
        public WFSWizardData getDataSource() {
641
                return dataSource;
642
        }
643

    
644
        /**
645
         * sets the wizard's data source
646
         *
647
         * @param source
648
         */
649
        public void setDataSource(WFSWizardData source) {
650
                dataSource = source;
651
        }
652

    
653
        /**
654
         * Returns the rectangle that contains all the others
655
         *
656
         * Obtiene el rect?ngulo que contiene a todos los otros
657
         *
658
         * @param rects[]  rectangulos
659
         *
660
         * @return Rectangle2D
661
         */
662
        public static Rectangle2D getRectangle(Rectangle2D[] rects) {
663
                Rectangle2D ret = rects[0];
664

    
665
                for (int i = 1; i < rects.length; i++) {
666
                        ret.add(rects[i]);
667
                }
668

    
669
                return ret;
670
        }
671

    
672
        /**
673
         * Returns the host typed in the host text field or null if nothing is typed
674
         * or it is not a valid URL.
675
         *
676
         * Devuelve el host que est? escrito en el cuadro de texto del host o null
677
         * en caso de que no haya nada escrito o est? mal escrito
678
         *
679
         * @return URL del host
680
         */
681
        public URL getHost() {
682
                try {
683
                        return new URL(cmbHost.getModel().getSelectedItem().toString());
684
                } catch (MalformedURLException e) {
685
                        return null;
686
                }
687
        }
688

    
689

    
690
        public void initWizard() {
691
                setDataSource(new WFSWizardData());
692
        }
693

    
694
        public void execute() {
695
        }
696

    
697
        /* (non-Javadoc)
698
         * @see com.iver.cit.gvsig.gui.WizardPanel#getLayer()
699
         */
700
        public FLayer getLayer() {
701
                FLayer layer = wfsParamsPanel.getLayer(); 
702
                URL host = getHost();
703
                String onlineResource = dataSource.getOnlineResource();
704
                FMapWFSDriver driver = dataSource.getDriver();
705
                return new FLyrWFSFactory().getFLyrWFS(layer,host,onlineResource,driver,true);
706
        }
707

    
708
        /**
709
         * This method initializes chkCaching
710
         *
711
         * @return javax.swing.JCheckBox
712
         */
713
        private JCheckBox getChkCaching() {
714
                if (chkCaching == null) {
715
                        chkCaching = new JCheckBox();
716
                        chkCaching.setBounds(7, 51, 349, 20);
717
                        chkCaching.setText(PluginServices.getText(this, "refresh_capabilities"));
718
                        chkCaching.setToolTipText(PluginServices.getText(this, "refresh_capabilities_tooltip"));
719
                        chkCaching.setSelected(refreshing);
720
                        chkCaching.addItemListener(new java.awt.event.ItemListener() {
721
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
722
                                        refreshing = chkCaching.isSelected();
723
                                }
724
                        });
725
                        chkCaching.addActionListener(new java.awt.event.ActionListener() {
726
                                public void actionPerformed(java.awt.event.ActionEvent e) {
727
                                        chkCaching.setEnabled(false); // This avoids multiple contiguous actions
728
                                        fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
729
                                        chkCaching.setEnabled(true); // This avoids multiple contiguous actions
730
                                }
731
                        });
732

    
733
                }
734
                return chkCaching;
735
        }
736

    
737
        /**
738
         * This method makes the 'btnSiguiente' to be clicked
739
         */
740
        public void doClickOnNextButton() {
741
                getBtnSiguiente().doClick();
742
        }
743
}