Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wcs / trunk / org.gvsig.raster.wcs / org.gvsig.raster.wcs.app / org.gvsig.raster.wcs.app.wcsclient / src / main / java / org / gvsig / raster / wcs / app / wcsclient / gui / wizard / WCSWizard.java @ 1355

History | View | Annotate | Download (24.7 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.wcs.app.wcsclient.gui.wizard;
24

    
25
import java.awt.Component;
26
import java.awt.FlowLayout;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.awt.geom.Rectangle2D;
30
import java.net.MalformedURLException;
31
import java.net.URL;
32
import java.util.prefs.Preferences;
33

    
34
import javax.swing.DefaultComboBoxModel;
35
import javax.swing.JButton;
36
import javax.swing.JCheckBox;
37
import javax.swing.JLabel;
38
import javax.swing.JOptionPane;
39
import javax.swing.JPanel;
40
import javax.swing.JScrollPane;
41
import javax.swing.JTextArea;
42

    
43
import org.cresques.cts.IProjection;
44
import org.gvsig.andami.PluginServices;
45
import org.gvsig.andami.persistence.serverData.ServerDataPersistence;
46
import org.gvsig.andami.ui.mdiManager.IWindow;
47
import org.gvsig.app.gui.WizardPanel;
48
import org.gvsig.app.gui.wizards.WizardListener;
49
import org.gvsig.app.gui.wizards.WizardListenerSupport;
50
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
51
import org.gvsig.compat.net.ICancellable;
52
import org.gvsig.fmap.dal.DALLocator;
53
import org.gvsig.fmap.dal.DataManager;
54
import org.gvsig.fmap.dal.DataStoreParameters;
55
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
56
import org.gvsig.fmap.dal.exception.InitializeException;
57
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
58
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
59
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
60
import org.gvsig.fmap.mapcontext.exceptions.ProjectionLayerException;
61
import org.gvsig.fmap.mapcontext.layers.FLayer;
62
import org.gvsig.raster.cache.tile.TileCacheLibrary;
63
import org.gvsig.raster.util.CancelTaskImpl;
64
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.WCSParamsPanel;
65
import org.gvsig.raster.wcs.io.WCSDataParameters;
66
import org.gvsig.raster.wcs.io.WCSServerExplorer;
67
import org.gvsig.raster.wcs.io.WCSServerExplorerParameters;
68
import org.gvsig.utils.NotExistInXMLEntity;
69
import org.gvsig.utils.XMLEntity;
70
import org.gvsig.utils.swing.jcomboServer.JComboServer;
71
import org.gvsig.utils.swing.jcomboServer.ServerData;
72
import org.slf4j.Logger;
73
import org.slf4j.LoggerFactory;
74

    
75

    
76

    
77
/**
78
 * The WCS properties container panel.
79
 *
80
 * @author Jaume Dominguez Faus
81
 */
82
public class WCSWizard extends WizardPanel implements ActionListener {
83
        final static private Logger           logger = LoggerFactory.getLogger(WCSWizard.class);
84
        private static final long             serialVersionUID   = 1L;
85
        protected int                         page               = 0;
86
        protected boolean                     connected          = false;
87
        private JComboServer                  cmbHost            = null;
88
        private JButton                       btnConnect         = null;
89
        private JButton                       btnCancel          = null;
90
        private JPanel                        jPanel             = null;
91
        private JLabel                        jLabel1            = null;
92
        private JLabel                        lblTitle           = null;
93
        private JScrollPane                   jScrollPane        = null;
94
        private JTextArea                     txtAbstract        = null;
95
        private JPanel                        panelPage1         = null;
96
        private JButton                       btnSiguiente       = null;
97
        private JButton                       btnAnterior        = null;
98
        private JPanel                        jPanel1            = null;
99
        protected WizardListenerSupport       listenerSupport    = new WizardListenerSupport();
100
        protected WCSParamsPanel              wcsParamsPanel     = null;
101
        protected JLabel                      lblServerType      = null;
102
        protected JLabel                      lblServerTypeValue = null;
103
        private JCheckBox                     chkCaching         = null;
104
        private static Preferences            fPrefs             = Preferences.userRoot().node( "gvsig.wcs-wizard" );
105
        private boolean                       usingTileCache     = fPrefs.getBoolean("tile_cache", false);
106
        private JCheckBox                     chkTileCache       = null;
107
        private boolean                       refreshing         = fPrefs.getBoolean("refresh_capabilities", false);
108
        protected int                         firstPage          = 0;
109
        private JPanel                        pnlName            = null;
110
        private IProjection                   proj               = null;
111
        private ICancellable                  cancel             = null;
112
        private WCSDataParameters             storeParams        = null;
113
        private WCSServerExplorer             explorer           = null;
114
        
115
        
116
        public WCSWizard (WCSParamsPanel params) {
117
                super();
118
                firstPage = 1;
119
                page = firstPage;
120
                this.wcsParamsPanel = params;
121
                this.explorer = wcsParamsPanel.getExplorer();
122

    
123
                setTabName("WCS");
124
                lblServerType = new JLabel();
125
                lblServerType.setBounds(20, 444, 100, 20);
126
                lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
127
                lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
128
                lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11));
129
                lblServerType.setText(PluginServices.getText(this, "server_type")+":");
130
                lblServerTypeValue = new JLabel();
131
                lblServerTypeValue.setBounds(128, 444, 148, 20);
132
                lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11));
