Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / wizards / WFSWizard.java @ 24753

History | View | Annotate | Download (22.6 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 javax.swing.JCheckBox;
13
import javax.swing.JLabel;
14
import javax.swing.JOptionPane;
15
import javax.swing.JPanel;
16
import javax.swing.JTabbedPane;
17
import javax.swing.event.ChangeEvent;
18
import javax.swing.event.ChangeListener;
19

    
20
import org.gvsig.exceptions.BaseException;
21
import org.gvsig.gui.beans.Messages;
22
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
23
import org.gvsig.gui.beans.swing.JButton;
24

    
25
import com.iver.andami.PluginServices;
26
import com.iver.andami.messages.NotificationManager;
27
import com.iver.andami.persistence.serverData.ServerDataPersistence;
28
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver;
29
import com.iver.cit.gvsig.fmap.layers.FLayer;
30
import com.iver.cit.gvsig.fmap.layers.FLyrWFSFactory;
31
import com.iver.cit.gvsig.gui.WizardPanel;
32
import com.iver.cit.gvsig.gui.panels.WFSParamsPanel;
33
import com.iver.cit.gvsig.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint;
34
import com.iver.utiles.NotExistInXMLEntity;
35
import com.iver.utiles.XMLEntity;
36
import com.iver.utiles.swing.jcomboServer.JComboServer;
37
import com.iver.utiles.swing.jcomboServer.ServerData;
38

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

    
164
/**
165
 * <p>Wizard that allows add a new WFS layer.</p>
166
 * 
167
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
168
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
169
 */
170
public class WFSWizard extends WizardPanel {
171
        private int page;
172
        private boolean connected = false;
173
        private JComboServer cmbHost = null;
174
        private JButton btnConnect = null;
175
        private javax.swing.JPanel jPanel = null;
176
        private javax.swing.JLabel jLabel1 = null;
177
        private javax.swing.JLabel lblTitle = null;
178
        private javax.swing.JScrollPane jScrollPane = null;
179
        private javax.swing.JTextArea txtAbstract = null;
180
        private javax.swing.JPanel panelPage1 = null;
181
        private javax.swing.JPanel pnlName = null;
182
        private JButton btnSiguiente = null;
183
        private JButton btnAnterior = null;
184
        private javax.swing.JPanel jPanel1 = null;
185
        private WFSParamsPanel wfsParamsPanel = null;
186
        private WFSWizardData dataSource = null;
187
        private JLabel lblServerType = null;
188
        private JLabel lblServerTypeValue = null;
189
        private JCheckBox chkCaching = null;
190
        private static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wfs-wizard" );
191
        private boolean refreshing = fPrefs.getBoolean("refresh_capabilities", false);
192
        private final String wfs_properties_extensionpoint_name = "WFSPropertiesDialog";
193

    
194
        /**
195
         * This is the default constructor
196
         */
197
        public WFSWizard() {
198
                super();
199
                initialize();
200
        }
201

    
202
        /**
203
         * This method initializes this
204
         */
205
        private void initialize() {
206
                setTabName(PluginServices.getText(this, "WFS"));
207

    
208
                lblServerType = new JLabel();
209
                lblServerType.setBounds(20, 444, 100, 20);
210
                lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
211
                lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
212
                lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11));
213
                lblServerType.setText(PluginServices.getText(this, "server_type")+":");
214
                lblServerTypeValue = new JLabel();
215
                lblServerTypeValue.setBounds(128, 444, 148, 20);
216
                lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11));
217
                lblServerTypeValue.setText("-");
218

    
219
                this.setLayout(null);
220
//                this.setPreferredSize(new java.awt.Dimension(750, 320));
221
//                this.setPreferredSize(new Dimension(750, 320));
222
                this.setVisible(true);
223
//                this.setSize(518, 468);
224

    
225
                this.add(getPanelPage1(), null);
226
                page = 0;
227
                this.add(getPanelPage2(), null);
228
        
