Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_1_RELEASE / extensions / extWMS / src / com / iver / cit / gvsig / gui / wizards / WMSWizard.java @ 9531

History | View | Annotate | Download (27.9 KB)

1 3746 jaume
/* 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
package com.iver.cit.gvsig.gui.wizards;
42
43 6844 ldiaz
import java.awt.Color;
44 4222 jaume
import java.awt.Component;
45
import java.awt.Dimension;
46 6122 jaume
import java.awt.FlowLayout;
47 3746 jaume
import java.awt.geom.Rectangle2D;
48
import java.net.MalformedURLException;
49
import java.net.URL;
50 4222 jaume
import java.util.Hashtable;
51 3746 jaume
import java.util.Vector;
52 4501 jaume
import java.util.prefs.Preferences;
53 3746 jaume
54 6844 ldiaz
import javax.swing.BorderFactory;
55 4501 jaume
import javax.swing.DefaultComboBoxModel;
56
import javax.swing.JCheckBox;
57 3746 jaume
import javax.swing.JLabel;
58 4222 jaume
import javax.swing.JOptionPane;
59 3746 jaume
import javax.swing.JPanel;
60
import javax.swing.tree.TreePath;
61
62
import org.apache.log4j.Logger;
63
64
import com.iver.andami.PluginServices;
65 4507 jorpiell
import com.iver.andami.persistence.serverData.ServerDataPersistence;
66 3746 jaume
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver;
67 4222 jaume
import com.iver.cit.gvsig.fmap.exceptions.CannotReprojectException;
68 3746 jaume
import com.iver.cit.gvsig.fmap.layers.FLayer;
69 4511 ldiaz
import com.iver.cit.gvsig.fmap.layers.FLayers;
70 3746 jaume
import com.iver.cit.gvsig.fmap.layers.FLyrWMS;
71 4511 ldiaz
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode;
72 3746 jaume
import com.iver.cit.gvsig.gui.WizardPanel;
73 4511 ldiaz
import com.iver.cit.gvsig.gui.panels.LayerTree;
74 3746 jaume
import com.iver.cit.gvsig.gui.panels.WMSParamsPanel;
75 4501 jaume
import com.iver.utiles.NotExistInXMLEntity;
76
import com.iver.utiles.XMLEntity;
77 4507 jorpiell
import com.iver.utiles.swing.jcomboServer.JComboServer;
78
import com.iver.utiles.swing.jcomboServer.ServerData;
79 3746 jaume
80
81
/**
82 3850 jaume
 * The WMS properties container panel.
83 3746 jaume
 *
84 3850 jaume
 * @author Jaume Dominguez Faus
85 3746 jaume
 */
86
public class WMSWizard extends WizardPanel {
87
        private static Logger logger = Logger.getLogger(WMSWizard.class.getName());
88 4624 ldiaz
        protected int page;
89
        protected boolean connected = false;
90 4507 jorpiell
        private JComboServer cmbHost = null;
91 6115 jaume
        private org.gvsig.gui.beans.swing.JButton btnConnect = null;
92 3746 jaume
        private javax.swing.JPanel jPanel = null;
93
        private javax.swing.JLabel jLabel1 = null;
94
        private javax.swing.JLabel lblTitle = null;
95
        private javax.swing.JScrollPane jScrollPane = null;
96
        private javax.swing.JTextArea txtAbstract = null;
97
        private javax.swing.JPanel panelPage1 = null;
98 6115 jaume
        private org.gvsig.gui.beans.swing.JButton btnSiguiente = null;
99
        private org.gvsig.gui.beans.swing.JButton btnAnterior = null;
100 3746 jaume
        private javax.swing.JPanel jPanel1 = null;
101 4624 ldiaz
        protected WizardListenerSupport listenerSupport = new WizardListenerSupport();
102
        protected WMSWizardData dataSource;
103
        protected WMSParamsPanel wmsParamsPanel = null;
104
        protected JLabel lblServerType = null;
105
        protected JLabel lblServerTypeValue = null;
106 4501 jaume
        private JCheckBox chkCaching = null;
107
        private static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wms-wizard" );
108
        private boolean refreshing = fPrefs.getBoolean("refresh_capabilities", false);
109 4624 ldiaz
        protected int firstPage;
110 6122 jaume
        private JPanel pnlName = null;
111 4507 jorpiell
112
        public WMSWizard (WMSParamsPanel params){
113 6115 jaume
114 4507 jorpiell
                super();
115
                firstPage = 1;
116
                page = firstPage;
117 6115 jaume
                this.wmsParamsPanel = params;
118 4507 jorpiell
                this.dataSource = wmsParamsPanel.dataSource;
119
120 6115 jaume
                setTabName("WMS");
121 4383 ldiaz
                lblServerType = new JLabel();
122
                lblServerType.setBounds(20, 444, 100, 20);
123
                lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
124
                lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
125
                lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11));
126
                lblServerType.setText(PluginServices.getText(this, "server_type")+":");
127
                lblServerTypeValue = new JLabel();
128
                lblServerTypeValue.setBounds(128, 444, 148, 20);
