Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / wcs / WCSWizard.java @ 2541

History | View | Annotate | Download (22.4 KB)

1 1877 luisw
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3 2012 jaume
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4 1877 luisw
 *
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.wcs;
42
43 2371 jaume
import java.awt.Event;
44
import java.awt.event.ActionListener;
45 2331 jaume
import java.awt.geom.Point2D;
46 1877 luisw
import java.awt.geom.Rectangle2D;
47 1961 jaume
import java.io.IOException;
48 1877 luisw
import java.net.MalformedURLException;
49
import java.net.URL;
50
51
import javax.swing.DefaultComboBoxModel;
52 1961 jaume
import javax.swing.JOptionPane;
53 1877 luisw
54
import org.apache.log4j.Logger;
55
56
import com.iver.andami.PluginServices;
57 2056 luisw
import com.iver.cit.gvsig.fmap.DriverException;
58 2048 jaume
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver;
59 1877 luisw
import com.iver.cit.gvsig.fmap.layers.FLayer;
60
import com.iver.cit.gvsig.fmap.layers.FLyrWCS;
61 2048 jaume
import com.iver.cit.gvsig.fmap.layers.FMapWCSAdaptor;
62 1877 luisw
import com.iver.cit.gvsig.gui.WCSDataSourceAdapter;
63
import com.iver.cit.gvsig.gui.WizardPanel;
64
import com.iver.cit.gvsig.gui.Panels.WCSParamsPanel;
65 2280 fjp
import com.iver.cit.gvsig.gui.wizards.WizardListener;
66
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport;
67 1877 luisw
import com.iver.utiles.NotExistInXMLEntity;
68
import com.iver.utiles.XMLEntity;
69
import com.iver.utiles.swing.JComboBox;
70 1961 jaume
71 1877 luisw
/**
72 2541 jaume
 * Class implementing the WCSWizard.
73 2097 jaume
 *
74 1961 jaume
 * Clase que implementa el Wizard para coberturas WCS
75 1877 luisw
 * @author Jaume Dom?nguez Faus
76
 */