133
                lblServerTypeValue.setText("-");
134
                this.setSize(510, 468);
135
                this.setLayout(null);
136
                this.setPreferredSize(new java.awt.Dimension(750, 420));
137
                this.setVisible(true);
138

    
139
                wcsParamsPanel.setListenerSupport(this.listenerSupport);
140
                wcsParamsPanel.setBounds(0, 5, 510, 428);
141
                wcsParamsPanel.getJTabbedPane().addMouseListener(
142
                                new java.awt.event.MouseAdapter() {
143
                                        public void mouseClicked(java.awt.event.MouseEvent e) {
144
                                                page = wcsParamsPanel.currentPage() + 1;
145
                                                activarVisualizarBotones();
146
                                        }
147
                                });
148
                this.add(wcsParamsPanel, null);
149
                this.add(lblServerType, null);
150
                this.add(lblServerTypeValue, null);
151
                getPanelPage2().setVisible(true);
152

    
153
                connected = true;
154
        }
155

    
156
        /**
157
         * This is the default constructor
158
         */
159
        public WCSWizard() {
160
                super();
161
                firstPage = 0;
162
                page = firstPage;
163
                initialize();
164
                
165
                IWindow[] windows = PluginServices.getMDIManager().getAllWindows();
166
                for (int i = 0; i < windows.length; i++) {
167
                        if(windows[i] instanceof AbstractViewPanel)
168
                                proj = ((AbstractViewPanel)windows[i]).getProjection();
169
                }
170
                cancel = new CancelTaskImpl();
171
        }
172
        /**
173
         * This method initializes this
174
         */
175
        private void initialize() {
176
                setTabName("WCS");
177

    
178
                lblServerType = new JLabel();
179
                lblServerType.setBounds(20, 444, 100, 20);
180
                lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
181
                lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
182
                lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11));
183
                lblServerType.setText(PluginServices.getText(this, "server_type")+":");
184
                lblServerTypeValue = new JLabel();
185
                lblServerTypeValue.setBounds(128, 444, 148, 20);
186
                lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11));
187
                lblServerTypeValue.setText("-");
188
                this.setSize(510, 468);
189
                this.setLayout(null);
190
                this.setPreferredSize(new java.awt.Dimension(750, 420));
191
                this.setVisible(true);
192
                this.add(getPanelPage1(), null);
193
                this.add(getPanelPage2(), null);
194
                this.add(getBtnAnterior(), null);
195
                this.add(getBtnSiguiente(), null);
196
                this.add(lblServerType, null);
197
                this.add(lblServerTypeValue, null);
198
                activarVisualizarBotones();
199
        }
200

    
201

    
202
        protected JPanel getPanelPage2(){
203
                if (wcsParamsPanel == null){
204
                        wcsParamsPanel = new WCSParamsPanel();
205
                        wcsParamsPanel.setListenerSupport(this.listenerSupport);
206
                        wcsParamsPanel.setBounds(0, 5, 510, 428);
207
                        wcsParamsPanel.getJTabbedPane().addMouseListener(
208
                                        new java.awt.event.MouseAdapter() {
209
                                                public void mouseClicked(java.awt.event.MouseEvent e) {
210
                                                        page = wcsParamsPanel.currentPage() + 1;
211
                                                        activarVisualizarBotones();
212
                                                }
213
                                        });
214
                }
215
                return wcsParamsPanel;
216
        }