129
                lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11));
130
                lblServerTypeValue.setText("-");
131
                this.setSize(510, 468);
132
                this.setLayout(null);
133
                this.setPreferredSize(new java.awt.Dimension(750, 420));
134
                this.setVisible(true);
135 4507 jorpiell
136 4383 ldiaz
                wmsParamsPanel.setListenerSupport(this.listenerSupport);
137 6844 ldiaz
                wmsParamsPanel.setBounds(0, 5, 510, 428);
138 4383 ldiaz
                wmsParamsPanel.getJTabbedPane().addMouseListener(
139 4507 jorpiell
                                new java.awt.event.MouseAdapter() {
140
                                        public void mouseClicked(java.awt.event.MouseEvent e) {
141
                                                page = wmsParamsPanel.currentPage() + 1;
142
                                                activarVisualizarBotones();
143
                                        }
144
                                });
145 4383 ldiaz
                this.add(wmsParamsPanel, null);
146
                this.add(lblServerType, null);
147
                this.add(lblServerTypeValue, null);
148 4360 ldiaz
                getPanelPage2().setVisible(true);
149 6844 ldiaz
150 6115 jaume
                connected = true;
151 4507 jorpiell
        }
152 6115 jaume
153 3746 jaume
        /**
154 4513 ldiaz
         * This is the default constructor
155
         */
156
        public WMSWizard() {
157
                super();
158
                firstPage = 0;
159
                page = firstPage;
160
                initialize();
161 6115 jaume
        }
162 4513 ldiaz
        /**
163 3746 jaume
         * This method initializes this
164
         */
165 4501 jaume
        private void initialize() {
166
                setTabName("WMS");
167 4507 jorpiell
168 3746 jaume
                lblServerType = new JLabel();
169 3796 jaume
                lblServerType.setBounds(20, 444, 100, 20);
170 3746 jaume
                lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
171
                lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
172
                lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11));
173 3796 jaume
                lblServerType.setText(PluginServices.getText(this, "server_type")+":");
174 3746 jaume
                lblServerTypeValue = new JLabel();
175
                lblServerTypeValue.setBounds(128, 444, 148, 20);
176
                lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11));
177
                lblServerTypeValue.setText("-");
178
                this.setSize(510, 468);
179
                this.setLayout(null);
180
                this.setPreferredSize(new java.awt.Dimension(750, 420));
181
                this.setVisible(true);
182
                this.add(getPanelPage1(), null);
183
                this.add(getPanelPage2(), null);
184
                this.add(getBtnAnterior(), null);
185
                this.add(getBtnSiguiente(), null);
186
                this.add(lblServerType, null);
187
                this.add(lblServerTypeValue, null);
188
                activarVisualizarBotones();
189
        }
190
191
192 4624 ldiaz
        protected JPanel getPanelPage2(){
193 3746 jaume
                if (wmsParamsPanel == null){
194
                        wmsParamsPanel = new WMSParamsPanel();
195
                        wmsParamsPanel.setListenerSupport(this.listenerSupport);
196 6500 jaume
                        wmsParamsPanel.setBounds(0, 5, 510, 428);
197 3746 jaume
                        wmsParamsPanel.getJTabbedPane().addMouseListener(
198 4507 jorpiell
                                        new java.awt.event.MouseAdapter() {
199
                                                public void mouseClicked(java.awt.event.MouseEvent e) {
200
                                                        page = wmsParamsPanel.currentPage() + 1;
201
                                                        activarVisualizarBotones();
202
                                                }
203
                                        });
204 3746 jaume
                }
205
                return wmsParamsPanel;
206
        }
207
        /**
208
         * DOCUMENT ME!
209
         *
210
         * @param host DOCUMENT ME!
211
         */
212
        private void addHost(String host) {
213 4501 jaume
                host = host.trim();
214
215 4507 jorpiell
                ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WMS);
216
                persistence.addServerData(new ServerData(host, ServerData.SERVER_TYPE_WMS));
217 3746 jaume
        }
218
219
        /**
220
         * DOCUMENT ME!
221
         */
222
        private void rellenarControles() {
223
                try {
224
                        String host = cmbHost.getModel().getSelectedItem().toString();
225 4507 jorpiell
226
                        dataSource.setHost(new URL(host), refreshing);
227
                        lblTitle.setText(dataSource.getTitle());
228 3746 jaume
                        lblServerTypeValue.setText(dataSource.getServerType());
229 4507 jorpiell
                        txtAbstract.setText(dataSource.getAbstract());
230
231 3746 jaume
                        addHost(host);
232
                        wmsParamsPanel.setWizardData(dataSource);
233 4501 jaume
                        connected = true;
234 3746 jaume
                        activarVisualizarBotones();
235
                } catch (Exception e) {
236
                        listenerSupport.callError(e);
237
                        e.printStackTrace();
238
                }
239
        }
240
241
        /**
242
         * DOCUMENT ME!
243
         */