229
                this.add(getBtnAnterior(), null);
230
                this.add(getBtnSiguiente(), null);
231

    
232
                this.add(lblServerType, null);
233
                this.add(lblServerTypeValue, null);
234

    
235
                uptateNavigatingButtons();
236
        }
237

    
238
        /**
239
         * Adds the host addres to a persistent data storage.
240
         *
241
         * @param host the host of the server
242
         */
243
        private void addHost(String host) {
244
                host = host.trim();
245
                ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WFS);
246
                persistence.addServerData(new ServerData(host, ServerData.SERVER_TYPE_WFS));
247
        }
248

    
249
        /**
250
         * Fills up the initial WCSWizard controls.
251
         *
252
         * jaume
253
         */
254
        private void rellenarControles() throws Exception{
255
                try {
256
                        String host = cmbHost.getModel().getSelectedItem().toString();
257

    
258
                        URL url = new URL(host);
259
                
260
                        dataSource.setHost(url, refreshing);
261
                        addHost(host);
262
                        getLblTitle().setText(dataSource.getTitle());
263
                        getTxtAbstract().setText(dataSource.getAbstract());
264
                        lblServerTypeValue.setText(dataSource.getServerType());
265
                        wfsParamsPanel.setWizardData(dataSource);
266
                        connected = true;
267
                } catch(Exception e) {                                
268
                        throw e;
269
                }
270
        }
271

    
272
        /**
273
         * Enables or disables the Next and Previous buttons according with the current
274
         * page and the enabled pages.
275
         */
276
        private void uptateNavigatingButtons() {
277
                if (page == 0) {
278
                        getBtnAnterior().setEnabled(false);
279
                        getBtnSiguiente().setVisible(true);
280
                        getBtnSiguiente().setEnabled(false);
281
                }
282
                else {
283
                        short tabIndex = (short) wfsParamsPanel.getSelectedIndex();
284
                        
285
                        getBtnAnterior().setEnabled(true);
286
                        if (wfsParamsPanel.nextPageEnabled() == -1) {
287
                            getBtnSiguiente().setEnabled(false);
288
                            
289
                            if (tabIndex == (wfsParamsPanel.getPanelInGUICount() -1))
290
                                        getBtnSiguiente().setVisible(false);
291
                        }
292
                        else {
293
                                getBtnSiguiente().setVisible(true);
294
                                getBtnSiguiente().setEnabled(true);
295
                        }
296
                }
297
        }
298

    
299
        /**
300
         * This method initializes txtHost from the persistent data storage
301
         *
302
         * @return javax.swing.JTextField
303
         */
304
        private javax.swing.JComboBox getTxtHost() {
305
                if (cmbHost == null) {
306
                        cmbHost = new JComboServer();
307
                        cmbHost.setModel(new DefaultComboBoxModel());
308
                        cmbHost.setPreferredSize(new java.awt.Dimension(350, 20));
309
                        cmbHost.setBounds(11, 26, 454, 20);
310
                        cmbHost.setEditable(true);
311

    
312
                        ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WFS);
313
                        ServerData[] servers = persistence.getArrayOfServerData();
314

    
315
                        if (servers.length == 0){
316
                                PluginServices ps = PluginServices.getPluginServices(this);
317
                                XMLEntity xml = ps.getPersistentXML();
318
                                try {
319
                                        String[] oldServers = xml.getStringArrayProperty("wfs-servers");
320
                                        servers = new ServerData[oldServers.length];
321
                                        for (int i=0; i<oldServers.length; i++) {
322
                                                servers[i] = new ServerData(oldServers[i],ServerData.SERVER_TYPE_WMS);
323
                                        }
324
                                        xml.remove("wfs-servers");
325
                                        ps.setPersistentXML(xml);
326
                                } catch (NotExistInXMLEntity e) {
327
                                        // Old servers doesn't exist
328
                                        servers = new ServerData[2];
329
                                        servers[0] = new ServerData("http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap",ServerData.SERVER_TYPE_WFS);
330
                                        servers[1] = new ServerData("http://www.idee.es/IDEE-WFS/ogcwebservice",ServerData.SERVER_TYPE_WFS);
331
                                }
332

    
333
                                for (int i = 0; i < servers.length; i++){
334
                                        persistence.addServerData(servers[i]);
335
                                }
336
                                persistence.setPersistent();
337
                        }
338

    
339
                        cmbHost.setServerList(servers);
340

    
341
                        // Allows that user can start the connection to the written server pressing the 'Enter' key
342
                        cmbHost.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
343
                                /*
344
                                 * (non-Javadoc)
345
                                 * @see java.awt.event.KeyAdapter#keyReleased(java.awt.event.KeyEvent)
346
                                 */
347
                                public void keyReleased(KeyEvent e) {
348
                                        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
349
                                                getBtnConnect().doClick();
350
                                        }
351
                                }
