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 4886 jorpiell
package com.iver.cit.gvsig.gui.wizards;
2
3 8372 jorpiell
import java.awt.FlowLayout;
4 9188 ppiqueras
import java.awt.event.KeyAdapter;
5
import java.awt.event.KeyEvent;
6 4886 jorpiell
import java.awt.geom.Rectangle2D;
7
import java.net.MalformedURLException;
8
import java.net.URL;
9 5830 jorpiell
import java.util.prefs.Preferences;
10 4886 jorpiell
11
import javax.swing.DefaultComboBoxModel;
12 5432 jorpiell
import javax.swing.JCheckBox;
13 5339 jorpiell
import javax.swing.JLabel;
14 18215 ppiqueras
import javax.swing.JOptionPane;
15 8372 jorpiell
import javax.swing.JPanel;
16 17738 ppiqueras
import javax.swing.JTabbedPane;
17
import javax.swing.event.ChangeEvent;
18
import javax.swing.event.ChangeListener;
19 4886 jorpiell
20 17738 ppiqueras
import org.gvsig.exceptions.BaseException;
21 18215 ppiqueras
import org.gvsig.gui.beans.Messages;
22 17738 ppiqueras
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
23
import org.gvsig.gui.beans.swing.JButton;
24
25 4886 jorpiell
import com.iver.andami.PluginServices;
26 17738 ppiqueras
import com.iver.andami.messages.NotificationManager;
27 4886 jorpiell
import com.iver.andami.persistence.serverData.ServerDataPersistence;
28 8445 jorpiell
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver;
29 4886 jorpiell
import com.iver.cit.gvsig.fmap.layers.FLayer;
30 8445 jorpiell
import com.iver.cit.gvsig.fmap.layers.FLyrWFSFactory;
31 4886 jorpiell
import com.iver.cit.gvsig.gui.WizardPanel;
32
import com.iver.cit.gvsig.gui.panels.WFSParamsPanel;
33 17738 ppiqueras
import com.iver.cit.gvsig.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint;
34 4886 jorpiell
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$
82
 * $Log$
83 10248 jorpiell
 * 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 9888 ppiqueras
 * Reencuadrado JScrollPane de descripci?n de conexi?n.
88
 *
89
 * Revision 1.22  2006/12/12 10:24:45  ppiqueras
90 9264 ppiqueras
 * 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 9232 ppiqueras
 * - Quitado el "Enter" asociado a los botones "Siguiente" y "Anterior"
94
 *
95
 * Revision 1.20  2006/12/05 09:22:59  ppiqueras
96 9188 ppiqueras
 * 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 8445 jorpiell
 * 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 8372 jorpiell
 * Se han cambiado algunas etiquetas de texto que sal?an recortadas
103
 *
104
 * Revision 1.17  2006/10/10 12:55:06  jorpiell
105 8018 jorpiell
 * Se ha a?adido el soporte de features complejas
106
 *
107
 * Revision 1.16  2006/10/02 09:09:45  jorpiell
108 7721 jorpiell
 * Cambios del 10 copiados al head
109 7304 caballero
 *
110 7721 jorpiell
 * 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 7304 caballero
 * Revision 1.14  2006/09/03 13:25:04  jorpiell
120 6979 jorpiell
 * Los servidores se guardan ahora en el plugin-persistence como WFS
121
 *
122
 * Revision 1.13  2006/08/30 07:42:29  jorpiell
123 6910 jorpiell
 * 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 6501 jaume
 * improved appearance
127
 *
128
 * Revision 1.11  2006/07/11 11:55:41  jorpiell
129 6289 jorpiell
 * 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 5864 jorpiell
 * 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 5830 jorpiell
 * Se tiene en cuanta la opcion para refrescar las capabilities
136
 *
137
 * Revision 1.8  2006/05/25 16:22:59  jorpiell
