Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / wizards / WFSWizard.java @ 2183

History | View | Annotate | Download (21.1 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
/*
42
 * Created on 23-abr-2004
43
 *
44
 * To change the template for this generated file go to
45
 * Window>Preferences>Java>Code Generation>Code and Comments
46
 */
47
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
48
 *
49
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
50
 *
51
 * This program is free software; you can redistribute it and/or
52
 * modify it under the terms of the GNU General Public License
53
 * as published by the Free Software Foundation; either version 2
54
 * of the License, or (at your option) any later version.
55
 *
56
 * This program is distributed in the hope that it will be useful,
57
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
58
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
59
 * GNU General Public License for more details.
60
 *
61
 * You should have received a copy of the GNU General Public License
62
 * along with this program; if not, write to the Free Software
63
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
64
 *
65
 * For more information, contact:
66
 *
67
 *  Generalitat Valenciana
68
 *   Conselleria d'Infraestructures i Transport
69
 *   Av. Blasco Ib??ez, 50
70
 *   46010 VALENCIA
71
 *   SPAIN
72
 *
73
 *      +34 963862235
74
 *   gvsig@gva.es
75
 *      www.gvsig.gva.es
76
 *
77
 *    or
78
 *
79
 *   IVER T.I. S.A
80
 *   Salamanca 50
81
 *   46005 Valencia
82
 *   Spain
83
 *
84
 *   +34 963163400
85
 *   dac@iver.es
86
 */
87
package com.iver.cit.gvsig.gui.wizards;
88

    
89
import com.iver.andami.PluginServices;
90
import com.iver.andami.Utilities;
91

    
92

    
93
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSDriver;
94
import com.iver.cit.gvsig.fmap.layers.FLayer;
95
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
96
import com.iver.cit.gvsig.gui.WMSDataSourceAdapter;
97
import com.iver.cit.gvsig.gui.WizardPanel;
98
import com.iver.cit.gvsig.gui.wfs.WFSDataSourceAdapter;
99
import com.iver.cit.gvsig.gui.wms.FormatListModel;
100
import com.iver.cit.gvsig.gui.wms.LayerInfo;
101
import com.iver.cit.gvsig.gui.wms.LayerListModel;
102
import com.iver.cit.gvsig.gui.wms.LayerTreeModel;
103
import com.iver.cit.gvsig.gui.wms.SRSListModel;
104
import com.iver.cit.gvsig.gui.wms.WMSWizard;
105
import com.iver.cit.gvsig.gui.wms.WizardData;
106
import com.iver.cit.gvsig.gui.wms.WizardDataSource;
107
import com.iver.cit.gvsig.gui.wms.WizardListener;
108
import com.iver.cit.gvsig.gui.wms.WizardListenerSupport;
109

    
110
import com.iver.utiles.NotExistInXMLEntity;
111
import com.iver.utiles.XMLEntity;
112
import com.iver.utiles.swing.JComboBox;
113

    
114
import org.apache.log4j.Logger;
115
import org.cresques.cts.IProjection;
116
import org.cresques.cts.ProjectionPool;
117

    
118
import java.awt.geom.Rectangle2D;
119

    
120
import java.net.MalformedURLException;
121
import java.net.URL;
122

    
123
import java.util.ArrayList;
124
import java.util.HashSet;
125
import java.util.Iterator;
126
import java.util.TreeSet;
127

    
128
import javax.swing.DefaultComboBoxModel;
129
import javax.swing.DefaultListModel;
130
import javax.swing.JPanel;
131
import javax.swing.JRadioButtonMenuItem;
132
import javax.swing.JTextField;
133
import javax.swing.tree.DefaultTreeModel;
134
import javax.swing.tree.DefaultTreeSelectionModel;
135
import javax.swing.tree.TreePath;
136
import javax.swing.tree.TreeSelectionModel;
137

    
138

    
139
import javax.swing.JLabel;
140
import java.awt.BorderLayout;
141
import java.awt.CardLayout;
142
import java.awt.GridLayout;
143
import javax.swing.JPasswordField;
144
import javax.swing.JCheckBox;
145
import javax.swing.JRadioButton;
146
import javax.swing.JButton;
147
import javax.swing.JList;
148
import javax.swing.JScrollPane;
149
import javax.swing.ListModel;
150
/**
151
 * DOCUMENT ME!
152
 *
153
 * @author Vicente Caballero Navarro
154
 */
155
public class WFSWizard extends WizardPanel {
156
        private static Logger logger = Logger.getLogger(WFSWizard.class.getName());
157
        private int page = 0;
158
        private boolean conectado = false;
159
        private javax.swing.JPanel jContentPane = null;
160
        private JComboBox cmbHost = null;
161
        private javax.swing.JPanel panelPage1 = null;
162
        private LayerListModel selectedLayersModel = new LayerListModel();
163
        private javax.swing.JPanel jPanel1 = null;
164
        private WizardListenerSupport listenerSupport = new WizardListenerSupport();
165
        private WizardDataSource dataSource;
166
        private JPanel jPanel = null;
167
        private JLabel jLabel = null;
168
        private JTextField jTxtUser = null;
169
        private JLabel jLabel1 = null;
170
        private JPasswordField jTxtPassword = null;
171
        private JRadioButton jRadioButton = null;
172
        private JRadioButton jRadioButton1 = null;
173
        private JTextField jTxtnumfeatures = null;
174
        private JLabel jLabel2 = null;
175
        private JLabel jLabel3 = null;
176
        private JTextField jTxttimeout = null;
177
        private JButton jButton = null;
178
        private JButton jButton1 = null;
179
        private JScrollPane jScrollPane = null;
180
        private javax.swing.JTree treeLayers1 = null;
181
        private JPanel panePage2 = null;
182
        private String versionS="version=1.0.0";
183
        private String requestS="request=getcapabilities";
184
        private String serviceS="service=wfs";
185
        private LayerListModel modelo;
186
        /**
187
         * This is the default constructor
188
         */
189
        public WFSWizard() {
190
                super();
191
                initialize();
192
        }
193

    
194
        /**
195
         * This method initializes this
196
         */
197
        private void initialize() {
198
                setTabName("WFS");
199
                this.setSize(510, 311);
200
                this.setLayout(null);
201
                this.setPreferredSize(new java.awt.Dimension(750, 320));
202
                this.setVisible(true);
203
                this.add(getPanePage2(), null);
204
                this.add(getJButton1(), null);
205
                this.add(getJButton(), null);
206
                this.add(getPanelPage1(), null);
207
                //JRadioButtonMenuItem jrmi=new JRadioButtonMenuItem();
208
                //jrmi.add(getJRadioButton());
209
                //jrmi.add(getJRadioButton1());
210
                //this.add(jrmi);
211
                listenerSupport.callStateChanged(true);
212
                // activarVisualizarBotones();
213
        }
214

    
215

    
216

    
217
        /**
218
         * DOCUMENT ME!
219
         *
220
         * @param host DOCUMENT ME!
221
         */
222
        private void addHost(String host) {
223
                host = host.trim();
224

    
225
                DefaultComboBoxModel model = (DefaultComboBoxModel) getTxtHost()
226
                                                                                                                                .getModel();
227

    
228
                if (model.getIndexOf(host) < 0) {
229
                        model.addElement(host);
230

    
231
                        PluginServices ps = PluginServices.getPluginServices(this);
232
                        XMLEntity xml = ps.getPersistentXML();
233

    
234
                        try {
235
                                String[] servers = xml.getStringArrayProperty("wms-servers");
236
                                String[] newServers = new String[servers.length + 1];
237
                                System.arraycopy(servers, 0, newServers, 0, servers.length);
238
                                newServers[servers.length] = host;
239
                                xml.putProperty("wfs-servers", newServers);
240
                        } catch (NotExistInXMLEntity e) {
241
                                xml.putProperty("wfs-servers", new String[] { host });
242
                        }
243

    
244
                        ps.setPersistentXML(xml);
245
                }
246
        }
247

    
248
        
249
        
250
        /**
251
         * This method initializes txtHost
252
         *
253
         * @return javax.swing.JTextField
254
         */
255
        private javax.swing.JComboBox getTxtHost() {
256
                if (cmbHost == null) {
257
                        cmbHost = new JComboBox();
258
                        cmbHost.setModel(new DefaultComboBoxModel());
259
                        cmbHost.setPreferredSize(new java.awt.Dimension(350, 20));
260
                        cmbHost.setEditable(true);
261

    
262
                        XMLEntity xml = PluginServices.getPluginServices(this)
263
                                                                                  .getPersistentXML();
264
                        if (xml == null)
265
                                xml = new XMLEntity();
266
                        String[] servers = null;
267
                        if (!xml.contains("wfs-servers")) {
268
                                servers = new String[1];
269
                                servers[0] = "http://localhost:8080/geoserver/wfs";
270

    
271
                                xml.putProperty("wfs-servers", servers);
272
                        }
273

    
274
                        try {
275
                                servers = xml.getStringArrayProperty("wfs-servers");
276

    
277
                                for (int i = 0; i < servers.length; i++) {
278
                                        ((DefaultComboBoxModel) cmbHost.getModel()).addElement(servers[i]);
279
                                }
280
                        } catch (NotExistInXMLEntity e) {
281
                        }
282
                }
283

    
284
                return cmbHost;
285
        }
286

    
287
        /**
288
         * This method initializes panelPage1
289
         *
290
         * @return javax.swing.JPanel
291
         */
292
        private javax.swing.JPanel getPanelPage1() {
293
                if (panelPage1 == null) {
294
                        panelPage1 = new javax.swing.JPanel();
295
                        panelPage1.setLayout(new BorderLayout());
296
                        panelPage1.setPreferredSize(new java.awt.Dimension(480, 220));
297
                        panelPage1.setVisible(true);
298
                        panelPage1.setBounds(15, 5, 480, 262);
299
                        panelPage1.add(getJPanel1(), java.awt.BorderLayout.NORTH);
300
                        panelPage1.add(getJPanel(), java.awt.BorderLayout.CENTER);
301
                }
302

    
303
                return panelPage1;
304
        }
305

    
306
        /**
307
         * This method initializes jPanel1
308
         *
309
         * @return javax.swing.JPanel
310
         */
311
        private javax.swing.JPanel getJPanel1() {
312
                if (jPanel1 == null) {
313
                        jPanel1 = new javax.swing.JPanel();
314
                        jPanel1.add(getTxtHost(), null);
315
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
316
                                        null, PluginServices.getText(this, "Cadena de conexi?n"),
317
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
318
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
319
                }
320

    
321
                return jPanel1;
322
        }
323

    
324
        /**
325
         * DOCUMENT ME!
326
         *
327
         * @param listener
328
         */
329
        public void addWizardListener(WizardListener listener) {
330
                listenerSupport.addWizardListener(listener);
331
        }
332

    
333
        /**
334
         * DOCUMENT ME!
335
         *
336
         * @param listener
337
         */
338
        public void removeWizardListener(WizardListener listener) {
339
                listenerSupport.removeWizardListener(listener);
340
        }
341

    
342
        /**
343
         * DOCUMENT ME!
344
         *
345
         * @return
346
         */
347
        public WizardDataSource getDataSource() {
348
                return dataSource;
349
        }
350

    
351
        /**
352
         * DOCUMENT ME!
353
         *
354
         * @param source
355
         */
356
        public void setDataSource(WizardDataSource source) {
357
                dataSource = source;
358
        }
359

    
360

    
361

    
362

    
363

    
364
        public String getUrlConnect() {
365
                        return cmbHost.getModel().getSelectedItem().toString();
366
        }
367
        public String getUser() {
368
                return jTxtUser.getText();
369
        }
370
        public String getPassword() {
371
                return jTxtPassword.getText();
372
        }
373
        public String getLayerName(){
374
                return getLayers()[0];//getLstSelectedLayers().getModel().toString();
375
        }
376
        public String[] getLayers(){
377
                ListModel listModel= modelo;
378
                String[] layers=new String[listModel.getSize()];
379
                for (int i=0;i<listModel.getSize();i++){
380
                        layers[i]=listModel.getElementAt(i).toString();
381
                }
382
                return layers;
383
        }
384
        public WFSDriver getWFSDriver(){
385
                return null;// new FMapWFSDriver();
386
        }
387
        public URL getHost(){
388
                 String urlS="http://localhost:8080/geoserver/wfs";
389
                        String versionS="version=1.0.0";
390
                        String requestS="request=getcapabilities";
391
                        String serviceS="service=wfs";
392
                        URL url=null;
393
                        try {
394
                                url = new URL(urlS+"?"+versionS+"&"+requestS+"&"+serviceS);
395
                        } catch (MalformedURLException e) {
396
                                e.printStackTrace();
397
                        }
398
                return url;
399
        }
400
        public IProjection getProjection(){
401
                return ProjectionPool.get("EPSG:23030");
402
        }
403
        /**
404
         * This method initializes jPanel        
405
         *         
406
         * @return javax.swing.JPanel        
407
         */    
408
        private JPanel getJPanel() {
409
                if (jPanel == null) {
410
                        jLabel3 = new JLabel();
411
                        jLabel3.setBounds(241, 157, 121, 18);
412
                        jLabel3.setText("Timeout");
413
                        jLabel2 = new JLabel();
414
                        jLabel2.setBounds(241, 129, 121, 18);
415
                        jLabel2.setText("N. Features buffer");
416
                        jPanel = new JPanel();
417
                        jLabel = new JLabel();
418
                        jLabel1 = new JLabel();
419
                        jPanel.setLayout(null);
420
                        jLabel.setText("Usuario:");
421
                        jLabel.setName("jLabel");
422
                        jLabel.setSize(80, 19);
423
                        jLabel.setLocation(151, 12);
424
                        jLabel1.setBounds(149, 41, 82, 19);
425
                        jLabel1.setText("Contrase?a:");
426
                        jPanel.add(getJTxttimeout(), null);
427
                        jPanel.add(jLabel3, null);
428
                        jPanel.add(jLabel2, null);
429
                        jPanel.add(getJTxtnumfeatures(), null);
430
                        jPanel.add(getJRadioButton1(), null);
431
                        jPanel.add(getJRadioButton(), null);
432
                        jPanel.add(jLabel, null);
433
                        jPanel.add(getJTxtUser(), null);
434
                        jPanel.add(jLabel1, null);
435
                        jPanel.add(getJTxtPassword(), null);
436
                }
437
                return jPanel;
438
        }
439
        /**
440
         * This method initializes jTextField        
441
         *         
442
         * @return javax.swing.JTextField        
443
         */    
444
        private JTextField getJTxtUser() {
445
                if (jTxtUser == null) {
446
                        jTxtUser = new JTextField();
447
                        jTxtUser.setName("jTextField");
448
                        jTxtUser.setColumns(0);
449
                        jTxtUser.setBounds(241, 12, 169, 19);
450
                        jTxtUser.addFocusListener(new java.awt.event.FocusListener() { 
451
                                public void focusLost(java.awt.event.FocusEvent e) {
452
                                    listenerSupport.callStateChanged(true);
453
                                        System.out.println("focusLost()"); // TODO Auto-generated Event stub focusLost()
454
                                }
455
                                public void focusGained(java.awt.event.FocusEvent e) {} 
456
                        });
457
                }
458
                return jTxtUser;
459
        }
460
        /**
461
         * This method initializes jPasswordField        
462
         *         
463
         * @return javax.swing.JPasswordField        
464
         */    
465
        private JPasswordField getJTxtPassword() {
466
                if (jTxtPassword == null) {
467
                        jTxtPassword = new JPasswordField();
468
                        jTxtPassword.setBounds(241, 39, 169, 20);
469
                }
470
                return jTxtPassword;
471
        }
472

    
473
        /**
474
         * This method initializes jRadioButton        
475
         *         
476
         * @return javax.swing.JRadioButton        
477
         */    
478
        private JRadioButton getJRadioButton() {
479
                if (jRadioButton == null) {
480
                        jRadioButton = new JRadioButton();
481
                        jRadioButton.setBounds(241, 73, 121, 18);
482
                        jRadioButton.setText("GET");
483
                        jRadioButton.setSelected(true);
484
                }
485
                return jRadioButton;
486
        }
487

    
488
        /**
489
         * This method initializes jRadioButton1        
490
         *         
491
         * @return javax.swing.JRadioButton        
492
         */    
493
        private JRadioButton getJRadioButton1() {
494
                if (jRadioButton1 == null) {
495
                        jRadioButton1 = new JRadioButton();
496
                        jRadioButton1.setBounds(241, 101, 121, 18);
497
                        jRadioButton1.setText("POST");
498
                }
499
                return jRadioButton1;
500
        }
501

    
502
        /**
503
         * This method initializes jTextField        
504
         *         
505
         * @return javax.swing.JTextField        
506
         */    
507
        private JTextField getJTxtnumfeatures() {
508
                if (jTxtnumfeatures == null) {
509
                        jTxtnumfeatures = new JTextField();
510
                        jTxtnumfeatures.setBounds(372, 129, 38, 18);
511
                        jTxtnumfeatures.setText("100");
512
                }
513
                return jTxtnumfeatures;
514
        }
515

    
516
        /**
517
         * This method initializes jTextField1        
518
         *         
519
         * @return javax.swing.JTextField        
520
         */    
521
        private JTextField getJTxttimeout() {
522
                if (jTxttimeout == null) {
523
                        jTxttimeout = new JTextField();
524
                        jTxttimeout.setBounds(371, 157, 39, 18);
525
                        jTxttimeout.setText("10000");
526
                }
527
                return jTxttimeout;
528
        }
529

    
530
        /**
531
         * This method initializes jButton        
532
         *         
533
         * @return javax.swing.JButton        
534
         */    
535
        private JButton getJButton() {
536
                if (jButton == null) {
537
                        jButton = new JButton();
538
                        jButton.setBounds(108, 275, 94, 22);
539
                        jButton.setText(PluginServices.getText(this, "anterior"));
540
                        jButton.setEnabled(false);
541
                        jButton.addActionListener(new java.awt.event.ActionListener() {
542
                                public void actionPerformed(java.awt.event.ActionEvent e) {
543
                                        page--;
544
                                        //getPanelPage1().setVisible(true);
545
                                        //getPanePage2().setVisible(false);
546
                                        activarVisualizarBotones();
547
                                }
548
                        });
549
                }
550
                return jButton;
551
        }
552

    
553
        /**
554
         * This method initializes jButton1        
555
         *         
556
         * @return javax.swing.JButton        
557
         */    
558
        private JButton getJButton1() {
559
                if (jButton1 == null) {
560
                        jButton1 = new JButton();
561
                        jButton1.setBounds(306, 275, 94, 22);
562
                        jButton1.setText(PluginServices.getText(this, "siguiente"));
563
                        jButton1.addActionListener(new java.awt.event.ActionListener() {
564
                                public void actionPerformed(java.awt.event.ActionEvent e) {
565
                                        page++;
566
                                        rellenarControles();
567
                                        //getPanelPage1().setVisible(false);
568
                                        //getPanePage2().setVisible(true);
569
                                        activarVisualizarBotones();
570
                                }
571
                        });
572
                }
573
                return jButton1;
574
        }
575
        /**
576
         * DOCUMENT ME!
577
         */
578
        private void activarVisualizarBotones() {
579
                if (page == 0) {
580
                        getPanePage2().setVisible(false);
581
                        getPanelPage1().setVisible(true);
582
                        
583
                        getJButton().setEnabled(false);
584
                        getJButton1().setVisible(true);
585

    
586
                        if (conectado) {
587
                                getJButton1().setEnabled(true);
588
                        } else {
589
                                getJButton1().setEnabled(false);
590
                        }
591
                } else if (page == 1) {
592
                        //rellenarControles();
593
                        
594
                        getPanelPage1().setVisible(false);
595
                        getPanePage2().setVisible(true);
596
                        getJButton1().setVisible(false);
597
                        getJButton().setEnabled(true);
598
                        
599
                        listenerSupport.callStateChanged(true);
600

    
601
                        /*if ((getLstSRSs().getSelectedIndex() != -1) &&
602
                                        (getLstFormats1().getSelectedIndex() != -1) &&
603
                                        (getLstSelectedLayers().getModel().getSize() > 0)) {
604
                                listenerSupport.callStateChanged(true);
605
                        } else {
606
                                listenerSupport.callStateChanged(false);
607
                        }
608
*/
609
                        if (getTreeLayers1().getSelectionCount() > 0) {
610
                                LayerInfo nodo = (LayerInfo) getTreeLayers1().getSelectionPath()
611
                                                                                                 .getLastPathComponent();
612
                                String name = nodo.name;
613

    
614
                                if (name != null) {
615
                                        //getBtnAdd().setEnabled(true);
616
                                } else {
617
                                        //getBtnAdd().setEnabled(false);
618
                                }
619
                        } else {
620
                                //getBtnAdd().setEnabled(false);
621
                        }
622

    
623
                        //if (getLstSelectedLayers().getSelectedIndex() != -1) {
624
                        //        getBtnDel().setEnabled(true);
625
                        //} else {
626
                        //        getBtnDel().setEnabled(false);
627
                        //}
628
                }
629
        }
630

    
631
        /**
632
         * This method initializes jScrollPane        
633
         *         
634
         * @return javax.swing.JScrollPane        
635
         */    
636
        private JScrollPane getJScrollPane() {
637
                if (jScrollPane == null) {
638
                        jScrollPane = new JScrollPane();
639
                        jScrollPane.setViewportView(getTreeLayers1());
640
                        jScrollPane.setPreferredSize(new java.awt.Dimension(150,200));
641
                }
642
                return jScrollPane;
643
        }
644
        private javax.swing.JTree getTreeLayers1() {
645
                if (treeLayers1 == null) {
646
                        treeLayers1 = new javax.swing.JTree();
647
                        treeLayers1.setRootVisible(false);
648
                        TreeSelectionModel tsm=new DefaultTreeSelectionModel();
649
                        tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
650
                        treeLayers1.setSelectionModel(tsm);
651
                        treeLayers1.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
652
                                        public void valueChanged(
653
                                                javax.swing.event.TreeSelectionEvent e) {
654
                                                addLayer();
655
                                                ///activarVisualizarBotones();
656
                                        }
657
                                });
658
                }
659

    
660
                return treeLayers1;
661
        }