352
                        });
353
                }
354
                return cmbHost;
355
        }
356

    
357
        /**
358
         * This method initializes btnDetalles
359
         *
360
         * @return JButton
361
         */
362
        private JButton getBtnConnect() {
363
                if (btnConnect == null) {
364
                        btnConnect = new JButton();
365
                        btnConnect.setPreferredSize(new java.awt.Dimension(100, 20));
366
                        btnConnect.setBounds(366, 50, 100, 20);
367
                        btnConnect.setText(PluginServices.getText(this, "connect"));
368
                        btnConnect.addActionListener(new java.awt.event.ActionListener() {
369
                                public void actionPerformed(java.awt.event.ActionEvent e) {
370
                                        btnConnect.setEnabled(false); // This avoids multiple contiguous actions
371

    
372
                                        try {
373
                                                rellenarControles();
374
                                                wfsParamsPanel.refreshCapabilitiesInfo();
375
                                                wfsParamsPanel.refreshWFSSelectFeaturePanel();
376
                                                wfsParamsPanel.enableDefaultTabs(false);
377
                                                btnConnect.setEnabled(true); // This avoids multiple contiguous actions
378
                                                
379
                                                getBtnSiguiente().setEnabled(true);
380
                                                getBtnSiguiente().requestFocus(); // Sets focus to the 'next' button
381
                                        }
382
                                        catch(Exception e1) {
383
                                                JOptionPane.showMessageDialog(null, 
384
                                                                Messages.getText("invalid_url"), 
385
                                                                Messages.getText("warning"),
386
                                                                JOptionPane.WARNING_MESSAGE);
387
                                                btnConnect.setEnabled(true); 
388
                                        }
389
                                }
390
                        });
391

    
392
                        // If user press the 'Enter' key -> advance
393
                        btnConnect.addKeyListener(new KeyAdapter() {
394
                                /*
395
                                 *  (non-Javadoc)
396
                                 * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
397
                                 */
398
                                public void keyReleased(KeyEvent e) {
399
                                        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
400
                                                btnConnect.doClick();
401
                                        }
402
                                }
403
                        });
404
                }
405

    
406
                return btnConnect;
407
        }
408

    
409
        /**
410
         * This method initializes jPanel
411
         *
412
         * @return javax.swing.JPanel
413
         */
414
        private javax.swing.JPanel getJPanel() {
415
                if (jPanel == null) {
416
                        jPanel = new javax.swing.JPanel();
417
                        jPanel.setLayout(null);
418
                        jPanel.setPreferredSize(new java.awt.Dimension(470, 130));
419
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
420
                                        PluginServices.getText(this, "descripcion"),
421
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
422
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
423
                                        null));
424
                        jPanel.setBounds(2, 96, 477, 324);
425
                        jPanel.add(getJScrollPane(), null);
426
                        jPanel.add(getPnlName(), null);
427
                }
428

    
429
                return jPanel;
430
        }
431

    
432
        /**
433
         * This method initializes pnlName
434
         *
435
         * @return javax.swing.JPanel
436
         */