244 4624 ldiaz
        protected void activarVisualizarBotones() {
245 4511 ldiaz
                if (page == firstPage) {
246 3746 jaume
                        getBtnAnterior().setEnabled(false);
247
                        getBtnSiguiente().setVisible(true);
248
249 4501 jaume
                        if (connected) {
250 3746 jaume
                                getBtnSiguiente().setEnabled(true);
251
                        } else {
252
                                getBtnSiguiente().setEnabled(false);
253
                        }
254
                } else if (page < wmsParamsPanel.getNumTabs()) {
255
                        getBtnSiguiente().setEnabled(true);
256
                        getBtnSiguiente().setVisible(true);
257
                        getBtnAnterior().setEnabled(true);
258
                        getBtnAnterior().setVisible(true);
259
                        if (wmsParamsPanel.nextEnabledPage()==-1){
260 4507 jorpiell
                                getBtnSiguiente().setEnabled(false);
261 3746 jaume
                        }
262
                        listenerSupport.callStateChanged(wmsParamsPanel.isCorrectlyConfigured());
263
                } else if (page == wmsParamsPanel.getNumTabs()) {
264
                        getBtnSiguiente().setVisible(false);
265
                        getBtnSiguiente().setEnabled(false);
266 6115 jaume
                        listenerSupport.callStateChanged(wmsParamsPanel
267 3746 jaume
                                        .isCorrectlyConfigured());
268
                }
269
        }
270
271
        /**
272
         * This method initializes txtHost
273
         *
274
         * @return javax.swing.JTextField
275
         */
276 4501 jaume
        private javax.swing.JComboBox getTxtHost() {
277 3746 jaume
                if (cmbHost == null) {
278 4507 jorpiell
                        cmbHost = new JComboServer();
279 4501 jaume
                        cmbHost.setModel(new DefaultComboBoxModel());
280 3746 jaume
                        cmbHost.setPreferredSize(new java.awt.Dimension(350, 20));
281
                        cmbHost.setBounds(11, 26, 454, 20);
282 6115 jaume
                        cmbHost.setEditable(true);
283 3746 jaume
284 4507 jorpiell
                        ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WMS);
285
                        ServerData[] servers = persistence.getArrayOfServerData();
286 4501 jaume
287 4507 jorpiell
                        if (servers.length == 0){
288 4509 jorpiell
                                PluginServices ps = PluginServices.getPluginServices(this);
289
                                XMLEntity xml = ps.getPersistentXML();
290 4507 jorpiell
                                try {
291
                                        String[] oldServers = xml.getStringArrayProperty("wms-servers");
292
                                        servers = new ServerData[oldServers.length];
293
                                        for (int i=0; i<oldServers.length; i++) {
294
                                                servers[i] = new ServerData(oldServers[i],ServerData.SERVER_TYPE_WMS);
295
                                        }
296
                                        xml.remove("wms-servers");
297 4509 jorpiell
                                        ps.setPersistentXML(xml);
298 4507 jorpiell
                                } catch (NotExistInXMLEntity e) {
299 4601 jaume
                                        // Old servers doesn't exist
300
                                        servers = new ServerData[12];
301 4507 jorpiell
                                        servers[0] = new ServerData("http://www.idee.es/wms/IDEE-Base/IDEE-Base",ServerData.SERVER_TYPE_WMS);
302
                                        servers[1] = new ServerData("http://wms.jpl.nasa.gov/wms.cgi",ServerData.SERVER_TYPE_WMS);
303
                                        servers[2] = new ServerData("http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?",ServerData.SERVER_TYPE_WMS);
304
                                        servers[3] = new ServerData("http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_patricova",ServerData.SERVER_TYPE_WMS);
305
                                        servers[4] = new ServerData("http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_parque_fondo_prug",ServerData.SERVER_TYPE_WMS);
306
                                        servers[5] = new ServerData("http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_pgof",ServerData.SERVER_TYPE_WMS);
307
                                        servers[6] = new ServerData("http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_urbanismo_tematicos",ServerData.SERVER_TYPE_WMS);
308
                                        servers[7] = new ServerData("http://onearth.jpl.nasa.gov/wms.cgi",ServerData.SERVER_TYPE_WMS);
309
                                        servers[8] = new ServerData("http://www.demis.nl/wms/wms.asp?WMS=WorldMap",ServerData.SERVER_TYPE_WMS);
310
                                        servers[9] = new ServerData("http://aes.gsfc.nasa.gov/cgi-bin/wms",ServerData.SERVER_TYPE_WMS);
311
                                        servers[10] = new ServerData("http://mapas.euitto.upm.es/cgi-bin/cnauticas",ServerData.SERVER_TYPE_WMS);
312 4601 jaume
                                        servers[11] = new ServerData("http://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx", ServerData.SERVER_TYPE_WMS);
313 4507 jorpiell
                                }
314 4501 jaume
315 4507 jorpiell
                                for (int i=0 ; i<servers.length ; i++){
316 6115 jaume
                                        persistence.addServerData(servers[i]);
317 4501 jaume
                                }
318 6115 jaume
                                persistence.setPersistent();
319 4501 jaume
                        }
320 4507 jorpiell
321
                        cmbHost.setServerList(servers);
322
323
324
//                        XMLEntity xml = PluginServices.getPluginServices(this)
325
//                        .getPersistentXML();
326
//                        if (xml == null)
327
//                        xml = new XMLEntity();
328
329
//                        if (!xml.contains("wms-servers")) {
330
//                        String[] servers = new String[11];
331
//                        // Begining of rubbish code
332
//                        //
333
//                        // The following block should not exist and it only will live in the
334
//                        // 0.6 version. It fixes an error that has been happening since the 0.4 version
335
//                        // and recovers the user's server data from the wrong location that has been used to use.
336
//                        // This code will be removed from the 0.7 version
337
//                        boolean bool = false;
338
//                        {
339
//                        Class gvSIGClass = AddLayer.class; // for example... (we only need to use a class that has been loaded by gvSIG's class loader
340
//                        XMLEntity xml2 = PluginServices.getPluginServices(PluginServices.getExtension(gvSIGClass)).getPersistentXML();
341
//                        if (xml2.contains("wms-servers")) {
342
//                        String oldServers[] = xml2.getStringArrayProperty("wms-servers");
343
//                        servers = new String[servers.length+oldServers.length];
344
//                        for (int i = 0; i < oldServers.length; i++) {
345
//                        servers[oldServers.length+i] = oldServers[i];
346
//                        }
347
//                        xml2.remove("wms-servers");
348
//                        bool = true;
349
//                        }
350
//                        }
351
//                        if (!bool) {
352
//                        // end of the rubbish code (don't forget to remove the closing bracket)
353
354
//                        servers[0] = "http://www.idee.es/wms/IDEE-Base/IDEE-Base";
355
//                        servers[1] = "http://wms.jpl.nasa.gov/wms.cgi";
356
//                        servers[2] = "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?";
357
//                        servers[3] = "http://demo.deegree.org:8080/deegree/wms";
358
//                        servers[4] = "http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_patricova";
359
//                        servers[5] = "http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_parque_fondo_prug";
360
//                        servers[6] = "http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_pgof";
361
//                        servers[7] = "http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_urbanismo_tematicos";
362
//                        servers[8] = "http://onearth.jpl.nasa.gov/wms.cgi";
363
//                        servers[9] = "http://www.demis.nl/wms/wms.asp?WMS=WorldMap";
364
//                        servers[9] = "http://aes.gsfc.nasa.gov/cgi-bin/wms";
365
//                        servers[10]= "http://mapas.euitto.upm.es/cgi-bin/cnauticas";
366
367
//                        } // this bracket will be removed too in version <= 0.7
368
//                        xml.putProperty("wms-servers", servers);
369 6115 jaume
//                        }
370 4507 jorpiell
//                        try {
371
//                        String[] servers = xml.getStringArrayProperty("wms-servers");
372
//                        for (int i = 0; i < servers.length; i++) {
373
//                        ((DefaultComboBoxModel) cmbHost.getModel()).addElement(servers[i]);
374
//                        }
375
//                        } catch (NotExistInXMLEntity e) {
376
//                        }
377 3746 jaume
                }