662
        /**
663
                 * DOCUMENT ME!
664
                 */
665
                private void addLayer() {
666
                        boolean alguno = false;
667

    
668
                        TreePath[] selecciones = getTreeLayers1().getSelectionPaths();
669

    
670
                        for (int i = 0; i < selecciones.length; i++) {
671
                                LayerInfo nodo = (LayerInfo) selecciones[i].getLastPathComponent();
672

    
673
                                String name = nodo.name;
674
                                String text = nodo.text;
675
                                
676
                                //Se a?ade a la lista de layers seleccionados
677
                                modelo = new LayerListModel();//(LayerListModel) lstSelectedLayers.getModel();
678

    
679
                                if (modelo.addElement(nodo)) {
680
                                        alguno = true;
681
                                }
682
                        }
683

    
684
                        if (alguno) {
685
                                activarVisualizarBotones();
686
                                //actualizarSRS();
687
                        }
688
                }
689

    
690
                /**
691
                 * DOCUMENT ME!
692
                 */
693
                private void delLayer() {
694
                        //int[] index = lstSelectedLayers.getSelectedIndices();
695

    
696
                        ArrayList removeList = new ArrayList();
697
                        //LayerListModel modelo = (LayerListModel) lstSelectedLayers.getModel();
698
                        LayerInfo[] infos = modelo.getElements();
699

    
700
                        //for (int i = 0; i < index.length; i++) {
701
                        //        removeList.add(infos[index[i]]);
702
                        //}
703

    
704
                        modelo.delElements(removeList);
705
                        //lstSelectedLayers.clearSelection();
706

    
707
                        activarVisualizarBotones();
708

    
709
                        //actualizarSRS();
710
                }