437
        private JPanel getPnlName() {
438
                if (pnlName == null) {
439
                        pnlName = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0));
440
                        pnlName.setBounds(new java.awt.Rectangle(9,19,452,24));
441
                        pnlName.add(getJLabel1(), null);
442
                        pnlName.add(getLblTitle(), null);
443
                }
444
                return pnlName;
445
        }
446

    
447
        /**
448
         * This method initializes jLabel1
449
         *
450
         * @return javax.swing.JLabel
451
         */
452
        private javax.swing.JLabel getJLabel1() {
453
                if (jLabel1 == null) {
454
                        jLabel1 = new javax.swing.JLabel();
455
                        jLabel1.setText(PluginServices.getText(this, "nombre") + ":");
456
                        jLabel1.setBounds(15, 26, 65, 15);
457
                }
458

    
459
                return jLabel1;
460
        }
461

    
462
        /**
463
         * This method initializes lblTitle
464
         *
465
         * @return javax.swing.JLabel
466
         */
467
        private javax.swing.JLabel getLblTitle() {
468
                if (lblTitle == null) {
469
                        lblTitle = new javax.swing.JLabel();
470
                        lblTitle.setText("-");
471
                        lblTitle.setPreferredSize(new java.awt.Dimension(350, 16));
472
                        lblTitle.setBounds(82, 26, 350, 16);
473
                }
474

    
475
                return lblTitle;
476
        }
477

    
478
        /**
479
         * This method initializes jScrollPane
480
         *
481
         * @return javax.swing.JScrollPane
482
         */
483
        private javax.swing.JScrollPane getJScrollPane() {
484
                if (jScrollPane == null) {
485
                        jScrollPane = new javax.swing.JScrollPane();
486
                        jScrollPane.setViewportView(getTxtAbstract());
487
                        jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60));
488
                        jScrollPane.setBounds(10, 47, 457, 267);
489
                }
490

    
491
                return jScrollPane;
492
        }
493

    
494
        /**
495
         * This method initializes txtAbstract
496
         *
497
         * @return javax.swing.JTextArea
498
         */
499
        private javax.swing.JTextArea getTxtAbstract() {
500
                if (txtAbstract == null) {
501
                        txtAbstract = new javax.swing.JTextArea();
502
                        txtAbstract.setWrapStyleWord(true);
503
                        txtAbstract.setColumns(30);
504
                        txtAbstract.setLineWrap(true);
505
                }
506

    
507
                return txtAbstract;
508
        }
509

    
510
        /**
511
         * This method initializes panelPage1
512
         *
513
         * @return javax.swing.JPanel
514
         */
515
        private javax.swing.JPanel getPanelPage1() {
516
                if (panelPage1 == null) {
517
                        panelPage1 = new javax.swing.JPanel();
518
                        panelPage1.setLayout(null);
519
                        panelPage1.setPreferredSize(new java.awt.Dimension(480, 220));
520
                        panelPage1.setVisible(true);
521
                        panelPage1.setBounds(15, 5, 480, 427);
522
                        panelPage1.add(getJPanel1(), null);
523
                        panelPage1.add(getJPanel(), null);
524
                }
525

    
526
                return panelPage1;
527
        }
528

    
529
        /**
530
         * This method initializes panelPage2
531
         *
532
         * @return javax.swing.JPanel
533
         */