217
        
218
        /**
219
         * This method checks for the options selected within the configuration
220
         * dialog are correct.
221
         *
222
         * @return true if you're done, false if not.
223
         */
224
        public boolean areSettingsValid() {
225
                return wcsParamsPanel.isCorrectlyConfigured();
226
        }
227
        
228
        /**
229
         * DOCUMENT ME!
230
         *
231
         * @param host DOCUMENT ME!
232
         */
233
        private void addHost(String host) {
234
                host = host.trim();
235

    
236
                ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WCS);
237
                persistence.addServerData(new ServerData(host, ServerData.SERVER_TYPE_WCS));
238
                persistence.setPersistent();
239
        }
240
        
241
        /**
242
         * Thread to connect to a WCS server
243
         * @author Nacho Brodin (nachobrodin@gmail.com)
244
         */
245
        public class ConnectThread extends Thread {
246
                private ICancellable             cancel      = null;
247
                private WCSServerExplorer        explorer    = null;
248
                private WCSWizard                wizard      = null;
249
                
250
                public ConnectThread(ICancellable cancel, WCSServerExplorer explorer, WCSWizard wizard) {
251
                        this.cancel = cancel;
252
                        this.explorer = explorer;
253
                        this.wizard = wizard;
254
                }
255
                
256
            public void run() {
257
                    try {
258
                            explorer.connect(cancel);
259
                        } catch (RemoteServiceException e) {
260
                                logger.info("The connection cannot be established", e);
261
                                return;
262
                        } finally {
263
                                ((CancelTaskImpl)cancel).setCanceled(false);
264
                        }
265
                        
266
                        storeParams = (WCSDataParameters)explorer.getStoreParameters();
267
                        
268
                        wizard.rellenarControles();
269
            }
270
        }
271

    
272
        /**
273
         * DOCUMENT ME!
274
         */
275
        private void rellenarControles() {
276
                try {
277
                        String host = cmbHost.getModel().getSelectedItem().toString();
278
                        
279
                        lblTitle.setText(explorer.getTitle());
280
                        lblServerTypeValue.setText(explorer.getServerType());
281
                        txtAbstract.setText(explorer.getAbstract());
282

    
283
                        addHost(host);
284
                        wcsParamsPanel.setWizardData(explorer);
285
                        connected = true;
286
                        activarVisualizarBotones();
287
                } catch (Exception e) {
288
                        if (e.getMessage()==null) {
289
                                txtAbstract.setText(PluginServices.getText(this,"error"));
290
                        } else {
291
                                txtAbstract.setText(e.getMessage());
292
                        }
293
                        listenerSupport.callError(e);
294
                        getBtnSiguiente().setEnabled(false);
295
                        getBtnAnterior().setEnabled(true);
296
                } finally {
297
                        getBtnCancel().setEnabled(false);
298
                }
299
        }
300
        
301
        public void actionPerformed(ActionEvent e) {
302
                if(e.getSource() == getBtnConnect()) {
303
                        getBtnCancel().setEnabled(true);
304
                        getTxtAbstract().setText("Trying to connect...");
305
                        String host = cmbHost.getModel().getSelectedItem().toString();
306
                        try {
307
                                DataManager datamanager = DALLocator.getDataManager();
308
                                WCSServerExplorerParameters explorerParams = (WCSServerExplorerParameters) datamanager.createServerExplorerParameters(WCSServerExplorer.NAME);
309
                                explorerParams.setHost(host);
310
                                
311
                                explorer = (WCSServerExplorer) datamanager.createServerExplorer(explorerParams);
312
                                
313
                                ((CancelTaskImpl)cancel).setCanceled(false);
314
                                new ConnectThread(cancel, explorer, this).start();
315
                                
316
                        } catch (InitializeException e1) {
317
                                getTxtAbstract().setText("Error creating WCS layer");
318
                        } catch (ProviderNotRegisteredException e1) {
319
                                getTxtAbstract().setText("Provider not registered. I cannot connect.");
320
                        } catch (ValidateDataParametersException e1) {
321
                                getTxtAbstract().setText("Parameters not valid. I cannot connect.");
322
                        }
323
                }
324
                
325
                if(e.getSource() == getBtnCancel()) {
326
                        getTxtAbstract().setText("Cancelled...");
327
                        ((CancelTaskImpl)cancel).setCanceled(true);
328
                        getBtnCancel().setEnabled(false);
329
                }
330
        }