711
                /**
712
                 * DOCUMENT ME!
713
                 */
714
                private void rellenarControles() {
715
                        try {
716
                                String host = cmbHost.getModel().getSelectedItem().toString();
717
                                ((WFSDataSourceAdapter)dataSource).setData(getUser(),getPassword(),getProtocol(),getNumFeatures(),getTimeout());
718
                                WizardData data = dataSource.detalles(new URL(host+"?"+versionS+"&"+requestS+"&"+serviceS));
719

    
720
                                addHost(host);
721
                                //modelo.clear();
722
                                //getTreeLayers1().repaint();
723
                                //((LayerListModel) lstSelectedLayers.getModel()).clear();
724
                                //lstSelectedLayers.repaint();
725
                                //lblTitle.setText(data.getTitle());
726
                                //txtAbstract.setText(data.getAbstract());
727
                                //lstFormats1.setModel(new FormatListModel(data.getFormats()));
728
                                treeLayers1.setModel(new LayerTreeModel(data.getLayer()));
729
                                conectado = true;
730
                                //activarVisualizarBotones();
731
                        } catch (Exception e) {
732
                                listenerSupport.callError(e);
733
                        }
734
                }
735

    
736
                /**
737
                 * This method initializes jPanel3        
738
                 *         
739
                 * @return javax.swing.JPanel        
740
                 */    