138 5463 jorpiell
 * 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 5454 jorpiell
 * 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 5432 jorpiell
 * 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 5403 jorpiell
 * Cambiado el nombre de la pesta?a a WFS
148
 *
149
 * Revision 1.4  2006/05/23 13:21:59  jorpiell
150 5367 jorpiell
 * 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 5339 jorpiell
 * 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 5300 jorpiell
 * Modificados algunos paneles
157
 *
158
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
159 4886 jorpiell
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
160
 *
161
 *
162
 */
163 17738 ppiqueras
164 4886 jorpiell
/**
165 17738 ppiqueras
 * <p>Wizard that allows add a new WFS layer.</p>
166
 *
167 4886 jorpiell
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
168 17738 ppiqueras
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
169 4886 jorpiell
 */
170
public class WFSWizard extends WizardPanel {
171 17738 ppiqueras
        private int page;
172 4886 jorpiell
        private boolean connected = false;
173
        private JComboServer cmbHost = null;
174 6501 jaume
        private JButton btnConnect = null;
175 4886 jorpiell
        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 8372 jorpiell
        private javax.swing.JPanel pnlName = null;
182 6501 jaume
        private JButton btnSiguiente = null;
183
        private JButton btnAnterior = null;
184 4886 jorpiell
        private javax.swing.JPanel jPanel1 = null;
185
        private WFSParamsPanel wfsParamsPanel = null;
186
        private WFSWizardData dataSource = null;
187 5339 jorpiell
        private JLabel lblServerType = null;
188
        private JLabel lblServerTypeValue = null;
189 5432 jorpiell
        private JCheckBox chkCaching = null;
190 5830 jorpiell
        private static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wfs-wizard" );
191
        private boolean refreshing = fPrefs.getBoolean("refresh_capabilities", false);
192 17738 ppiqueras
        private final String wfs_properties_extensionpoint_name = "WFSPropertiesDialog";
193 6501 jaume
194 4886 jorpiell
        /**
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 17738 ppiqueras
                setTabName(PluginServices.getText(this, "WFS"));
207
208 5339 jorpiell
                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 6501 jaume
                lblServerTypeValue.setText("-");
218 17738 ppiqueras
219 4886 jorpiell
                this.setLayout(null);
220 17738 ppiqueras
//                this.setPreferredSize(new java.awt.Dimension(750, 320));
221
//                this.setPreferredSize(new Dimension(750, 320));
222 4886 jorpiell
                this.setVisible(true);
223 17738 ppiqueras
//                this.setSize(518, 468);
224
225 4886 jorpiell
                this.add(getPanelPage1(), null);
226 17738 ppiqueras
                page = 0;
227 4886 jorpiell
                this.add(getPanelPage2(), null);
228 17738 ppiqueras
229 4886 jorpiell
                this.add(getBtnAnterior(), null);
230
                this.add(getBtnSiguiente(), null);
231 17738 ppiqueras
232 5339 jorpiell
                this.add(lblServerType, null);
233
                this.add(lblServerTypeValue, null);
234 17738 ppiqueras
235
                uptateNavigatingButtons();
236 4886 jorpiell
        }
237
238
        /**
239
         * Adds the host addres to a persistent data storage.
240 6501 jaume
         *
241 17738 ppiqueras
         * @param host the host of the server
242 4886 jorpiell
         */
243
        private void addHost(String host) {
244
                host = host.trim();
245 6979 jorpiell
                ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WFS);
246
                persistence.addServerData(new ServerData(host, ServerData.SERVER_TYPE_WFS));
247 4886 jorpiell
        }
248
249
        /**
250
         * Fills up the initial WCSWizard controls.
251 6501 jaume
         *
252 4886 jorpiell
         * jaume
253
         */