331

    
332
        /**
333
         * DOCUMENT ME!
334
         */
335
        protected void activarVisualizarBotones() {
336
                if (page == firstPage) {
337
                        getBtnAnterior().setEnabled(false);
338
                        getBtnSiguiente().setVisible(true);
339

    
340
                        if (connected) {
341
                                getBtnSiguiente().setEnabled(true);
342
                        } else {
343
                                getBtnSiguiente().setEnabled(false);
344
                        }
345
                } else if (page < wcsParamsPanel.getNumTabs()) {
346
                        getBtnSiguiente().setEnabled(true);
347
                        getBtnSiguiente().setVisible(true);
348
                        getBtnAnterior().setEnabled(true);
349
                        getBtnAnterior().setVisible(true);
350
                        if (wcsParamsPanel.nextEnabledPage()==-1){
351
                                getBtnSiguiente().setEnabled(false);
352
                        }
353
                        listenerSupport.callStateChanged(wcsParamsPanel.isCorrectlyConfigured());
354
                } else if (page == wcsParamsPanel.getNumTabs()) {
355
                        getBtnSiguiente().setVisible(false);
356
                        getBtnSiguiente().setEnabled(false);
357
                        listenerSupport.callStateChanged(wcsParamsPanel.isCorrectlyConfigured());
358
                }
359
        }
360

    
361
        /**
362
         * This method initializes txtHost
363
         *
364
         * @return javax.swing.JTextField
365
         */
366
        private javax.swing.JComboBox getTxtHost() {
367
                if (cmbHost == null) {
368
                        cmbHost = new JComboServer();
369
                        cmbHost.setModel(new DefaultComboBoxModel());
370
                        cmbHost.setPreferredSize(new java.awt.Dimension(350, 20));
371
                        cmbHost.setBounds(11, 26, 454, 20);
372
                        cmbHost.setEditable(true);
373

    
374
                        ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WCS);
375
                        ServerData[] servers = persistence.getArrayOfServerData();
376

    
377
                        if (servers.length == 0){
378
                                PluginServices ps = PluginServices.getPluginServices(this);
379
                                XMLEntity xml = ps.getPersistentXML();
380
                                try {
381
                                        String[] oldServers = xml.getStringArrayProperty("wcs-servers");
382
                                        servers = new ServerData[oldServers.length];
383
                                        for (int i=0; i<oldServers.length; i++) {
384
                                                servers[i] = new ServerData(oldServers[i],ServerData.SERVER_TYPE_WCS);
385
                                        }
386
                                        xml.remove("wcs-servers");
387
                                        ps.setPersistentXML(xml);
388
                                } catch (NotExistInXMLEntity e) {
389
                                        // Old servers doesn't exist
390
                                        servers = new ServerData[2];
391
                                        servers[0] = new ServerData("http://maps.gdal.org/cgi-bin/mapserv_dem",ServerData.SERVER_TYPE_WCS);
392
                                        servers[1] = new ServerData("http://inspire.cop.gva.es/mapserver/wcs",ServerData.SERVER_TYPE_WCS);
393
                                }
394

    
395
                                for (int i=0 ; i<servers.length ; i++){
396
                                        persistence.addServerData(servers[i]);
397
                                }
398
                                persistence.setPersistent();
399
                        }
400

    
401
                        cmbHost.setServerList(servers);
402
                }
403

    
404
                return cmbHost;
405
        }
406

    
407
        /**
408
         * This method initializes btnDetalles
409
         *
410
         * @return javax.swing.JButton
411
         */
412
        private JButton getBtnConnect() {
413
                if (btnConnect == null) {
414
                        btnConnect = new JButton();
415
                        btnConnect.setPreferredSize(new java.awt.Dimension(100, 20));
416
                        btnConnect.setBounds(262, 50, 100, 20);
417
                        btnConnect.setText(PluginServices.getText(this, "conectar"));
418
                        btnConnect.addActionListener(this);
419
                }
420

    
421
                return btnConnect;
422
        }
423
        
424
        /**
425
         * This method initializes btnDetalles
426
         *
427
         * @return javax.swing.JButton
428
         */