77
public class WCSWizard extends WizardPanel {
78
        private static Logger logger = Logger.getLogger(WCSWizard.class.getName());
79
        private int page = 0;
80
        private boolean conectado = false;
81
        private javax.swing.JPanel jContentPane = null;
82
        private JComboBox cmbHost = null;
83
        private javax.swing.JButton btnDetalles = null;
84
        private javax.swing.JPanel jPanel = null;
85
        private javax.swing.JLabel jLabel1 = null;
86
        private javax.swing.JLabel lblTitle = null;
87
        private javax.swing.JScrollPane jScrollPane = null;
88
        private javax.swing.JTextArea txtAbstract = null;
89
        private javax.swing.JPanel panelPage1 = null;
90
        private javax.swing.JPanel panelPage2 = null;
91
        private CoverageListModel selectedLayersModel = new CoverageListModel();
92
        private javax.swing.JButton btnSiguiente = null;
93
        private javax.swing.JButton btnAnterior = null;
94
        private javax.swing.JPanel jPanel1 = null;
95
        private WizardListenerSupport listenerSupport = new WizardListenerSupport();
96
        private WCSParamsPanel wcsParamsTabbedPane = null;
97 1986 jaume
        private WCSWizardDataSource dataSource;
98 1886 luisw
        private WCSWizardData data = null;
99 1961 jaume
100 1877 luisw
        /**
101
         * This is the default constructor
102
         */
103
        public WCSWizard() {
104
                super();
105
                initialize();
106
        }
107
108
        /**
109
         * This method initializes this
110
         */
111
        private void initialize() {
112
                setTabName("WCS");
113
                this.setSize(510, 311);
114
                this.setLayout(null);
115
                this.setPreferredSize(new java.awt.Dimension(750, 320));
116
                this.setVisible(true);
117
                this.add(getPanelPage1(), null);
118
                this.add(getPanelPage2(), null);
119
                this.add(getBtnAnterior(), null);
120
                this.add(getBtnSiguiente(), null);
121
                activarVisualizarBotones();
122
        }
123
124
        /**
125 2097 jaume
         * Returns the selected coverage name
126
         *
127 1961 jaume
         * Devuelve el nombre de la cobertura seleccionada
128
         * @return String
129 1877 luisw
         */
130 1961 jaume
        private String getNomCobertura(){
131 1979 jaume
                return (String) wcsParamsTabbedPane.getNomCobertura();
132 1961 jaume
        }
133 1979 jaume
134 1877 luisw
        /**
135 2097 jaume
         * A pure JavaScript alert dialog.
136
         *
137
         * Un di?logo de alert al m?s puro estilo estilo JavaScript
138 1961 jaume
         * @param text
139 1877 luisw
         */
140 1961 jaume
        private void alert(String text) {
141
                JOptionPane.showMessageDialog(null, text, "Error", JOptionPane.ERROR_MESSAGE);
142 1886 luisw
        }
143 1961 jaume
144 1877 luisw
        /**
145 2097 jaume
         * Adds the host addres to a persistent data storage.
146
         *
147 1961 jaume
         * con addHost guardamos la informaci?n del combo de servidores en un
148
         * almac?n persistente
149
         *
150 1886 luisw
         * @param host
151 1877 luisw
         */
152
        private void addHost(String host) {
153
                host = host.trim();
154
155
                DefaultComboBoxModel model = (DefaultComboBoxModel) getTxtHost()
156 1961 jaume
                                .getModel();
157 1877 luisw
158
                if (model.getIndexOf(host) < 0) {
159
                        model.addElement(host);
160
161
                        PluginServices ps = PluginServices.getPluginServices(this);
162
                        XMLEntity xml = ps.getPersistentXML();
163
164
                        try {
165
                                String[] servers = xml.getStringArrayProperty("wcs-servers");
166
                                String[] newServers = new String[servers.length + 1];
167
                                System.arraycopy(servers, 0, newServers, 0, servers.length);
168
                                newServers[servers.length] = host;
169
                                xml.putProperty("wcs-servers", newServers);
170
                        } catch (NotExistInXMLEntity e) {
171
                                xml.putProperty("wcs-servers", new String[] { host });
172
                        }
173
174
                        ps.setPersistentXML(xml);
175
                }
176
        }
177
178
        /**
179 2097 jaume
         * Fills up the initial WCSWizard controls.
180
         *
181 1886 luisw
         * Rellena los primeros controles del WCS Wizard
182
         *
183
         * jaume
184 1877 luisw
         */
185
        private void rellenarControles() {
186
                try {
187
                        String host = cmbHost.getModel().getSelectedItem().toString();
188 1961 jaume
189 1886 luisw
                        data = dataSource.detalles(new URL(host));
190 1961 jaume
                        int i = 0;
191 1877 luisw
192 1961 jaume
                        addHost(host);
193 1882 luisw
                        getLblTitle().setText(data.getTitle());
194
                        getTxtAbstract().setText(data.getDescription());
195 1961 jaume
                        wcsParamsTabbedPane.getLstCoverages().setListData(
196
                                        data.getCoverageNames());
197 1979 jaume
                        wcsParamsTabbedPane.setWizardData(data);
198
                        wcsParamsTabbedPane.setDataSource(dataSource);
199 1877 luisw
                        conectado = true;
200
                        activarVisualizarBotones();
201 2056 luisw
                } catch (DriverException soe) {
202 1961 jaume
                        alert(PluginServices.getText(this, "servidor_wcs_no_responde"));
203
                } catch (IOException ioe){
204
                        alert(PluginServices.getText(this, "error_comunicacion_servidor"));
205 1877 luisw
                } catch (Exception e) {
206
                        listenerSupport.callError(e);
207
                }
208
        }
209
210
        /**
211 2097 jaume
         * Enables or disables the Next and Previous buttons according with the current
212
         * page and the enabled pages.
213 1877 luisw
         */
214
        private void activarVisualizarBotones() {
215
                if (page == 0) {
216
                        getBtnAnterior().setEnabled(false);
217
                        getBtnSiguiente().setVisible(true);
218
                        if (conectado) {
219
                                getBtnSiguiente().setEnabled(true);
220
                        } else {
221
                                getBtnSiguiente().setEnabled(false);
222
                        }
223 1961 jaume
                } else if (page < wcsParamsTabbedPane.getNumTabs()) {
224 1877 luisw
                        getBtnSiguiente().setEnabled(true);
225
                        getBtnSiguiente().setVisible(true);
226
                        getBtnAnterior().setEnabled(true);
227
                        getBtnAnterior().setVisible(true);
228 2097 jaume
                        if (wcsParamsTabbedPane.nextPageEnabled()==-1){
229
                            getBtnSiguiente().setEnabled(false);
230
                        }
231 1979 jaume
                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
232 1961 jaume
                } else if (page == wcsParamsTabbedPane.getNumTabs()) {
233 1877 luisw
                        getBtnSiguiente().setVisible(false);
234
                        getBtnSiguiente().setEnabled(false);
235 1979 jaume
                        listenerSupport.callStateChanged(wcsParamsTabbedPane
236
                                        .hayParametrosSuficientes());
237 1877 luisw
                }
238 1961 jaume
239
        }
240
241 1877 luisw
242 1961 jaume
243 1877 luisw
        /**
244 1886 luisw
         * This method initializes txtHost from the persistent data storage
245 1961 jaume
         *
246 1877 luisw
         * @return javax.swing.JTextField
247
         */
248
        private javax.swing.JComboBox getTxtHost() {
249
                if (cmbHost == null) {
250
                        cmbHost = new JComboBox();
251
                        cmbHost.setModel(new DefaultComboBoxModel());
252
                        cmbHost.setPreferredSize(new java.awt.Dimension(350, 20));
253
                        cmbHost.setEditable(true);
254
255
                        XMLEntity xml = PluginServices.getPluginServices(this)
256 1961 jaume
                                        .getPersistentXML();
257 1877 luisw
                        if (xml == null)
258
                                xml = new XMLEntity();
259 1961 jaume
260 1877 luisw
                        if (!xml.contains("wcs-servers")) {
261
                                String[] servers = new String[2];
262 1963 jaume
                                servers[0] = "http://hypnos.cbs.umn.edu/cgi-bin/mapserv43d?map=/data/wcs/demo.map";
263 1990 jaume
                                servers[1] = "http://172.19.21.36/cgi-bin/wcs";
264 1877 luisw
265
                                xml.putProperty("wcs-servers", servers);
266
                        }
267
268
                        try {
269
                                String[] servers = xml.getStringArrayProperty("wcs-servers");
270
271
                                for (int i = 0; i < servers.length; i++) {
272 1961 jaume
                                        ((DefaultComboBoxModel) cmbHost.getModel())
273
                                                        .addElement(servers[i]);
274 1877 luisw
                                }
275
                        } catch (NotExistInXMLEntity e) {
276 1961 jaume
                        }
277 1877 luisw
                }
278
279
                return cmbHost;
280
        }
281
282 1979 jaume
283 1877 luisw
        /**
284
         * This method initializes btnDetalles
285 1961 jaume
         *
286 1877 luisw
         * @return javax.swing.JButton
287
         */
288
        private javax.swing.JButton getBtnDetalles() {
289
                if (btnDetalles == null) {
290
                        btnDetalles = new javax.swing.JButton();
291
                        btnDetalles.setPreferredSize(new java.awt.Dimension(100, 20));
292
                        btnDetalles.setText(PluginServices.getText(this, "detalles"));
293
                        btnDetalles.addActionListener(new java.awt.event.ActionListener() {
294 1961 jaume
                                public void actionPerformed(java.awt.event.ActionEvent e) {
295 1979 jaume
                                        wcsParamsTabbedPane.limpiaWizard();
296 1961 jaume
                                        conectado = false;
297
                                        rellenarControles();
298
                                }
299
                        });
300 1877 luisw
                }
301
302
                return btnDetalles;
303
        }
304
305
        /**
306
         * This method initializes jPanel
307 1961 jaume
         *
308 1877 luisw
         * @return javax.swing.JPanel
309
         */
310
        private javax.swing.JPanel getJPanel() {
311
                if (jPanel == null) {
312
                        jPanel = new javax.swing.JPanel();
313
                        jPanel.setLayout(null);
314
                        jPanel.setPreferredSize(new java.awt.Dimension(470, 130));
315 1961 jaume
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
316
                                        PluginServices.getText(this, "descripcion"),
317 1877 luisw
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
318 1961 jaume
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
319
                                        null));
320 1877 luisw
                        jPanel.setBounds(2, 67, 477, 197);
321
                        jPanel.add(getJLabel1(), null);
322
                        jPanel.add(getLblTitle(), null);
323
                        jPanel.add(getJScrollPane(), null);
324
                }