254 24753 jpiera
        private void rellenarControles() throws Exception{
255 4886 jorpiell
                try {
256
                        String host = cmbHost.getModel().getSelectedItem().toString();
257 6501 jaume
258 18215 ppiqueras
                        URL url = new URL(host);
259
260
                        dataSource.setHost(url, refreshing);
261 4886 jorpiell
                        addHost(host);
262
                        getLblTitle().setText(dataSource.getTitle());
263
                        getTxtAbstract().setText(dataSource.getAbstract());
264 5339 jorpiell
                        lblServerTypeValue.setText(dataSource.getServerType());
265 4886 jorpiell
                        wfsParamsPanel.setWizardData(dataSource);
266
                        connected = true;
267 24753 jpiera
                } catch(Exception e) {
268 18215 ppiqueras
                        throw e;
269 4886 jorpiell
                }
270
        }
271
272
        /**
273
         * Enables or disables the Next and Previous buttons according with the current
274
         * page and the enabled pages.
275
         */
276 17738 ppiqueras
        private void uptateNavigatingButtons() {
277 4886 jorpiell
                if (page == 0) {
278
                        getBtnAnterior().setEnabled(false);
279
                        getBtnSiguiente().setVisible(true);
280 17738 ppiqueras
                        getBtnSiguiente().setEnabled(false);
281
                }
282
                else {
283
                        short tabIndex = (short) wfsParamsPanel.getSelectedIndex();
284
285 4886 jorpiell
                        getBtnAnterior().setEnabled(true);
286 17738 ppiqueras
                        if (wfsParamsPanel.nextPageEnabled() == -1) {
287 4886 jorpiell
                            getBtnSiguiente().setEnabled(false);
288 17738 ppiqueras
289
                            if (tabIndex == (wfsParamsPanel.getPanelInGUICount() -1))
290
                                        getBtnSiguiente().setVisible(false);
291 4886 jorpiell
                        }
292 17738 ppiqueras
                        else {
293
                                getBtnSiguiente().setVisible(true);
294
                                getBtnSiguiente().setEnabled(true);
295
                        }
296 4886 jorpiell
                }
297
        }
298
299
        /**
300
         * This method initializes txtHost from the persistent data storage
301 6501 jaume
         *
302 4886 jorpiell
         * @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 6501 jaume
                        cmbHost.setEditable(true);
311 4886 jorpiell
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 10248 jorpiell
                                        servers = new ServerData[2];
329 4886 jorpiell
                                        servers[0] = new ServerData("http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap",ServerData.SERVER_TYPE_WFS);
330 10248 jorpiell
                                        servers[1] = new ServerData("http://www.idee.es/IDEE-WFS/ogcwebservice",ServerData.SERVER_TYPE_WFS);
331 4886 jorpiell
                                }
332
333 17738 ppiqueras
                                for (int i = 0; i < servers.length; i++){
334 6501 jaume
                                        persistence.addServerData(servers[i]);
335 4886 jorpiell
                                }
336 6501 jaume
                                persistence.setPersistent();
337 4886 jorpiell
                        }
338
339
                        cmbHost.setServerList(servers);
340 14476 jmvivo
341 9188 ppiqueras
                        // 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 17738 ppiqueras
                                                getBtnConnect().doClick();
350 9188 ppiqueras
                                        }
351
                                }
352
                        });
353 4886 jorpiell
                }
354
                return cmbHost;
355
        }
356
357
        /**
358
         * This method initializes btnDetalles
359 6501 jaume
         *
360
         * @return JButton
361 4886 jorpiell
         */
362 6501 jaume
        private JButton getBtnConnect() {
363 4886 jorpiell
                if (btnConnect == null) {
364 6501 jaume
                        btnConnect = new JButton();
365 4886 jorpiell
                        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 14476 jmvivo
                                        btnConnect.setEnabled(false); // This avoids multiple contiguous actions
371 17738 ppiqueras
372 18215 ppiqueras
                                        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 24753 jpiera
                                        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 18215 ppiqueras
                                        }
389 4886 jorpiell
                                }
390
                        });