429
        private JButton getBtnCancel() {
430
                if (btnCancel == null) {
431
                        btnCancel = new JButton();
432
                        btnCancel.setEnabled(false);
433
                        btnCancel.setPreferredSize(new java.awt.Dimension(100, 20));
434
                        btnCancel.setBounds(366, 50, 100, 20);
435
                        btnCancel.setText(PluginServices.getText(this, "cancel"));
436
                        btnCancel.addActionListener(this);
437
                }
438

    
439
                return btnCancel;
440
        }
441

    
442
        /**
443
         * This method initializes jPanel
444
         *
445
         * @return javax.swing.JPanel
446
         */
447
        private javax.swing.JPanel getJPanel() {
448
                if (jPanel == null) {
449
                        jPanel = new javax.swing.JPanel();
450
                        jPanel.setLayout(null);
451
                        jPanel.setPreferredSize(new java.awt.Dimension(470, 130));
452
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
453
                                        null, PluginServices.getText(this, "description"),
454
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
455
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
456
                        jPanel.setBounds(2, 116, 477, 304);
457

    
458
                        jPanel.add(getJScrollPane(), null);
459
                        jPanel.add(getPnlName(), null);
460
                }
461

    
462
                return jPanel;
463
        }
464

    
465
        /**
466
         * This method initializes jLabel1
467
         *
468
         * @return javax.swing.JLabel
469
         */
470
        private javax.swing.JLabel getJLabel1() {
471
                if (jLabel1 == null) {
472
                        jLabel1 = new javax.swing.JLabel();
473
                        jLabel1.setText(PluginServices.getText(this, "name") + ":");
474
                }
475

    
476
                return jLabel1;
477
        }
478

    
479
        /**
480
         * This method initializes lblTitle
481
         *
482
         * @return javax.swing.JLabel
483
         */
484
        private javax.swing.JLabel getLblTitle() {
485
                if (lblTitle == null) {
486
                        lblTitle = new javax.swing.JLabel();
487
                        lblTitle.setText("-");
488
                }
489

    
490
                return lblTitle;
491
        }
492

    
493
        /**
494
         * This method initializes jScrollPane
495
         *
496
         * @return javax.swing.JScrollPane
497
         */
498
        private javax.swing.JScrollPane getJScrollPane() {
499
                if (jScrollPane == null) {
500
                        jScrollPane = new javax.swing.JScrollPane();
501
                        jScrollPane.setViewportView(getTxtAbstract());
502
                        jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60));
503
                        jScrollPane.setBounds(10, 47, 457, 247);
504
                }
505

    
506
                return jScrollPane;
507
        }
508

    
509
        /**
510
         * This method initializes txtAbstract
511
         *
512
         * @return javax.swing.JTextArea
513
         */
514
        private javax.swing.JTextArea getTxtAbstract() {
515
                if (txtAbstract == null) {
516
                        txtAbstract = new javax.swing.JTextArea();
517
                        txtAbstract.setWrapStyleWord(true);
518
                        txtAbstract.setColumns(30);
519
                        txtAbstract.setLineWrap(true);
520
                }
521

    
522
                return txtAbstract;
523
        }
524
        
525
        private javax.swing.JPanel getPanelPage1() {
526
                if (panelPage1 == null) {
527
                        panelPage1 = new JPanel();
528
                        panelPage1.setLayout(null);
529
                        panelPage1.setPreferredSize(new java.awt.Dimension(480, 220));
530
                        panelPage1.setVisible(true);
531
                        panelPage1.setBounds(15, 5, 480, 427);
532
                        panelPage1.add(getJPanel1(), null);
533
                        panelPage1.add(getJPanel(), null);
534
                }
535

    
536
                return panelPage1;
537
        }
538

    
539

    
540
        /**
541
         * This method initializes btnSiguiente
542
         *
543
         * @return javax.swing.JButton
544
         */
545
        private javax.swing.JButton getBtnSiguiente() {
546
                if (btnSiguiente == null) {
547
                        btnSiguiente = new JButton();
548
                        btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30));
549
                        btnSiguiente.setBounds(395, 444, 100, 20);
550
                        btnSiguiente.setText(PluginServices.getText(this, "siguiente"));
551
                        btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