325
326
                return jPanel;
327
        }
328
329
        /**
330
         * This method initializes jLabel1
331 1961 jaume
         *
332 1877 luisw
         * @return javax.swing.JLabel
333
         */
334
        private javax.swing.JLabel getJLabel1() {
335
                if (jLabel1 == null) {
336
                        jLabel1 = new javax.swing.JLabel();
337
                        jLabel1.setText(PluginServices.getText(this, "nombre") + ":");
338
                        jLabel1.setBounds(37, 26, 40, 15);
339
                }
340
341
                return jLabel1;
342
        }
343
344
        /**
345
         * This method initializes lblTitle
346 1961 jaume
         *
347 1877 luisw
         * @return javax.swing.JLabel
348
         */
349
        private javax.swing.JLabel getLblTitle() {
350
                if (lblTitle == null) {
351
                        lblTitle = new javax.swing.JLabel();
352
                        lblTitle.setText("-");
353
                        lblTitle.setPreferredSize(new java.awt.Dimension(350, 16));
354
                        lblTitle.setBounds(82, 26, 350, 16);
355
                }
356
357
                return lblTitle;
358
        }
359
360
        /**
361
         * This method initializes jScrollPane
362 1961 jaume
         *
363 1877 luisw
         * @return javax.swing.JScrollPane
364
         */