378
379
                return cmbHost;
380 6115 jaume
        }
381 3746 jaume
382 4507 jorpiell
383 3746 jaume
        /**
384
         * This method initializes btnDetalles
385
         *
386
         * @return javax.swing.JButton
387
         */
388
        private javax.swing.JButton getBtnConnect() {
389
                if (btnConnect == null) {
390 6115 jaume
                        btnConnect = new org.gvsig.gui.beans.swing.JButton();
391 3746 jaume
                        btnConnect.setPreferredSize(new java.awt.Dimension(100, 20));
392
                        btnConnect.setBounds(366, 50, 100, 20);
393
                        btnConnect.setText(PluginServices.getText(this, "conectar"));
394
                        btnConnect.addActionListener(new java.awt.event.ActionListener() {
395 4507 jorpiell
                                public void actionPerformed(java.awt.event.ActionEvent e) {
396
                                        rellenarControles();
397
                                }
398
                        });
399 3746 jaume
                }
400
401
                return btnConnect;
402
        }
403
404
        /**
405
         * This method initializes jPanel
406
         *
407
         * @return javax.swing.JPanel
408
         */
409
        private javax.swing.JPanel getJPanel() {
410
                if (jPanel == null) {
411
                        jPanel = new javax.swing.JPanel();
412
                        jPanel.setLayout(null);
413
                        jPanel.setPreferredSize(new java.awt.Dimension(470, 130));
414
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
415 3774 jaume
                                        null, PluginServices.getText(this, "description"),
416 3746 jaume
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
417
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
418
                        jPanel.setBounds(2, 96, 477, 324);
419 6122 jaume
420 3746 jaume
                        jPanel.add(getJScrollPane(), null);
421 6122 jaume
                        jPanel.add(getPnlName(), null);
422 3746 jaume
                }
423
424
                return jPanel;
425
        }
426
427
        /**
428
         * This method initializes jLabel1
429
         *
430
         * @return javax.swing.JLabel
431
         */