552
                                public void actionPerformed(java.awt.event.ActionEvent e) {
553
                                        if(page == firstPage && getChkTileCache().isSelected()) {
554
                                                messageBoxInfo("remote_service_tiled", TileCacheLibrary.ALTERNATIVE_TILESIZE + "", this);
555
                                        }
556
                                        if (page > firstPage) {
557
                                                // si page es mayor que cero, vamos enfocando las
558
                                                // sucesivas SOLAPAS del WCSParamsPanel
559
                                                wcsParamsPanel.avanzaTab();
560
                                                page = wcsParamsPanel.currentPage();
561
                                        }
562
                                        page++;
563
                                        getPanelPage1().setVisible(false);
564
                                        getPanelPage2().setVisible(true);
565
                                        activarVisualizarBotones();
566
                                }
567
                        });
568
                }
569
                return btnSiguiente;
570
        }
571
        
572
        /**
573
         * Shows an information dialog with a text and a accept button 
574
         * @param msg Message to show in the dialog
575
         * @param parentWindow Parent window
576
         */
577
        public static void messageBoxInfo(String msg, String fixedText, Object parentWindow){
578
                String string = PluginServices.getText(parentWindow, "accept");
579
                Object[] options = {string};
580
                JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(),
581
                                        "<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + " " + fixedText + "</html>",
582
                                        PluginServices.getText(parentWindow, "confirmacion"),
583
                                        JOptionPane.OK_OPTION,
584
                                        JOptionPane.INFORMATION_MESSAGE,
585
                                        null,
586
                                        options,
587
                                        string);
588
        }
589

    
590
        /**
591
         * This method initializes btnAnterior
592
         *
593
         * @return javax.swing.JButton
594
         */
595
        private javax.swing.JButton getBtnAnterior() {
596
                if (btnAnterior == null) {
597
                        btnAnterior = new JButton();
598
                        btnAnterior.setBounds(292, 444, 100, 20);
599
                        btnAnterior.setPreferredSize(new java.awt.Dimension(100, 30));
600
                        btnAnterior.setText(PluginServices.getText(this, "anterior"));
601
                        btnAnterior.addActionListener(new java.awt.event.ActionListener() {
602
                                public void actionPerformed(java.awt.event.ActionEvent e) {
603
                                        page --;
604
                                        if (page > firstPage) {
605
                                                // Tenemos que retroceder en el wcsParamsPanel
606
                                                wcsParamsPanel.retrocedeTab();
607
                                                page = wcsParamsPanel.currentPage() + 1;
608
                                                activarVisualizarBotones();
609
                                        } else if (page==firstPage){
610
                                                activarVisualizarBotones();
611
                                                page = firstPage +1;
612
                                                getLblTitle().setText("-");
613
                                                getTxtAbstract().setText("");
614
                                                wcsParamsPanel.retrocedeTab();
615
                                                getPanelPage1().setVisible(true);
616
                                                getPanelPage2().setVisible(false);
617
                                                getBtnSiguiente().setEnabled(false);
618
                                                connected = false;
619
                                        }
620
                                        listenerSupport.callStateChanged(wcsParamsPanel.isCorrectlyConfigured());
621
                                }
622
                        });
623
                }
624

    
625
                return btnAnterior;
626
        }
627
        
628
        private javax.swing.JPanel getJPanel1() {
629
                if (jPanel1 == null) {
630
                        jPanel1 = new javax.swing.JPanel();
631
                        jPanel1.setLayout(null);
632
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
633
                                        null, PluginServices.getText(this, "server"),
634
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
635
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
636
                        jPanel1.setBounds(2, 5, 477, 105);
637
                        jPanel1.add(getTxtHost(), null);
638
                        jPanel1.add(getBtnConnect(), null);
639
                        jPanel1.add(getBtnCancel(), null);
640
                        jPanel1.add(getChkCaching(), null);
641
                        jPanel1.add(getChkTileCache(), null);
642
                }
643

    
644
                return jPanel1;
645
        }
646

    
647
        /**
648
         * DOCUMENT ME!
649
         *
650
         * @param listener
651
         */
652
        public void addWizardListener(WizardListener listener) {
653
                listenerSupport.addWizardListener(listener);
654
        }
655

    
656
        /**
657
         * DOCUMENT ME!
658
         *
659
         * @param listener
660
         */
661
        public void removeWizardListener(WizardListener listener) {
662
                listenerSupport.removeWizardListener(listener);
663
        }
664

    
665
        /**
666
         * DOCUMENT ME!
667
         *
668
         * @return DOCUMENT ME!
669
         * @throws ProjectionLayerException
670
         */
671
        public Rectangle2D getLayersRectangle() throws ProjectionLayerException {
672
                //return wcsParamsPanel.getLayersRectangle();
673
                return null;
674
        }