365
        private javax.swing.JScrollPane getJScrollPane() {
366
                if (jScrollPane == null) {
367
                        jScrollPane = new javax.swing.JScrollPane();
368
                        jScrollPane.setViewportView(getTxtAbstract());
369
                        jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60));
370 1886 luisw
                        jScrollPane.setBounds(10, 47, 450, 130);
371 1877 luisw
                }
372
373
                return jScrollPane;
374
        }
375
376
        /**
377
         * This method initializes txtAbstract
378 1961 jaume
         *
379 1877 luisw
         * @return javax.swing.JTextArea
380
         */
381
        private javax.swing.JTextArea getTxtAbstract() {
382
                if (txtAbstract == null) {
383
                        txtAbstract = new javax.swing.JTextArea();
384
                        txtAbstract.setWrapStyleWord(true);
385
                        txtAbstract.setColumns(30);
386
                        txtAbstract.setLineWrap(true);
387
                }
388
389
                return txtAbstract;
390
        }
391
392
        /**
393
         * This method initializes panelPage1
394 1961 jaume
         *
395 1877 luisw
         * @return javax.swing.JPanel
396
         */
397
        private javax.swing.JPanel getPanelPage1() {
398
                if (panelPage1 == null) {
399
                        panelPage1 = new javax.swing.JPanel();
400
                        panelPage1.setLayout(null);
401
                        panelPage1.setPreferredSize(new java.awt.Dimension(480, 220));
402
                        panelPage1.setVisible(true);
403
                        panelPage1.setBounds(15, 5, 480, 262);
404
                        panelPage1.add(getJPanel1(), null);
405
                        panelPage1.add(getJPanel(), null);
406
                }
407
408
                return panelPage1;
409
        }
410
411
        /**
412
         * This method initializes panelPage2
413 1961 jaume
         *
414 1877 luisw
         * @return javax.swing.JPanel
415
         */