534
        private javax.swing.JPanel getPanelPage2() {
535
                if (wfsParamsPanel == null) {
536

    
537
                        try {
538
                                PanelGroupManager manager = PanelGroupManager.getManager();
539
                                manager.registerPanelGroup(WFSParamsPanel.class);
540
                                manager.setDefaultType(WFSParamsPanel.class);
541

    
542
                                // Initially there is no layer
543
                                wfsParamsPanel = (WFSParamsPanel) manager.getPanelGroup(null);
544
                                wfsParamsPanel.setBounds(4, 9, 502, 423);
545
                                wfsParamsPanel.loadPanels(new PanelGroupLoaderFromExtensionPoint(wfs_properties_extensionpoint_name));
546
                                wfsParamsPanel.addChangeListener(new ChangeListener() {
547
                                // This method is called whenever the selected tab changes
548
                                public void stateChanged(ChangeEvent evt) {
549
                                    JTabbedPane pane = (JTabbedPane)evt.getSource();
550

    
551
                                    // Update the navigation buttons
552
                                    uptateNavigatingButtons();
553
                                }
554
                            });
555
                        } catch (BaseException bE) {
556
                                NotificationManager.showMessageError(bE.getLocalizedMessageStack(), bE);
557
                        } catch (Exception e) {
558
                                NotificationManager.showMessageError(e.getLocalizedMessage(), e);
559
                        }
560
                }
561

    
562
                return wfsParamsPanel;
563
        }
564

    
565
        /**
566
         * This method initializes btnSiguiente
567
         *
568
         * @return JButton
569
         */
570
        private JButton getBtnSiguiente() {
571
                if (btnSiguiente == null) {
572
                        btnSiguiente = new JButton();
573
                        btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30));
574
                        btnSiguiente.setBounds(395, 444, 100, 20);
575
                        btnSiguiente.setText(PluginServices.getText(this, "siguiente"));
576
                        btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
577
                                public void actionPerformed(java.awt.event.ActionEvent e) {
578
                                        if (page == 0) {
579
                                                page = 1;
580
                                                getPanelPage1().setVisible(false);
581
                                                getPanelPage2().setVisible(true);
582
                                        }
583
                                        else {
584
                                                wfsParamsPanel.goToNextTab();
585
                                        }
586

    
587
                                        uptateNavigatingButtons();
588
                                }
589
                        });
590
                }
591
                return btnSiguiente;
592
        }
593

    
594
        /**
595
         * This method initializes btnAnterior
596
         *
597
         * @return JButton
598
         */
599
        private JButton getBtnAnterior() {
600
                if (btnAnterior == null) {
601
                        btnAnterior = new JButton();
602
                        btnAnterior.setBounds(292, 444, 100, 20);
603
                        btnAnterior.setText(PluginServices.getText(this, "anterior"));
604
                        btnAnterior.setPreferredSize(new java.awt.Dimension(100, 30));
605
                        btnAnterior.addActionListener(new java.awt.event.ActionListener() {
606
                                public void actionPerformed(java.awt.event.ActionEvent e) {
607
                                        int tabIndex = wfsParamsPanel.getSelectedIndex();
608
                                        
609
                                        if (page == 1) {
610
                                                if (tabIndex == 0) {
611
                                                        page = 0;
612
                                                        connected = false;
613

    
614
                                                        wfsParamsPanel.enableDefaultTabs(false);
615
                                                        getLblTitle().setText("-");
616
                                                        getTxtAbstract().setText("");
617

    
618

    
619
                                                        getPanelPage2().setVisible(false);
620
                                                        getPanelPage1().setVisible(true);
621
                                                }
622
                                                else {
623
                                                        wfsParamsPanel.goToPreviousTab();        
624
                                                }
625
                                        }
626
                                        else {
627
                                                
628
                                        }
629
                                        
630
                                        uptateNavigatingButtons();
631
                                }
632
                        });
633
                }
634
                return btnAnterior;
635
        }
636

    
637
        /**
638
         * This method initializes jPanel1
639
         *
640
         * @return javax.swing.JPanel
641
         */
642
        private javax.swing.JPanel getJPanel1() {
643
                if (jPanel1 == null) {
644
                        jPanel1 = new javax.swing.JPanel();
645
                        jPanel1.setLayout(null);
646
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
647
                                        null, PluginServices.getText(this, "server"),
648
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
649
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
650
                        jPanel1.setBounds(2, 5, 477, 85);
651
                        jPanel1.add(getTxtHost(), null);
652
                        jPanel1.add(getBtnConnect(), null);
653
                        jPanel1.add(getChkCaching(), null);
654
                }
655

    
656
                return jPanel1;
657
        }