675

    
676

    
677

    
678
        /**
679
         * Devuelve el host que est� escrito en el cuadro de texto del host o null
680
         * en caso de que no haya nada escrito o est� mal escrito
681
         *
682
         * @return URL del host
683
         */
684
        public URL getHost() {
685
                try {
686
                        if ((cmbHost == null)|| (cmbHost.getModel().getSelectedItem() == null)) {
687
                                return new URL(explorer.getHost());
688
                        } else {
689
                                return new URL(cmbHost.getModel().getSelectedItem().toString());
690
                        }
691
                } catch (MalformedURLException e) {
692
                        return null;
693
                }
694
        }
695

    
696
        /**
697
         * DOCUMENT ME!
698
         *
699
         * @return Nombre de la capa que aparece en el TOC.
700
         */
701
        public String getLayerName() {
702
                return wcsParamsPanel.getLayerName();
703
        }
704

    
705

    
706
        public void initWizard() {
707
        }
708

    
709
        public void execute() {
710
                try {
711
                        FLayer layer = wcsParamsPanel.getLayer(getChkTileCache().isSelected());
712
                        if(layer == null)
713
                                return;
714
                        this.getMapCtrl().getMapContext().getLayers().addLayer(layer);
715
                } catch (LoadLayerException e) {
716
                        logger.info("The layer cannot be added", e);
717
                }
718

    
719
        }
720
        
721
        /**
722
         * This method initializes chkCaching
723
         *
724
         * @return javax.swing.JCheckBox
725
         */
726
        private JCheckBox getChkCaching() {
727
                if (chkCaching == null) {
728
                        chkCaching = new JCheckBox();
729
                        chkCaching.setBounds(7, 51, 249, 20);
730
                        chkCaching.setText(PluginServices.getText(this, "refresh_capabilities"));
731
                        chkCaching.setToolTipText(PluginServices.getText(this, "refresh_capabilities_tooltip"));
732
                        chkCaching.setSelected(refreshing);
733
                        chkCaching.addItemListener(new java.awt.event.ItemListener() {
734
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
735
                                        refreshing = chkCaching.isSelected();
736
                                }
737
                        });
738
                        chkCaching.addActionListener(new java.awt.event.ActionListener() {
739
                                public void actionPerformed(java.awt.event.ActionEvent e) {
740
                                        fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
741
                                }
742
                        });
743

    
744
                }
745
                return chkCaching;
746
        }
747
        
748
        /**
749
         * This method initializes chkCaching
750
         *
751
         * @return javax.swing.JCheckBox
752
         */
753
        private JCheckBox getChkTileCache() {
754
                if (chkTileCache == null) {
755
                        chkTileCache = new JCheckBox();
756
                        chkTileCache.setBounds(7, 72, 249, 20);
757
                        chkTileCache.setText(PluginServices.getText(this, "tile_cache"));
758
                        chkTileCache.setToolTipText(PluginServices.getText(this, "tile_cache_tooltip"));
759
                        chkTileCache.setSelected(usingTileCache);
760
                        chkTileCache.addItemListener(new java.awt.event.ItemListener() {
761
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
762
                                        usingTileCache = chkTileCache.isSelected();
763
                                }
764
                        });
765
                        chkTileCache.addActionListener(new java.awt.event.ActionListener() {
766
                                public void actionPerformed(java.awt.event.ActionEvent e) {
767
                                        fPrefs.putBoolean("tile_cache", chkTileCache.isSelected());
768
                                }
769
                        });
770

    
771
                }
772
                return chkTileCache;
773
        }
774

    
775
        /**
776
         * This method initializes pnlName
777
         *
778
         * @return javax.swing.JPanel
779
         */
780
        private JPanel getPnlName() {
781
                if (pnlName == null) {
782
                        pnlName = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0));
783
                        pnlName.setBounds(new java.awt.Rectangle(9,19,452,24));
784
                        pnlName.add(getJLabel1(), null);
785
                        pnlName.add(getLblTitle(), null);
786
                }
787
                return pnlName;
788
        }
789

    
790
        @Override
791
        public DataStoreParameters[] getParameters() {
792
                // TODO Auto-generated method stub
793
                return null;
794
        }
795

    
796
        @Override
797
        public void close() {
798
                // Nothing to do
799
        }
800
}  //  @jve:decl-index=0:visual-constraint="10,10"