416
        private javax.swing.JPanel getPanelPage2() {
417
                if (panelPage2 == null) {
418
                        panelPage2 = new javax.swing.JPanel();
419
                        panelPage2.setLayout(null);
420
                        panelPage2.setPreferredSize(new java.awt.Dimension(490, 300));
421
                        panelPage2.setVisible(false);
422
                        wcsParamsTabbedPane = new WCSParamsPanel();
423 1961 jaume
                        wcsParamsTabbedPane.getJTabbedPane().addMouseListener(
424
                                        new java.awt.event.MouseAdapter() {
425
                                                public void mouseClicked(java.awt.event.MouseEvent e) {
426
                                                        page = wcsParamsTabbedPane.getIndiceSolapaActual() + 1;
427
                                                        activarVisualizarBotones();
428
                                                }
429
                                        });
430
                        wcsParamsTabbedPane.getLstCoverages().addListSelectionListener(new javax.swing.event.ListSelectionListener() {
431
                                public void valueChanged(javax.swing.event.ListSelectionEvent e) {
432 1979 jaume
                                        wcsParamsTabbedPane.actualizaWizard();
433 1877 luisw
                                }
434
                        });
435 1961 jaume
                        wcsParamsTabbedPane.getLstCRSs().addListSelectionListener(new javax.swing.event.ListSelectionListener() {
436
                                public void valueChanged(javax.swing.event.ListSelectionEvent e) {
437 1979 jaume
                                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
438 1886 luisw
                                }
439
                        });
440 1961 jaume
                        wcsParamsTabbedPane.getLstFormats().addListSelectionListener(new javax.swing.event.ListSelectionListener() {
441
                                public void valueChanged(javax.swing.event.ListSelectionEvent e) {
442 1979 jaume
                                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
443 1886 luisw
                                }
444
                        });
445 1961 jaume
                        wcsParamsTabbedPane.getLstSelectedTimes().addListSelectionListener(new javax.swing.event.ListSelectionListener() {
446
                                public void valueChanged(javax.swing.event.ListSelectionEvent e) {
447 1979 jaume
                                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
448 1886 luisw
                                }
449
                        });
450 1961 jaume
                        wcsParamsTabbedPane.getLstParamValues().addListSelectionListener(new javax.swing.event.ListSelectionListener() {
451
                                public void valueChanged(javax.swing.event.ListSelectionEvent e) {
452 1979 jaume
                                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
453 1886 luisw
                                }
454
                        });
455 1961 jaume
                        wcsParamsTabbedPane.getCmbParam().addItemListener(
456
                                        new java.awt.event.ItemListener() {
457
                                                public void itemStateChanged(java.awt.event.ItemEvent e) {
458
                                                        String s = (String) wcsParamsTabbedPane.getLstCoverages().getSelectedValue();
459 1979 jaume
                                                        wcsParamsTabbedPane.actualizaListaParametros(s);
460 1961 jaume
                                                }
461
                                        });
462 2371 jaume
                        wcsParamsTabbedPane.getTxtInterval().addKeyListener(new java.awt.event.KeyAdapter() {
463
                                public void keyReleased(java.awt.event.KeyEvent e) {
464
                                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
465
                                }
466
                        });
467
                        wcsParamsTabbedPane.getTxtIntervalEnd().addKeyListener(new java.awt.event.KeyAdapter() {
468
                                public void keyReleased(java.awt.event.KeyEvent e) {
469
                                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
470
                                }
471
                        });
472
                        wcsParamsTabbedPane.getTxtIntervalBegin().addKeyListener(new java.awt.event.KeyAdapter() {
473
                                public void keyReleased(java.awt.event.KeyEvent e) {
474
                                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
475
                                }
476
                        });
477
                        wcsParamsTabbedPane.getRadioSingleInterval().addChangeListener(new javax.swing.event.ChangeListener() {
478
                                public void stateChanged(javax.swing.event.ChangeEvent e) {
479
                                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
480
                                }
481
                        });
482
                        wcsParamsTabbedPane.getRadioMultipleInterval().addChangeListener(new javax.swing.event.ChangeListener() {
483
                                public void stateChanged(javax.swing.event.ChangeEvent e) {
484
                                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
485
                                }
486
                        });
487 1961 jaume
                        wcsParamsTabbedPane.getBtnAddTemps().addActionListener(
488
                                        new java.awt.event.ActionListener() {
489
                                                public void actionPerformed(java.awt.event.ActionEvent e) {
490 1979 jaume
                                                        wcsParamsTabbedPane.addTiempo();
491 1961 jaume
                                                }
492
                                        });
493
                        wcsParamsTabbedPane.getBtnDelTemps().addActionListener(
494
                                        new java.awt.event.ActionListener() {
495
                                                public void actionPerformed(java.awt.event.ActionEvent e) {
496 1979 jaume
                                                        wcsParamsTabbedPane.delTiempo();
497 1961 jaume
                                                }
498
                                        });
499 1877 luisw
                        panelPage2.add(wcsParamsTabbedPane, null);
500 1886 luisw
                        panelPage2.setBounds(10, 5, 496, 276);
501 1961 jaume
502 1877 luisw
                }
503
504
                return panelPage2;
505
        }