432
        private javax.swing.JLabel getJLabel1() {
433
                if (jLabel1 == null) {
434
                        jLabel1 = new javax.swing.JLabel();
435 3796 jaume
                        jLabel1.setText(PluginServices.getText(this, "name") + ":");
436 3746 jaume
                }
437
438
                return jLabel1;
439
        }
440
441
        /**
442
         * This method initializes lblTitle
443
         *
444
         * @return javax.swing.JLabel
445
         */
446
        private javax.swing.JLabel getLblTitle() {
447
                if (lblTitle == null) {
448
                        lblTitle = new javax.swing.JLabel();
449
                        lblTitle.setText("-");
450
                }
451
452
                return lblTitle;
453
        }
454
455
        /**
456
         * This method initializes jScrollPane
457
         *
458
         * @return javax.swing.JScrollPane
459
         */
460
        private javax.swing.JScrollPane getJScrollPane() {
461
                if (jScrollPane == null) {
462
                        jScrollPane = new javax.swing.JScrollPane();
463
                        jScrollPane.setViewportView(getTxtAbstract());
464
                        jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60));
465
                        jScrollPane.setBounds(10, 47, 450, 267);
466
                }
467
468
                return jScrollPane;
469
        }
470
471
        /**
472
         * This method initializes txtAbstract
473
         *
474
         * @return javax.swing.JTextArea
475
         */
476
        private javax.swing.JTextArea getTxtAbstract() {
477
                if (txtAbstract == null) {
478
                        txtAbstract = new javax.swing.JTextArea();
479
                        txtAbstract.setWrapStyleWord(true);
480
                        txtAbstract.setColumns(30);
481
                        txtAbstract.setLineWrap(true);
482
                }
483
484
                return txtAbstract;
485
        }
486
487
        /**
488
         * This method initializes panelPage1
489
         *
490
         * @return javax.swing.JPanel
491
         */
492
        private javax.swing.JPanel getPanelPage1() {
493
                if (panelPage1 == null) {
494
                        panelPage1 = new javax.swing.JPanel();
495
                        panelPage1.setLayout(null);
496
                        panelPage1.setPreferredSize(new java.awt.Dimension(480, 220));
497
                        panelPage1.setVisible(true);
498
                        panelPage1.setBounds(15, 5, 480, 427);
499
                        panelPage1.add(getJPanel1(), null);
500
                        panelPage1.add(getJPanel(), null);
501
                }
502
503
                return panelPage1;
504
        }
505
506
        /**
507
         * This method initializes btnSiguiente
508
         *
509
         * @return javax.swing.JButton
510
         */
511
        private javax.swing.JButton getBtnSiguiente() {
512
                if (btnSiguiente == null) {
513 6115 jaume
                        btnSiguiente = new org.gvsig.gui.beans.swing.JButton();
514 3746 jaume
                        btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30));
515
                        btnSiguiente.setBounds(395, 444, 100, 20);
516
                        btnSiguiente.setText(PluginServices.getText(this, "siguiente"));
517
                        btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
518 4507 jorpiell
                                public void actionPerformed(java.awt.event.ActionEvent e) {
519 4511 ldiaz
                                        if (page > firstPage) {
520 4507 jorpiell
                                                // si page es mayor que cero, vamos enfocando las
521
                                                // sucesivas SOLAPAS del WCSParamsPanel
522
                                                wmsParamsPanel.avanzaTab();
523
                                                page = wmsParamsPanel.currentPage();
524 3746 jaume
                                        }
525 4507 jorpiell
                                        page++;
526
                                        getPanelPage1().setVisible(false);
527
                                        getPanelPage2().setVisible(true);
528
                                        activarVisualizarBotones();
529
                                }
530
                        });
531 3746 jaume
                }
532
                return btnSiguiente;
533
        }
534
535
        /**
536
         * This method initializes btnAnterior
537
         *
538
         * @return javax.swing.JButton
539
         */
540
        private javax.swing.JButton getBtnAnterior() {
541
                if (btnAnterior == null) {
542 6115 jaume
                        btnAnterior = new org.gvsig.gui.beans.swing.JButton();
543
                        btnAnterior.setBounds(292, 444, 100, 20);
544 6122 jaume
                        btnAnterior.setPreferredSize(new java.awt.Dimension(100, 30));
545 3746 jaume
                        btnAnterior.setText(PluginServices.getText(this, "anterior"));
546
                        btnAnterior.addActionListener(new java.awt.event.ActionListener() {
547
                                public void actionPerformed(java.awt.event.ActionEvent e) {
548
                                        page --;
549 4511 ldiaz
                                        if (page > firstPage) {
550 3746 jaume
                                                // Tenemos que retroceder en el wcsParamsPanel
551
                                                wmsParamsPanel.retrocedeTab();
552
                                                page = wmsParamsPanel.currentPage() + 1;
553
                                                activarVisualizarBotones();
554 4511 ldiaz
                                        } else if (page==firstPage){
555 3746 jaume
                                                activarVisualizarBotones();
556 4511 ldiaz
                                                page = firstPage +1;
557 3746 jaume
                                                //wmsParamsPanel.limpiaWizard();
558
                                                getLblTitle().setText("-");
559
                                                getTxtAbstract().setText("");
560
                                                wmsParamsPanel.retrocedeTab();
561
                                                getPanelPage1().setVisible(true);
562
                                                getPanelPage2().setVisible(false);
563
                                                getBtnSiguiente().setEnabled(false);
564 6115 jaume
                                                connected = false;
565 3746 jaume
                                        }
566
                                        listenerSupport.callStateChanged(wmsParamsPanel.isCorrectlyConfigured());
567
                                }
568
                        });
569
                }
570
571
                return btnAnterior;
572
        }