391 14476 jmvivo
392 9188 ppiqueras
                        // 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 14476 jmvivo
                                }
403 9188 ppiqueras
                        });
404 4886 jorpiell
                }
405
406
                return btnConnect;
407
        }
408
409
        /**
410
         * This method initializes jPanel
411 6501 jaume
         *
412 4886 jorpiell
         * @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 8372 jorpiell
                        jPanel.add(getPnlName(), null);
427 4886 jorpiell
                }
428
429
                return jPanel;
430
        }
431 14476 jmvivo
432 8372 jorpiell
        /**
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 4886 jorpiell
447
        /**
448
         * This method initializes jLabel1
449 6501 jaume
         *
450 4886 jorpiell
         * @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 8372 jorpiell
                        jLabel1.setBounds(15, 26, 65, 15);
457 4886 jorpiell
                }
458
459
                return jLabel1;
460
        }
461
462
        /**
463
         * This method initializes lblTitle
464 6501 jaume
         *
465 4886 jorpiell
         * @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 6501 jaume
         *
481 4886 jorpiell
         * @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 9888 ppiqueras
                        jScrollPane.setBounds(10, 47, 457, 267);
489 4886 jorpiell
                }
490
491
                return jScrollPane;
492
        }
493
494
        /**
495
         * This method initializes txtAbstract
496 6501 jaume
         *
497 4886 jorpiell
         * @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 6501 jaume
         *
513 4886 jorpiell
         * @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 6501 jaume
         *
532 4886 jorpiell
         * @return javax.swing.JPanel
533
         */
534
        private javax.swing.JPanel getPanelPage2() {
535
                if (wfsParamsPanel == null) {
536 17738 ppiqueras
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 4886 jorpiell
                }
561
562
                return wfsParamsPanel;
563
        }
564
565
        /**
566
         * This method initializes btnSiguiente
567 6501 jaume
         *
568
         * @return JButton
569 4886 jorpiell
         */
570 6501 jaume
        private JButton getBtnSiguiente() {
571 4886 jorpiell
                if (btnSiguiente == null) {
572 6501 jaume
                        btnSiguiente = new JButton();
573 4886 jorpiell
                        btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30));
574 6501 jaume
                        btnSiguiente.setBounds(395, 444, 100, 20);
575 4886 jorpiell
                        btnSiguiente.setText(PluginServices.getText(this, "siguiente"));
576
                        btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
577
                                public void actionPerformed(java.awt.event.ActionEvent e) {
578 17738 ppiqueras
                                        if (page == 0) {
579
                                                page = 1;
580
                                                getPanelPage1().setVisible(false);
581
                                                getPanelPage2().setVisible(true);
582 4886 jorpiell
                                        }
583 17738 ppiqueras
                                        else {
584
                                                wfsParamsPanel.goToNextTab();
585
                                        }
586 4886 jorpiell
587 17738 ppiqueras
                                        uptateNavigatingButtons();
588 4886 jorpiell
                                }
589 14476 jmvivo
                        });
590 4886 jorpiell
                }
591
                return btnSiguiente;
592
        }
593
594
        /**
595
         * This method initializes btnAnterior
596 6501 jaume
         *
597
         * @return JButton
598 4886 jorpiell
         */
599 6501 jaume
        private JButton getBtnAnterior() {
600 4886 jorpiell
                if (btnAnterior == null) {
601 6501 jaume
                        btnAnterior = new JButton();
602
                        btnAnterior.setBounds(292, 444, 100, 20);
603 4886 jorpiell
                        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 17738 ppiqueras
                                        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 4886 jorpiell
                                        }
626 17738 ppiqueras
                                        else {
627
628
                                        }
629
630
                                        uptateNavigatingButtons();
631 4886 jorpiell
                                }
632
                        });
633
                }
634
                return btnAnterior;
635
        }