506
507 1961 jaume
508
509 1886 luisw
        /**
510 1877 luisw
         * This method initializes btnSiguiente
511 1961 jaume
         *
512 1877 luisw
         * @return javax.swing.JButton
513
         */
514
        private javax.swing.JButton getBtnSiguiente() {
515
                if (btnSiguiente == null) {
516
                        btnSiguiente = new javax.swing.JButton();
517
                        btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30));
518
                        btnSiguiente.setText(PluginServices.getText(this, "siguiente"));
519
                        btnSiguiente.setBounds(205, 282, 100, 21);
520
                        btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
521 1961 jaume
                                public void actionPerformed(java.awt.event.ActionEvent e) {
522
                                        if (page > 0) {
523
                                                // si page es mayor que cero, vamos enfocando las
524
                                                // sucesivas SOLAPAS del WCSParamsPanel
525
                                                wcsParamsTabbedPane.avanzaTab();
526
                                                page = wcsParamsTabbedPane.getIndiceSolapaActual();
527 1877 luisw
                                        }
528 1961 jaume
                                        page++;
529
530
                                        getPanelPage1().setVisible(false);
531
                                        getPanelPage2().setVisible(true);
532
                                        activarVisualizarBotones();
533
                                }
534
                        });
535 1877 luisw
                }
536
                return btnSiguiente;
537
        }
538
539
        /**
540
         * This method initializes btnAnterior
541 1961 jaume
         *
542 1877 luisw
         * @return javax.swing.JButton
543
         */
544
        private javax.swing.JButton getBtnAnterior() {
545
                if (btnAnterior == null) {
546
                        btnAnterior = new javax.swing.JButton();
547
                        btnAnterior.setText(PluginServices.getText(this, "anterior"));
548
                        btnAnterior.setPreferredSize(new java.awt.Dimension(100, 30));
549
                        btnAnterior.setBounds(100, 282, 100, 21);
550
                        btnAnterior.addActionListener(new java.awt.event.ActionListener() {
551 1961 jaume
                                public void actionPerformed(java.awt.event.ActionEvent e) {
552
                                        page --;
553
                                        if (page > 0) {
554
                                                // Tenemos que retroceder en el wcsParamsPanel
555
                                                wcsParamsTabbedPane.retrocedeTab();
556
                                                page = wcsParamsTabbedPane.getIndiceSolapaActual() + 1;
557 1877 luisw
                                                activarVisualizarBotones();
558 1961 jaume
                                        } else if (page==0){
559
                                                activarVisualizarBotones();
560
                                                page = 1;
561 1979 jaume
                                                wcsParamsTabbedPane.limpiaWizard();
562 1961 jaume
                                                getLblTitle().setText("-");
563
                                                getTxtAbstract().setText("");
564
                                                wcsParamsTabbedPane.retrocedeTab();
565
                                                getPanelPage1().setVisible(true);
566
                                                getPanelPage2().setVisible(false);
567
                                                getBtnSiguiente().setEnabled(false);
568
                                                conectado = false;
569 1877 luisw
                                        }
570 1979 jaume
                                        listenerSupport.callStateChanged(wcsParamsTabbedPane.hayParametrosSuficientes());
571 1961 jaume
                                }
572
                        });
573 1877 luisw
                }
574
                return btnAnterior;
575
        }