573
574
        /**
575
         * This method initializes jPanel1
576
         *
577
         * @return javax.swing.JPanel
578
         */
579
        private javax.swing.JPanel getJPanel1() {
580
                if (jPanel1 == null) {
581
                        jPanel1 = new javax.swing.JPanel();
582
                        jPanel1.setLayout(null);
583
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
584 3774 jaume
                                        null, PluginServices.getText(this, "server"),
585 3746 jaume
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
586
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
587
                        jPanel1.setBounds(2, 5, 477, 85);
588
                        jPanel1.add(getTxtHost(), null);
589
                        jPanel1.add(getBtnConnect(), null);
590 4501 jaume
                        jPanel1.add(getChkCaching(), null);
591 3746 jaume
                }
592
593
                return jPanel1;
594
        }
595
596
        /**
597
         * DOCUMENT ME!
598
         *
599
         * @param listener
600
         */
601
        public void addWizardListener(WizardListener listener) {
602
                listenerSupport.addWizardListener(listener);
603
        }
604
605
        /**
606
         * DOCUMENT ME!
607
         *
608
         * @param listener
609
         */
610
        public void removeWizardListener(WizardListener listener) {
611
                listenerSupport.removeWizardListener(listener);
612
        }
613
614
        /**
615
         * DOCUMENT ME!
616
         *
617
         * @return
618
         */
619
//        public WMSWizardDataSource getDataSource() {
620 4507 jorpiell
//        return dataSource;
621 3746 jaume
//        }
622
623
        /**
624
         * DOCUMENT ME!
625
         *
626
         * @param source
627
         */
628
//        public void setDataSource(WMSWizardDataSource source) {
629 4507 jorpiell
//        dataSource = source;
630 3746 jaume
//        }
631
632
633
        /**
634
         * DOCUMENT ME!
635
         *
636
         * @return DOCUMENT ME!
637
         */
638
        public String getSRS() {
639
                return wmsParamsPanel.getSRS();
640
        }
641
642
        /**
643
         * DOCUMENT ME!
644
         *
645
         * @return DOCUMENT ME!
646
         */
647
        public String getFormat() {
648
                return wmsParamsPanel.getFormat();
649
        }
650
651
        /**
652
         * DOCUMENT ME!
653
         *
654
         * @return DOCUMENT ME!
655
         */
656
        public TreePath[] getSelectedLayers() {
657
                return wmsParamsPanel.getSelectedLayers();
658
        }
659
660
        /**
661
         * DOCUMENT ME!
662
         *
663
         * @return DOCUMENT ME!
664
         */
665 4222 jaume
        public Rectangle2D getLayersRectangle() throws CannotReprojectException{
666 3746 jaume
                return wmsParamsPanel.getLayersRectangle();
667
        }
668
669
670 4501 jaume
671 3746 jaume
        /**
672 4222 jaume
         * Devuelve el host que est? escrito en el cuadro de texto del host o null
673
         * en caso de que no haya nada escrito o est? mal escrito
674 3746 jaume
         *
675
         * @return URL del host
676
         */
677
        public URL getHost() {
678
                try {
679 4513 ldiaz
                        if ((cmbHost == null)|| (cmbHost.getModel().getSelectedItem() == null))
680 6115 jaume
                                return new URL(dataSource.getHost());
681 4513 ldiaz
                        else
682
                                return new URL(cmbHost.getModel().getSelectedItem().toString());
683 3746 jaume
                } catch (MalformedURLException e) {
684
                        return null;
685
                }
686
        }
687
688
        /**
689
         * DOCUMENT ME!
690
         *
691
         * @return Nombre de la capa que aparece en el TOC.
692
         */
693
        public String getLayerName() {
694
                return wmsParamsPanel.getLayerName();
695
        }
696
697 4501 jaume
698 3746 jaume
        public void initWizard() {
699
                dataSource = new WMSWizardData();
700
        }
701
702
        public void execute() {
703 4507 jorpiell
704 3746 jaume
        }
705
706
        /**
707
         * DOCUMENT ME!
708
         *
709
         * @return DOCUMENT ME!
710
         */
711 4624 ldiaz
        protected String getLayersQuery() {
712 3746 jaume
                return wmsParamsPanel.getLayersQuery();
713
        }
714 4501 jaume
715 6434 ldiaz
        //gets all the layers available in the WMS
716
        public FLayer getAllLayers(){
717
                return wmsParamsPanel.getAllLayers();
718
        }