658

    
659
        /**
660
         * Returns the wizard's data source
661
         *
662
         * @return the wizard's data source
663
         */
664
        public WFSWizardData getDataSource() {
665
                return dataSource;
666
        }
667

    
668
        /**
669
         * Sets the wizard's data source
670
         *
671
         * @param source the wizard's data source
672
         */
673
        public void setDataSource(WFSWizardData source) {
674
                dataSource = source;
675
        }
676

    
677
        /**
678
         * Returns the rectangle that contains all the others
679
         *
680
         * @param rects[] rectangles with its positions and dimensions
681
         *
682
         * @return Rectangle2D the rectangle that contains all the others
683
         */
684
        public static Rectangle2D getRectangle(Rectangle2D[] rects) {
685
                Rectangle2D ret = rects[0];
686

    
687
                for (int i = 1; i < rects.length; i++) {
688
                        ret.add(rects[i]);
689
                }
690

    
691
                return ret;
692
        }
693

    
694
        /**
695
         * Returns the host typed in the host text field or null if nothing is typed
696
         * or it is not a valid URL.
697
         *
698
         * @return URL del host
699
         */
700
        public URL getHost() {
701
                try {
702
                        return new URL(cmbHost.getModel().getSelectedItem().toString());
703
                } catch (MalformedURLException e) {
704
                        return null;
705
                }
706
        }
707

    
708
        /*
709
         * (non-Javadoc)
710
         * @see com.iver.cit.gvsig.gui.WizardPanel#initWizard()
711
         */
712
        public void initWizard() {
713
                setDataSource(new WFSWizardData());
714
        }
715

    
716
        /*
717
         * (non-Javadoc)
718
         * @see com.iver.cit.gvsig.gui.WizardPanel#execute()
719
         */
720
        public void execute() {
721
        }
722

    
723
        /*
724
         * (non-Javadoc)
725
         * @see com.iver.cit.gvsig.gui.WizardPanel#getLayer()
726
         */
727
        public FLayer getLayer() {
728
                FLayer layer = wfsParamsPanel.getLayer();
729
                URL host = getHost();
730
                String onlineResource = dataSource.getOnlineResource();
731
                FMapWFSDriver driver = dataSource.getDriver();
732
                return new FLyrWFSFactory().getFLyrWFS(layer,host,onlineResource,driver,true,true);
733
        }
734

    
735
        /**
736
         * This method initializes chkCaching
737
         *
738
         * @return javax.swing.JCheckBox
739
         */
740
        private JCheckBox getChkCaching() {
741
                if (chkCaching == null) {
742
                        chkCaching = new JCheckBox();
743
                        chkCaching.setBounds(7, 51, 349, 20);
744
                        chkCaching.setText(PluginServices.getText(this, "refresh_capabilities"));
745
                        chkCaching.setToolTipText(PluginServices.getText(this, "refresh_capabilities_tooltip"));
746
                        chkCaching.setSelected(refreshing);
747
                        chkCaching.addItemListener(new java.awt.event.ItemListener() {
748
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
749
                                        refreshing = chkCaching.isSelected();
750
                                }
751
                        });
752
                        chkCaching.addActionListener(new java.awt.event.ActionListener() {
753
                                public void actionPerformed(java.awt.event.ActionEvent e) {
754
                                        chkCaching.setEnabled(false); // This avoids multiple contiguous actions
755
                                        fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
756
                                        chkCaching.setEnabled(true); // This avoids multiple contiguous actions
757
                                }
758
                        });
759

    
760
                }
761
                return chkCaching;
762
        }
763

    
764
        /**
765
         * This method makes the 'btnSiguiente' to be clicked
766
         */
767
        public void doClickOnNextButton() {
768
                getBtnSiguiente().doClick();
769
        }
770
}