576
577
        /**
578
         * This method initializes jPanel1
579 1961 jaume
         *
580 1877 luisw
         * @return javax.swing.JPanel
581
         */
582
        private javax.swing.JPanel getJPanel1() {
583
                if (jPanel1 == null) {
584
                        jPanel1 = new javax.swing.JPanel();
585
                        jPanel1.add(getTxtHost(), null);
586
                        jPanel1.add(getBtnDetalles(), null);
587
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
588
                                        null, PluginServices.getText(this, "servidor"),
589
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
590 1961 jaume
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
591
                                        null));
592 1877 luisw
                        jPanel1.setBounds(2, 5, 477, 57);
593
                }
594
595
                return jPanel1;
596
        }
597
598
        /**
599 2097 jaume
         * Adds the gvSIG's wizard listener
600 1961 jaume
         *
601 1877 luisw
         * @param listener
602
         */
603 1961 jaume
        public void addWizardListener(WizardListener listener) {
604 1877 luisw
                listenerSupport.addWizardListener(listener);
605
        }
606
607
        /**
608 2097 jaume
         * Removes the gvSIG's wizard listener
609 1961 jaume
         *
610 1877 luisw
         * @param listener
611
         */
612
        public void removeWizardListener(WizardListener listener) {
613
                listenerSupport.removeWizardListener(listener);
614
        }
615
616
        /**
617 2097 jaume
         * Returns the Wizard's data source
618 1961 jaume
         *
619 1877 luisw
         * @return
620
         */
621
        public WCSWizardDataSource getDataSource() {
622
                return dataSource;
623
        }
624
625
        /**
626 2097 jaume
         * sets the wizard's data source
627 1961 jaume
         *
628 1877 luisw
         * @param source
629
         */
630
        public void setDataSource(WCSWizardDataSource source) {
631
                dataSource = source;
632 1979 jaume
633 1877 luisw
        }
634
635
636
        /**
637 2097 jaume
         * returns the selected SRS
638 1961 jaume
         *
639 2097 jaume
         * @return String
640 1877 luisw
         */
641
        public String getSRS() {
642 1979 jaume
                return (String) wcsParamsTabbedPane.getSRS();
643 1877 luisw
        }
644
645
        /**
646 2097 jaume
         * Returns the selected format
647 1961 jaume
         *
648 2097 jaume
         * @return string
649 1877 luisw
         */
650
        public String getFormat() {
651 1979 jaume
                return (String) wcsParamsTabbedPane.getFormat();
652 1877 luisw
        }
653
654
        /**
655 2097 jaume
         * Returns the selected coverage's bounding box
656 1961 jaume
         *
657 2097 jaume
         * @return Rectangle2D
658 1877 luisw
         */
659
        public Rectangle2D getLayersRectangle() {
660 1979 jaume
                return wcsParamsTabbedPane.getLayersRectangle();
661 1877 luisw
        }
662
663
        /**
664 2097 jaume
         * Returns the rectangle that contains all the others
665
         *
666 1877 luisw
         * Obtiene el rect?ngulo que contiene a todos los otros
667 1961 jaume
         *
668 2097 jaume
         * @param rects[]  rectangulos
669 1961 jaume
         *
670 2097 jaume
         * @return Rectangle2D
671 1877 luisw
         */
672
        public static Rectangle2D getRectangle(Rectangle2D[] rects) {
673
                Rectangle2D ret = rects[0];
674
675
                for (int i = 1; i < rects.length; i++) {
676
                        ret.add(rects[i]);
677
                }
678
679
                return ret;
680
        }
681
682
        /**
683 2097 jaume
         * Returns the host typed in the host text field or null if nothing is typed
684
         * or it is not a valid URL.
685
         *
686 1877 luisw
         * Devuelve el host que est? escrito en el cuadro de texto del host o null
687
         * en caso de que no haya nada escrito o est? mal escrito
688 1961 jaume
         *
689 1877 luisw
         * @return URL del host
690
         */