719 6500 jaume
720 4511 ldiaz
        public FLayer getLayer(){
721 6115 jaume
722
                return wmsParamsPanel.getLayer();
723 4947 ldiaz
//                if(wmsParamsPanel.getDisagregatedLayers()){
724
//                        return getLayerTree();
725
//                }else{
726
//                        return getLayerPlain();
727 6115 jaume
//                }
728 4511 ldiaz
        }
729 6115 jaume
730
//        private Object[] getFullPath(String name){
731 4511 ldiaz
//                Vector path = new Vector();
732 6115 jaume
//                WMSLayerNode layerNode;
733 4511 ldiaz
//                WMSLayerNode parent;
734
//                for (int i = 0; i <wmsParamsPanel.getLstSelectedLayers().getModel().getSize(); i++) {
735
//                        layerNode = (WMSLayerNode)wmsParamsPanel.getLstSelectedLayers().getModel().getElementAt(i);
736
//                        if(layerNode.getName().compareTo( name ) == 0 ){
737
//                                path.add(layerNode);
738
//                                parent = (WMSLayerNode)layerNode.getParent().clone();
739
//                                while ( parent != null){
740
//                                        path.add(parent);
741
//                                        parent = (WMSLayerNode)parent.getParent().clone();
742
//                                }
743
//                        }
744
//                }
745
//                return path.toArray();
746 4507 jorpiell
//        }
747 6115 jaume
748 4511 ldiaz
        /**
749
         * If user does not select the chekbox Disagregate layers, will get the layer tree in WMS
750
         * @return
751
         */
752 6115 jaume
    protected FLayer getLayerTree() {
753
        LayerTree layerTree = wmsParamsPanel.getLayerStructure();
754 4511 ldiaz
                TreePath[] selection = (TreePath[])wmsParamsPanel.getSelectedPaths().toArray(new TreePath[0]);//layerTree.getSelectionPaths();
755 6115 jaume
                if (selection!=null){
756
                        return getSubTree((WMSLayerNode)layerTree.getModel().getRoot(), selection);
757
                }
758 4511 ldiaz
                return null;
759
    }
760 6115 jaume
761 4624 ldiaz
    protected boolean nodeSelected(TreePath[] selection, WMSLayerNode node){
762 6115 jaume
                for (int i = 0; i < selection.length; i++) {
763 4511 ldiaz
                        Object[] components = selection[i].getPath();
764
                        for (int j=0; j < components.length ; j++)
765 6115 jaume
                        {
766 4511 ldiaz
                                if (components[j] instanceof WMSLayerNode){
767
                                        if (((WMSLayerNode)components[j]).getTitle().compareTo(node.getTitle()) == 0){
768
                                                return true;
769
                                        }
770
                                }
771 6115 jaume
                        }
772
                }
773 4511 ldiaz
                return false;
774
    }
775 6115 jaume
776 8765 jjdelcerro
    /**
777
     * @deprecated
778
     * @param node
779
     * @param selection
780
     * @return
781
     */
782 4624 ldiaz
        protected FLayer getSubTree(WMSLayerNode node, TreePath[] selection)
783 6115 jaume
        {
784 4511 ldiaz
                if (node.getChildren().size() > 0)
785 4507 jorpiell
                {
786 4609 ldiaz
                //com.iver.cit.gvsig.gui.View v = (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
787 6115 jaume
                FLayers l = new FLayers(this.getMapCtrl().getMapContext(), null);
788 4511 ldiaz
                l.setName(node.getTitle());
789
                        for(int i = 0; i < node.getChildren().size(); i++ ){
790
                                if (nodeSelected(selection, (WMSLayerNode)(node.getChildren().get(i))))
791
                                {
792
                                        FLayer lyr = getSubTree((WMSLayerNode)node.getChildren().get(i), selection);
793
                                        if(lyr != null){
794
                                                l.addLayer(lyr);
795
                                        }
796
                                }
797
                        }
798
                        return l;
799 4507 jorpiell
                }
800 4511 ldiaz
                else{
801
                        if (nodeSelected(selection, node))
802
                        {
803
                                FLyrWMS layer = new FLyrWMS();
804
                                layer.setHost(getHost());
805
                                try {
806 6115 jaume
                                        layer.setFullExtent(getLayersRectangle());
807
                                } catch (CannotReprojectException e) {
808 4511 ldiaz
                                        e.printStackTrace();
809 4609 ldiaz
                                        return null;
810 6115 jaume
                                }
811 4511 ldiaz
                                layer.setFormat(getFormat());
812 4645 ldiaz
                                layer.setLayerQuery(node.getName());
813 4609 ldiaz
                        layer.setInfoLayerQuery(getQueryableLayerQuery());
814
                        layer.setSRS(getSRS());
815 4645 ldiaz
                        layer.setName(node.getTitle());
816 4609 ldiaz
                        layer.setWmsTransparency(getTransparency());
817
                        layer.setStyles(getStyles());
818
                        layer.setDimensions(getDimensions());
819
                        layer.setDriver(getDriver());
820
                        layer.setOnlineResources(getOnlineResources());
821
                        layer.setFixedSize(getFixedSize());
822 8765 jjdelcerro
                        layer.setQueryable(node.isQueryable());
823 6115 jaume
824 4609 ldiaz
                        return layer;
825 6115 jaume
826 4511 ldiaz
                        }else{
827
                                return null;
828 6115 jaume
                        }
829
                }
830
        }