741
                private JPanel getPanePage2() {
742
                        if (panePage2 == null) {
743
                                panePage2 = new JPanel();
744
                                panePage2.setBounds(0, 2, 495, 266);
745
                                panePage2.setVisible(false);
746
                                panePage2.add(getJScrollPane(), null);
747
                        }
748
                        return panePage2;
749
                }
750

    
751
                public boolean getProtocol(){
752
                        if (getJRadioButton().isSelected()){
753
                                return true;
754
                        }
755
                        return false;
756
                }
757
                public int getNumFeatures(){
758
                        return Integer.parseInt(getJTxtnumfeatures().getText());
759
                }
760
                public int getTimeout(){
761
                        return Integer.parseInt(getJTxttimeout().getText());
762
                }
763
                public void initWizard() {
764
                        setDataSource(new WFSDataSourceAdapter());
765
                }
766

    
767
                /* (non-Javadoc)
768
                 * @see com.iver.cit.gvsig.gui.WizardPanel#execute()
769
                 */
770
                public void execute() {
771
                }
772

    
773
                /* (non-Javadoc)
774
                 * @see com.iver.cit.gvsig.gui.WizardPanel#getLayer()
775
                 */
776
                public FLayer getLayer() {
777
                        WFSWizard wfs = this;
778
                        String[] layers=wfs.getLayers();
779
                        if (layers.length>0) {
780
                                String layerName = wfs.getLayerName();
781
                                String user = wfs.getUser();
782
                                String pwd = wfs.getPassword();
783
                                String url = wfs.getUrlConnect();
784
                                
785
                                boolean protocol=wfs.getProtocol();
786
                                int numfeatures=wfs.getNumFeatures();
787
                                int timeout=wfs.getTimeout();
788
                                //String fields = wfs.getSqlFields();
789
                                //String whereClause = dbWiz.getSqlWhere();
790
                                WFSDriver driver = new WFSDriver();
791
                                driver.setData(url,user,pwd,layers,protocol,numfeatures,timeout,2);
792
                                return LayerFactory.createWFSLayer(layerName,driver,wfs.getHost(),
793
                                                wfs.getProjection());
794
                        }
795
                        return null;
796
                }
797
}