691
        public URL getHost() {
692
                try {
693
                        return new URL(cmbHost.getModel().getSelectedItem().toString());
694
                } catch (MalformedURLException e) {
695
                        return null;
696
                }
697
        }
698
699
        /**
700 2097 jaume
         * Returns the name of the coverage that appears in the TOC
701 1961 jaume
         *
702 2097 jaume
         * @return String
703 1877 luisw
         */
704
        public String getLayerName() {
705 1979 jaume
                return wcsParamsTabbedPane.getLayerName();
706 1877 luisw
        }
707 1961 jaume
708 1877 luisw
        public void initWizard() {
709 1961 jaume
                setDataSource(new WCSDataSourceAdapter());
710 1877 luisw
        }
711
712
        public void execute() {
713
        }
714 2097 jaume
715
        /**
716
         * Returns the name and the selected values (if they are) of the parameter in
717
         * a query string. Such string may directly be concatenated to the query string.
718
         *
719
         * Devuelve el nombre y los valores seleccionados (si hay alguno) del par?metro
720
         * en forma de querystring, de manera que puede ser concatenado a la query.
721
         *
722
         * Si no se han seleccionado devuelve null.
723
         *
724
         * @return String
725
         */
726 1979 jaume
        private String getParametro(){
727
                return wcsParamsTabbedPane.getParametro();
728
        }
729
730 2097 jaume
        /**
731
         * Returns the time positions in a string that may directly be concatenated
732
         * to the query string.
733
         *
734
         * Devuelve las posiciones para el tiempo en forma de querystring,
735
         * de manera que puede ser concatenado a la query.
736
         *
737
         * @return String
738
         */
739 1979 jaume
        private String getSelectedTimes(){
740
                return wcsParamsTabbedPane.getTiempos();
741
        }
742 2097 jaume
743
        /**
744
         * Creates a new layer to be passed to gvSIG. This method is automatically called
745
         * by gvSIG and it must ensure that a layer is fully and correctly created or then
746 2331 jaume
         * return null.
747 1877 luisw
         */
748
        public FLayer getLayer() {
749 1961 jaume
                FLyrWCS layer = new FLyrWCS();
750 1979 jaume
751 2048 jaume
                FMapWCSAdaptor wcsAdap = new FMapWCSAdaptor();
752
                wcsAdap.setDriver((FMapWCSDriver)((WCSDataSourceAdapter)dataSource).getDriver());
753 2003 jaume
                layer.setHost(this.getHost().toString());
754 1979 jaume
                layer.setCoverageName(this.getNomCobertura());
755 1961 jaume
                layer.setLabel(this.getEtiquetaCobertura());
756
                layer.setSRS(this.getSRS());
757
                layer.setFormat(this.getFormat());
758
                layer.setFullExtent(this.getLayersRectangle());
759 2003 jaume
                layer.setTime(this.getSelectedTimes());
760 1961 jaume
                layer.setParameter(this.getParametro());
761 1979 jaume
                layer.setToc(this.wcsParamsTabbedPane);
762
                layer.setName(layer.getLabel());
763 2021 jaume
                layer.setMaxResolution(getMaxResolution());
764 1961 jaume
                return layer;
765
        }
766 2097 jaume
767 1961 jaume
        /**
768 2097 jaume
         * Returns the max supported resolution for the coverage.
769
         *
770
         * Recupera la resoluci?n m?xima soportada por la cobertura.
771
         * @return double
772 1961 jaume
         */
773 2331 jaume
        //private double getMaxResolution() {
774
        private Point2D getMaxResolution() {
775 2021 jaume
                return wcsParamsTabbedPane.getMaxRes();
776
        }
777
778
        /**
779 2097 jaume
         * Returns the coverage label.
780
         *
781
         * @return String
782 2021 jaume
         */
783 1961 jaume
        private String getEtiquetaCobertura() {
784 1979 jaume
                return wcsParamsTabbedPane.getEtiquetaCobertura();
785 1961 jaume
        }
786
}