636
637
        /**
638
         * This method initializes jPanel1
639 6501 jaume
         *
640 4886 jorpiell
         * @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 14476 jmvivo
                        jPanel1.add(getChkCaching(), null);
654 4886 jorpiell
                }
655
656
                return jPanel1;
657
        }
658
659
        /**
660 17738 ppiqueras
         * Returns the wizard's data source
661 6501 jaume
         *
662 17738 ppiqueras
         * @return the wizard's data source
663 4886 jorpiell
         */
664
        public WFSWizardData getDataSource() {
665
                return dataSource;
666
        }
667
668
        /**
669 17738 ppiqueras
         * Sets the wizard's data source
670 6501 jaume
         *
671 17738 ppiqueras
         * @param source the wizard's data source
672 4886 jorpiell
         */
673
        public void setDataSource(WFSWizardData source) {
674
                dataSource = source;
675
        }
676
677
        /**
678
         * Returns the rectangle that contains all the others
679 6501 jaume
         *
680 17738 ppiqueras
         * @param rects[] rectangles with its positions and dimensions
681 6501 jaume
         *
682 17738 ppiqueras
         * @return Rectangle2D the rectangle that contains all the others
683 4886 jorpiell
         */
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 6501 jaume
         *
698 4886 jorpiell
         * @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 17738 ppiqueras
        /*
709
         * (non-Javadoc)
710
         * @see com.iver.cit.gvsig.gui.WizardPanel#initWizard()
711
         */
712 4886 jorpiell
        public void initWizard() {
713
                setDataSource(new WFSWizardData());
714
        }
715
716 17738 ppiqueras
        /*
717
         * (non-Javadoc)
718
         * @see com.iver.cit.gvsig.gui.WizardPanel#execute()
719
         */
720 4886 jorpiell
        public void execute() {
721
        }
722 6501 jaume
723 17738 ppiqueras
        /*
724
         * (non-Javadoc)
725 4886 jorpiell
         * @see com.iver.cit.gvsig.gui.WizardPanel#getLayer()
726
         */
727
        public FLayer getLayer() {
728 14476 jmvivo
                FLayer layer = wfsParamsPanel.getLayer();
729 8445 jorpiell
                URL host = getHost();
730
                String onlineResource = dataSource.getOnlineResource();
731
                FMapWFSDriver driver = dataSource.getDriver();
732 14476 jmvivo
                return new FLyrWFSFactory().getFLyrWFS(layer,host,onlineResource,driver,true,true);
733 4886 jorpiell
        }
734 6501 jaume
735 5432 jorpiell
        /**
736 6501 jaume
         * This method initializes chkCaching
737
         *
738
         * @return javax.swing.JCheckBox
739
         */
740 5432 jorpiell
        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 5830 jorpiell
                        chkCaching.setSelected(refreshing);
747 6501 jaume
                        chkCaching.addItemListener(new java.awt.event.ItemListener() {
748 5432 jorpiell
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
749 5830 jorpiell
                                        refreshing = chkCaching.isSelected();
750 5432 jorpiell
                                }
751
                        });
752 6501 jaume
                        chkCaching.addActionListener(new java.awt.event.ActionListener() {
753
                                public void actionPerformed(java.awt.event.ActionEvent e) {
754 9188 ppiqueras
                                        chkCaching.setEnabled(false); // This avoids multiple contiguous actions
755 5830 jorpiell
                                        fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
756 9188 ppiqueras
                                        chkCaching.setEnabled(true); // This avoids multiple contiguous actions
757 5432 jorpiell
                                }
758
                        });
759 4886 jorpiell
760 5432 jorpiell
                }
761
                return chkCaching;
762
        }
763 5300 jorpiell
764 9264 ppiqueras
        /**
765
         * This method makes the 'btnSiguiente' to be clicked
766
         */
767
        public void doClickOnNextButton() {
768
                getBtnSiguiente().doClick();
769
        }
770 4886 jorpiell
}