831 4507 jorpiell
832 4511 ldiaz
        /**
833 8765 jjdelcerro
         * @deprecated
834 4511 ldiaz
         * If user selects the chekbox Disagregate layers, will get the selected layers rendered in one
835
         * the tree structure in WMS will be lost.
836
         * @return
837
         */
838 4624 ldiaz
    protected FLayer getLayerPlain(){
839 4511 ldiaz
        FLyrWMS layer = new FLyrWMS();
840
        layer.setHost(getHost());
841
        try{
842
                layer.setFullExtent(getLayersRectangle());
843
        }catch(CannotReprojectException ex)
844
        {
845
                ex.printStackTrace();
846
                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), ex.getMessage());
847
                return null;
848
        }
849
        layer.setFormat(getFormat());
850
        layer.setLayerQuery(getLayersQuery());
851
        layer.setInfoLayerQuery(getQueryableLayerQuery());
852
        layer.setSRS(getSRS());
853
        layer.setName(getLayerName());
854
        layer.setWmsTransparency(getTransparency());
855
        layer.setStyles(getStyles());
856
        layer.setDimensions(getDimensions());
857
        layer.setDriver(getDriver());
858
        layer.setOnlineResources(getOnlineResources());
859
        layer.setFixedSize(getFixedSize());
860
        layer.setQueryable(isQueryable());
861
        return layer;
862
    }
863
864 4624 ldiaz
        protected boolean isQueryable() {
865 4222 jaume
                return dataSource.isQueryable();
866
        }
867
868 4624 ldiaz
        protected Dimension getFixedSize() {
869 4507 jorpiell
                return wmsParamsPanel.getFixedSize();
870
        }
871
872 4222 jaume
        private Hashtable getOnlineResources() {
873
                return wmsParamsPanel.getOnlineResources();
874
        }
875
876 4624 ldiaz
        protected FMapWMSDriver getDriver() {
877 3746 jaume
                return wmsParamsPanel.getDriver();
878
        }
879
880
        /**
881 4507 jorpiell
         * @return
882
         */
883 4624 ldiaz
        protected Vector getStyles() {
884 4507 jorpiell
                return wmsParamsPanel.getStyles();
885
        }
886 3746 jaume
887 4624 ldiaz
        protected Vector getDimensions() {
888 4507 jorpiell
                return wmsParamsPanel.getDimensions();
889
        }
890 3746 jaume
891 4507 jorpiell
        /**
892
         * @return
893
         */
894 4624 ldiaz
        protected boolean getTransparency() {
895 4507 jorpiell
                return wmsParamsPanel.getTransparency();
896
        }
897
898
        /**
899 3746 jaume
         * DOCUMENT ME!
900
         *
901
         * @return DOCUMENT ME!
902
         */
903
        public String getQueryableLayerQuery() {
904
                return wmsParamsPanel.getQueryableLayerQuery();
905
        }
906 4501 jaume
907
        /**
908 6115 jaume
         * This method initializes chkCaching
909
         *
910
         * @return javax.swing.JCheckBox
911
         */
912 4501 jaume
        private JCheckBox getChkCaching() {
913
                if (chkCaching == null) {
914
                        chkCaching = new JCheckBox();
915
                        chkCaching.setBounds(7, 51, 349, 20);
916
                        chkCaching.setText(PluginServices.getText(this, "refresh_capabilities"));
917
                        chkCaching.setToolTipText(PluginServices.getText(this, "refresh_capabilities_tooltip"));
918
                        chkCaching.setSelected(refreshing);
919 6115 jaume
                        chkCaching.addItemListener(new java.awt.event.ItemListener() {
920 4501 jaume
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
921
                                        refreshing = chkCaching.isSelected();
922
                                }
923
                        });
924 6115 jaume
                        chkCaching.addActionListener(new java.awt.event.ActionListener() {
925
                                public void actionPerformed(java.awt.event.ActionEvent e) {
926 4501 jaume
                                        fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
927
                                }
928
                        });
929 4507 jorpiell
930 4501 jaume
                }
931
                return chkCaching;
932
        }
933 6122 jaume
934
        /**
935
         * This method initializes pnlName
936
         *
937
         * @return javax.swing.JPanel
938
         */
939
        private JPanel getPnlName() {
940
                if (pnlName == null) {
941
                        pnlName = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0));
942
                        pnlName.setBounds(new java.awt.Rectangle(9,19,452,24));
943
                        pnlName.add(getJLabel1(), null);
944
                        pnlName.add(getLblTitle(), null);
945
                }
946
                return pnlName;
947
        }
948 3746 jaume
}  //  @jve:decl-index=0:visual-constraint="10,10"