Statistics
| Revision:

svn-gvsig-desktop / branches / gvSIG_WMSv2 / extensions / extWMS / src / com / iver / cit / gvsig / gui / panels / WMSParamsPanel.java @ 3537

History | View | Annotate | Download (43.3 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 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.panels;
42

    
43
import java.awt.geom.Rectangle2D;
44
import java.util.ArrayList;
45
import java.util.ConcurrentModificationException;
46
import java.util.HashSet;
47
import java.util.Iterator;
48
import java.util.TreeSet;
49
import java.util.Vector;
50

    
51
import javax.swing.DefaultListModel;
52
import javax.swing.ImageIcon;
53
import javax.swing.JButton;
54
import javax.swing.JCheckBox;
55
import javax.swing.JComboBox;
56
import javax.swing.JList;
57
import javax.swing.JPanel;
58
import javax.swing.JScrollPane;
59
import javax.swing.JTabbedPane;
60
import javax.swing.JTable;
61
import javax.swing.JTextField;
62
import javax.swing.table.DefaultTableModel;
63
import javax.swing.tree.TreePath;
64

    
65
import com.iver.andami.PluginServices;
66
import com.iver.cit.gvsig.fmap.layers.IFMapWMSDimension;
67
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode;
68
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode.FMapWMSStyle;
69
import com.iver.cit.gvsig.gui.beans.dnd.JDnDList;
70
import com.iver.cit.gvsig.gui.beans.dnd.JDnDListModel;
71
import com.iver.cit.gvsig.gui.wizards.FormatListModel;
72
import com.iver.cit.gvsig.gui.wizards.LayerTreeModel;
73
import com.iver.cit.gvsig.gui.wizards.SRSListModel;
74
import com.iver.cit.gvsig.gui.wizards.StylesTableModel;
75
import com.iver.cit.gvsig.gui.wizards.WMSWizardData;
76
import com.iver.cit.gvsig.gui.wizards.WizardData;
77
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport;
78
/**
79
 * This class implements the map option panel.
80
 * 
81
 * It includes a set of Listeners that implement some control rules which
82
 * refresh the component values that depends on those selected in the other
83
 * components to avoid to choose an invalid set of options. It also includes a
84
 * method (isCorrectlyConfigured()) that checks if the current set of values is enough to
85
 * correctly launch a GetMap request.
86
 * 
87
 * The information is obtained from a WMSWizardDataSource object.
88
 * 
89
 * 
90
 * Esta clase implementa el panel de opciones disponibles sobre la cobertura.
91
 * 
92
 * Incluye una serie de Listeners que implementan unas reglas de control que
93
 * refrescan los valores de componentes cuyos valores dependen de aqu?llos 
94
 * seleccionados en otros componentes para evitar que se escoja una combinaci?n
95
 * de opciones err?nea as? como una funci?n (isCorrectlyConfigured()) que
96
 * comprueba si la combinaci?n escogida actualmente es suficiente para lanzar
97
 * una operaci?n GetMap correctamente.
98
 * 
99
 * La informaci?n obtiene a partir de un objeto WMSWizardDataSource.
100
 * 
101
 * @author jaume - jaume dominguez faus
102
 *
103
 */
104
public class WMSParamsPanel extends JPanel {
105
        private javax.swing.JScrollPane jScrollPane1 = null;
106
        private javax.swing.JScrollPane jScrollPane2 = null;
107
        private javax.swing.JScrollPane jScrollPane5 = null;
108
        private javax.swing.JButton btnAdd = null;
109
        private javax.swing.JButton btnDel = null;
110
        private javax.swing.JScrollPane jScrollPane6 = null;
111
        private javax.swing.JPanel jPanel2 = null;
112
        private javax.swing.JPanel tabFormats = null;
113
        private JPanel jPanel4 = null;
114
        private JTextField jTxtNomCapa = null;
115
        private JDnDList lstSelectedLayers = null;
116
        private javax.swing.JList lstSRSs = null;
117
        private javax.swing.JTree treeLayers = null;
118
        private javax.swing.JList lstFormats = null;
119
        private JDnDListModel selectedLayersModel = new JDnDListModel();
120
        private WizardListenerSupport listenerSupport;
121
        private WMSWizardData dataSource;
122
        private JTabbedPane jTabbedPane = null;
123
        private JPanel tabLayers = null;
124
        private JPanel jPanel1 = null;
125
        private JPanel jPanel5 = null;
126
        private StylesPanel tabStyle = null;
127
        private JPanel jPanel8 = null;
128
        private StylesSelectionPanel styleSelectPanel;
129
        private JPanel tabStyleSelect;
130
        private JCheckBox chkTransparency = null;
131
    private JPanel tabStyles = null;
132
    private JScrollPane jScrollPane = null;
133
    private JTable tblStyles = null;
134
    private InfoPanel tabInfo = null;
135
    private DimensionPanel tabDimensions = null;
136
    
137
    
138
    public WMSParamsPanel(){
139
                super();
140
                initialize();
141
        }
142
        
143
        /**
144
         * This method initializes panelPage2
145
         *
146
         * @return javax.swing.JPanel
147
         */
148
        private void initialize() {
149
                this.setLayout(null);
150
                this.setVisible(false);
151
                this.setBounds(10, 5, 481, 427);
152
                this.add(getJTabbedPane(), null);
153
        }
154
        /**
155
         * This method initializes jPanel2
156
         *
157
         * @return javax.swing.JPanel
158
         */
159
        private javax.swing.JPanel getJPanel2() {
160
                if (jPanel2 == null) {
161
                        jPanel2 = new javax.swing.JPanel();
162
                        jPanel2.setLayout(null);
163
                        jPanel2.setBounds(4, 59, 454, 328);
164
                        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(
165
                                        null, PluginServices.getText(this, "seleccionar_capas"),
166
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
167
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
168
                        jPanel2.add(getJScrollPane1(), null);
169
                        jPanel2.add(getBtnDel(), null);
170
                        jPanel2.add(getBtnAdd(), null);
171
                        jPanel2.add(getJScrollPane5(), null);
172
                }
173

    
174
                return jPanel2;
175
        }
176
        
177
        /**
178
         * This method initializes jPanel4
179
         *
180
         * @return javax.swing.JPanel
181
         */
182
        private JPanel getJPanel4() {
183
                if (jPanel4 == null) {
184
                        jPanel4 = new JPanel();
185
                        jPanel4.setLayout(null);
186
                        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(
187
                                        null, PluginServices.getText(this, "nombre_capa"),
188
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
189
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
190
                        jPanel4.setBounds(4, 8, 457, 49);
191
                        jPanel4.add(getJTxtNomCapa(), null);
192
                }
193

    
194
                return jPanel4;
195
        }
196
        
197
        /**
198
         * This method initializes jPanel3
199
         *
200
         * @return javax.swing.JPanel
201
         */
202
        private javax.swing.JPanel getTabFormats() {
203
                if (tabFormats == null) {
204
                        tabFormats = new javax.swing.JPanel();
205
                        tabFormats.setLayout(null);
206
                        //tabFormats.
207
                        tabFormats.add(getJPanel1(), null);
208
                        tabFormats.add(getJPanel5(), null);
209
                }
210

    
211
                return tabFormats;
212
        }
213
        /**
214
         * This method initializes jScrollPane1
215
         *
216
         * @return javax.swing.JScrollPane
217
         */
218
        private javax.swing.JScrollPane getJScrollPane1() {
219
                if (jScrollPane1 == null) {
220
                        jScrollPane1 = new javax.swing.JScrollPane();
221
                        jScrollPane1.setBounds(11, 22, 430, 124);
222
                        jScrollPane1.setViewportView(getTreeLayers());
223
                        jScrollPane1.setPreferredSize(new java.awt.Dimension(205, 75));
224
                }
225

    
226
                return jScrollPane1;
227
        }
228
        
229
        /**
230
         * This method initializes btnDel
231
         *
232
         * @return javax.swing.JButton
233
         */
234
        public javax.swing.JButton getBtnDel() {
235
                if (btnDel == null) {
236
                        btnDel = new javax.swing.JButton();
237
                        btnDel.setPreferredSize(new java.awt.Dimension(23, 23));
238
                        btnDel.setText(PluginServices.getText(this, "quitar"));
239
                        btnDel.setMargin(new java.awt.Insets(2, 0, 2, 0));
240
                        btnDel.setBounds(246, 158, 101, 23);
241
                        btnDel.setEnabled(false);
242
                        btnDel.addActionListener(new java.awt.event.ActionListener() {
243
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
244
                                                delLayer();
245
                                        }
246
                                });
247
                }
248
                return btnDel;
249
        }
250
        
251
        /**
252
         * This method initializes btnAdd
253
         *
254
         * @return javax.swing.JButton
255
         */
256
        public javax.swing.JButton getBtnAdd() {
257
                if (btnAdd == null) {
258
                        btnAdd = new javax.swing.JButton();
259
                        btnAdd.setPreferredSize(new java.awt.Dimension(23, 23));
260
                        btnAdd.setText(PluginServices.getText(this, "anadir"));
261
                        btnAdd.setMargin(new java.awt.Insets(2, 0, 2, 0));
262
                        btnAdd.setBounds(133, 158, 101, 23);
263
                        btnAdd.setEnabled(false);
264
                        btnAdd.addActionListener(new java.awt.event.ActionListener() {
265
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
266
                                                addLayer();
267
                                        }
268
                                });
269
                }
270

    
271
                return btnAdd;
272
        }
273
        
274
        /**
275
         * This method initializes jScrollPane5
276
         *
277
         * @return javax.swing.JScrollPane
278
         */
279
        private javax.swing.JScrollPane getJScrollPane5() {
280
                if (jScrollPane5 == null) {
281
                        jScrollPane5 = new javax.swing.JScrollPane();
282
                        jScrollPane5.setBounds(11, 190, 431, 130);
283
                        jScrollPane5.setViewportView(getLstSelectedLayers());
284
                        jScrollPane5.setPreferredSize(new java.awt.Dimension(205, 75));
285
                }
286

    
287
                return jScrollPane5;
288
        }
289
        
290
        /**
291
         * This method initializes jTextField
292
         *
293
         * @return javax.swing.JTextField
294
         */
295
        public JTextField getJTxtNomCapa() {
296
                if (jTxtNomCapa == null) {
297
                        jTxtNomCapa = new JTextField();
298
                        jTxtNomCapa.setBounds(10, 19, 437, 20);
299
                        jTxtNomCapa.setText(PluginServices.getText(this, "capaWMS"));
300
                }
301

    
302
                return jTxtNomCapa;
303
        }
304

    
305

    
306
        /**
307
         * This method initializes jScrollPane6
308
         *
309
         * @return javax.swing.JScrollPane
310
         */
311
        private javax.swing.JScrollPane getJScrollPane6() {
312
                if (jScrollPane6 == null) {
313
                        jScrollPane6 = new javax.swing.JScrollPane();
314
                        jScrollPane6.setBounds(5, 23, 442, 140);
315
                        jScrollPane6.setViewportView(getLstFormats());
316
                        jScrollPane6.setPreferredSize(new java.awt.Dimension(250, 200));
317
                }
318

    
319
                return jScrollPane6;
320
        }
321
        
322
        /**
323
         * This method initializes jScrollPane2
324
         *
325
         * @return javax.swing.JScrollPane
326
         */
327
        private javax.swing.JScrollPane getJScrollPane2() {
328
                if (jScrollPane2 == null) {
329
                        jScrollPane2 = new javax.swing.JScrollPane();
330
                        jScrollPane2.setBounds(5, 23, 442, 141);
331
                        jScrollPane2.setViewportView(getLstSRSs());
332
                        jScrollPane2.setPreferredSize(new java.awt.Dimension(100, 200));
333
                }
334

    
335
                return jScrollPane2;
336
        }
337
        
338
        /**
339
         * This method initializes treeLayers
340
         *
341
         * @return javax.swing.JTree
342
         */
343
        public javax.swing.JTree getTreeLayers() {
344
                if (treeLayers == null) {
345
                        treeLayers = new javax.swing.JTree();
346
                        treeLayers.setRootVisible(true);
347
                        treeLayers.addMouseListener(new java.awt.event.MouseAdapter() { 
348
                                public void mouseClicked(java.awt.event.MouseEvent e) {    
349
                                        if (e.getClickCount() == 2){
350
                        addLayer();
351
                    }
352
                                }
353
                        });
354
                        treeLayers.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
355
                                        public void valueChanged(
356
                                                javax.swing.event.TreeSelectionEvent e) {
357
                                                
358
                        boolean isGetMapable = false; // pffff, jajaja
359
                        TreePath[] selecciones = getTreeLayers().getSelectionPaths();
360
                        if (selecciones!=null) // no entenc perqu? peta ac?...
361
                        {
362
                                for (int i = 0; i < selecciones.length && !isGetMapable; i++) {
363
                                        isGetMapable = ((WMSLayerNode) selecciones[i].getLastPathComponent()).getChildren().size()==0;
364
                                }
365
                                
366
                        }
367
                        getBtnAdd().setEnabled(isGetMapable);
368
                            listenerSupport.callStateChanged(isCorretlyConfigured());
369
                                        }
370
                                });
371
//            treeLayers.setCellRenderer(new TreeCellRenderer() {
372
//
373
//                public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
374
//                    final JLabel label = new JLabel();
375
//                    if (value instanceof WMSLayerNode){
376
//                        label.setText(((WMSLayerNode)value).getTitle());
377
//                        label.setToolTipText(((WMSLayerNode)value).getAbstract());
378
//                    }
379
//                    
380
//                    return label;
381
//                }
382
//                
383
//            });
384
                }
385

    
386
                return treeLayers;
387
        }
388
        
389

    
390
    /**
391
         * This method checks for the options selected within the configuration dialog are 
392
         * correct and enough to perform a GetMap request.
393
         * @return true if you're done, false if not.
394
         */
395
        public boolean isCorretlyConfigured() {
396
        
397
                boolean b;
398
        this.repaint();
399
                if ((getLstSRSs().getSelectedIndex() != -1) &&
400
                                (getLstFormats().getSelectedIndex() != -1) &&
401
                                (getLstSelectedLayers().getModel().getSize() > 0)) {
402
                        b = true;
403
                } else {
404
                        b = false;
405
                }
406
        
407
        // Enable or disable the delete layer button.
408
        getBtnDel().setEnabled(getLstSelectedLayers().getSelectedIndices()!=null && getLstSelectedLayers().getSelectedIndices().length>0);
409
        return b;
410
        }
411

    
412
        /**
413
         * DOCUMENT ME!
414
         */
415
        private void delLayer() {
416
                int[] indices = lstSelectedLayers.getSelectedIndices();
417

    
418
                ArrayList removeList = new ArrayList();
419
        JDnDListModel modelo = ((JDnDListModel) lstSelectedLayers.getModel()); 
420
        ArrayList elements = modelo.getElements();
421
        WMSLayerNode[] infos = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]);
422
        
423
                for (int i = 0; i < indices.length; i++) {
424
                        removeList.add(infos[indices[i]]);
425
                }
426

    
427
                modelo.delIndices(indices);
428
                lstSelectedLayers.clearSelection();
429
                listenerSupport.callStateChanged(true);
430
                //activarVisualizarBotones();
431

    
432
                refresh();
433
        
434
        }
435
        
436
        /**
437
     * Refreshes the content shown by this.
438
     */
439
    public void refresh() {
440
        refreshSRS();
441
        getLstSelectedLayers().repaint();
442
        //styleSelectPanel.refresh();
443
        //refreshStyleTable();
444
        refreshStyleTree();
445
        refreshDimensionTree();
446
    }
447

    
448
    private void refreshDimensionTree() {
449
            int size = getLstSelectedLayers().getModel().getSize();
450
            
451
            WMSLayerNode dimensionRoot = new WMSLayerNode();
452
            dimensionRoot.setTitle(PluginServices.getText(this, "selected_themes"));
453
            
454
            DimensionTreeModel model = new DimensionTreeModel(dimensionRoot);
455
            
456
            for (int i=0; i<size; i++) {
457
                    WMSLayerNode node = (WMSLayerNode) getLstSelectedLayers().getModel().getElementAt(i);
458
                    WMSLayerNode myNode = new WMSLayerNode();
459
            myNode.setName(node.getName());
460
            myNode.setTitle(node.getTitle());
461
            if (node.getDimensions()==null)
462
                        continue;
463

    
464
            for (int j = 0; j < node.getDimensions().size(); j++) {
465
                    IFMapWMSDimension dim = (IFMapWMSDimension) node.getDimensions().get(j);
466
                myNode.addDimension(dim.getName(), dim.getUnit(), dim.getUnitSymbol(), dim.getExpression());
467
            }
468
            model.addLayerBranch(myNode);
469
                    model.addLayerBranch(node);
470
            }
471
            getDimensionTree().setModel(model);
472
        getDimensionTree().repaint();
473
    }
474
    /**
475
     * 
476
     */
477
    private void refreshStyleTree() {
478
        int size = getLstSelectedLayers().getModel().getSize();
479
        
480
        WMSLayerNode styleRoot = new WMSLayerNode();
481
        styleRoot.setTitle(PluginServices.getText(this, "selected_themes"));
482
        
483
        StylesTreeModel model = new StylesTreeModel(styleRoot);
484
        
485
        for (int i=0; i<size; i++){
486
            WMSLayerNode node = (WMSLayerNode)getLstSelectedLayers().getModel().getElementAt(i);
487
            WMSLayerNode myNode = new WMSLayerNode();
488
            myNode.setName(node.getName());
489
            myNode.setTitle(node.getTitle());
490

    
491
            for (int j = 0; j < node.getStyles().size(); j++) {
492
                FMapWMSStyle sty = (FMapWMSStyle) node.getStyles().get(j);
493
                myNode.addStyle(sty.name, sty.title, sty.styleAbstract);
494
            }
495
            model.addLayerBranch(myNode);
496
        }
497
        getStyleTree().setModel(model);
498
        
499
        getStyleTree().repaint();
500
    }
501
    
502
    /**
503
     * Gets the currently shown style tree.
504
     * @return
505
     */
506
    public StyleTree getStyleTree() {
507
        return getTabStyle().getStyleTree();
508
    }
509
    
510
    /**
511
     * Gets the currently shown style tree.
512
     * @return
513
     */
514
    public DimensionTree getDimensionTree() {
515
        return getTabDimensions().getDimensionTree();
516
    }
517

    
518
    /**
519
         * DOCUMENT ME!
520
         */
521
        private void addLayer() {
522
                boolean alguno = false;
523

    
524
                TreePath[] selecciones = getTreeLayers().getSelectionPaths();
525

    
526
                for (int i = 0; i < selecciones.length; i++) {
527
                        WMSLayerNode nodo = (WMSLayerNode) selecciones[i].getLastPathComponent();
528
                        if (nodo.getName()==null)
529
                continue;
530
                        //Se a?ade a la lista de layers seleccionados
531
                        JDnDListModel modelo = (JDnDListModel) lstSelectedLayers.getModel();
532

    
533
                        if (modelo.addElement(nodo.clone())) {
534
                                alguno = true;
535
                        }
536
            
537
                }
538

    
539
                if (alguno) {
540
                        refresh();
541
                }
542
        
543
        }
544
        
545
        /**
546
         * This method initializes lstSelectedLayers
547
         *
548
         * @return javax.swing.JList
549
         */
550
        public javax.swing.JList getLstSelectedLayers() {
551
                if (lstSelectedLayers == null) {
552
            lstSelectedLayers = new JDnDList();
553
                        lstSelectedLayers.setModel(selectedLayersModel);
554
                        lstSelectedLayers.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
555
                        lstSelectedLayers.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
556
                            public void valueChanged(javax.swing.event.ListSelectionEvent e) {
557
                                listenerSupport.callStateChanged(isCorretlyConfigured());
558
                            }
559
                        });
560
                }
561

    
562
                return lstSelectedLayers;
563
        }
564
        
565
    
566

    
567
    private void refreshStyleTable(){
568
        int size = getLstSelectedLayers().getModel().getSize();
569
        getTabStyle().setEnabled(size != 0); // TODO y que alguna de ellas tenga estilo
570
        
571
        StylesTableModel model = (StylesTableModel) getTblStyles().getModel();
572
        model.removeAll();
573
        for (int i=0; i<size; i++){
574
            WMSLayerNode node = (WMSLayerNode)getLstSelectedLayers().getModel().getElementAt(i);
575
            model.addRow(node);
576
        }
577
    }
578
    
579
        /**
580
         * This method initializes lstSRSs
581
         *
582
         * @return javax.swing.JList
583
         */
584
        public javax.swing.JList getLstSRSs() {
585
                if (lstSRSs == null) {
586
                        lstSRSs = new javax.swing.JList();
587
                        lstSRSs.setModel(new SRSListModel());
588
                        lstSRSs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
589
                        lstSRSs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
590
                                public void valueChanged(
591
                                                javax.swing.event.ListSelectionEvent e) {
592
                                        //activarVisualizarBotones();
593
                                        listenerSupport.callStateChanged(isCorretlyConfigured());
594
                                }
595
                        });
596
                }
597

    
598
                return lstSRSs;
599
        }
600

    
601
        /**
602
         * This method initializes lstFormats1
603
         *
604
         * @return javax.swing.JList
605
         */
606
        public javax.swing.JList getLstFormats() {
607
                if (lstFormats == null) {
608
                        lstFormats = new javax.swing.JList();
609
                        lstFormats.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
610
                        lstFormats.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
611
                                public void valueChanged(
612
                                                javax.swing.event.ListSelectionEvent e) {
613
                                        listenerSupport.callStateChanged(isCorretlyConfigured());
614
                                }
615
                        });
616
                }
617

    
618
                return lstFormats;
619
        }
620

    
621
        /**
622
         * DOCUMENT ME!
623
         */
624
        private void refreshSRS() {
625
        String oldSrs = (String) getLstSRSs().getSelectedValue();
626
        ArrayList elements = ((JDnDListModel) lstSelectedLayers.getModel()).getElements();
627
        WMSLayerNode[] layers = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]);
628
                
629

    
630
                if (layers.length == 0) {
631
                        lstSRSs.setModel(new DefaultListModel());
632
                } else {
633
                        TreeSet srsSet = new TreeSet();
634
                        srsSet.addAll(layers[0].getAllSrs());
635
            
636
            // I'm adding the layer specific SRS
637
            for (int i = 1; i < layers.length; i++) {
638
                                HashSet nuevo = new HashSet(layers[i].getAllSrs());
639
                try{
640
                    Iterator it = srsSet.iterator();
641
                                    while (it.hasNext()) {
642
                                        String srs = (String) it.next();
643
                                        
644
                                        if (!nuevo.contains(srs)) {
645
                                            srsSet.remove(srs);
646
                                        }
647
                                    }
648
                                } catch (ConcurrentModificationException e){
649
                    // just ignore it and wait the user for do something.
650
                    // this is tipically caused by a fast dialog manipulation.
651
                                }
652
                        }
653
            // And now, I'm adding the service SRS
654
            srsSet.addAll(((WMSLayerNode)getTreeLayers().getModel().getRoot()).getAllSrs());
655
            
656
                        DefaultListModel model = new DefaultListModel();
657
                        String[] array = (String[]) srsSet.toArray(new String[0]);
658

    
659
                        for (int i = 0; i < array.length; i++) {
660
                                model.addElement(array[i]);
661
                        }
662

    
663
                        lstSRSs.setModel(model);
664
                }
665
        int srsIndex = getSRSIndex( oldSrs );
666
        if (srsIndex!=-1)
667
            getLstSRSs().setSelectedIndex(srsIndex);
668
        
669
        }
670

    
671
        public void setListenerSupport(WizardListenerSupport support) {
672
                listenerSupport = support;
673
        }
674

    
675
        public void setWizardData(WizardData data) {
676
                this.dataSource = (WMSWizardData) data;
677
                ((JDnDListModel) getLstSelectedLayers().getModel()).clear();
678
                getLstSelectedLayers().repaint();
679
        
680
                getLstFormats().setModel(new FormatListModel(this.dataSource.getFormats()));
681
                getTreeLayers().setModel(new LayerTreeModel(this.dataSource.getLayer()));
682
                /*getLstLayerStyles().setModel(getLstSelectedLayers().getModel());
683
                getLstLayerStyles().repaint();*/
684
        getTabInfo().refresh(dataSource);
685
        }
686

    
687
        
688
        public String getFormat() {
689
                return (String) getLstFormats().getSelectedValue();
690
        }
691

    
692
        public String getLayersQuery() {
693
        ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
694
        WMSLayerNode[] layers = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]);
695
        
696
                //Nombre separado por comas de las capas
697
                String layersQuery = layers[0].getName();
698

    
699
                for (int i = 1; i < layers.length; i++) {
700
                        layersQuery += ("," + layers[i].getName());
701
                }
702

    
703
                return layersQuery;
704
                
705
        }
706

    
707
        public String getSRS() {
708
                return (String) getLstSRSs().getSelectedValue();
709
        }
710

    
711
        public String getLayerName() {
712
                return getJTxtNomCapa().getText();        
713
        }
714
        
715
    public Rectangle2D getLayersRectangle(){
716
        ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
717
        WMSLayerNode[] layers = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]);
718
        String[] layerNames = new String[layers.length];
719
        for (int i = 0; i < layerNames.length; i++) {
720
            layerNames[i] = layers[i].getName();
721
        }
722
        //Boundingbox de todas las capas
723
        ArrayList rectangulos = new ArrayList();
724
        
725
        Rectangle2D rect;
726
        
727
        for (int i = 0; i < layers.length; i++) {
728
            rect = dataSource.getBoundingBox(layerNames, getSRS());
729
            
730
            if (rect != null) {
731
                rectangulos.add(rect);
732
            }
733
        }
734
        
735
        rect = getRectangle((Rectangle2D.Double[]) rectangulos.toArray(
736
                new Rectangle2D.Double[0]));
737
        
738
        return rect;
739
    }
740
    
741
    public Rectangle2D _getLayersRectangle(){        
742
                TreePath[] layers = getSelectedLayers();
743
                
744
                //Boundingbox de todas las capas
745
                ArrayList rectangulos = new ArrayList();
746
                
747
                Rectangle2D rect;
748
                
749
                for (int i = 0; i < layers.length; i++) {
750
                        String[] rutaCapa = new String[layers[i].getPathCount()];
751
                        
752
                        for (int j = 0; j < layers[i].getPathCount(); j++) {
753
                                rutaCapa[j] = ((WMSLayerNode) layers[i].getPathComponent(j)).getTitle();
754
                        }
755
                        
756
                        rect = dataSource.getBoundingBox(rutaCapa, getSRS());
757
                        
758
                        if (rect != null) {
759
                                rectangulos.add(rect);
760
                        }
761
                }
762
                
763
                rect = getRectangle((Rectangle2D.Double[]) rectangulos.toArray(
764
                                new Rectangle2D.Double[0]));
765
                
766
                return rect;
767
        }
768

    
769
        public TreePath[] getSelectedLayers() {
770
                return getTreeLayers().getSelectionPaths();
771
        }
772
        
773
        /**
774
         * Obtiene el rect?ngulo que contiene a todos los otros
775
         *
776
         * @param rects rectangulos
777
         *
778
         * @return Rectangulo que contiene a todos los demas
779
         */
780
        private Rectangle2D getRectangle(Rectangle2D[] rects) {
781
                Rectangle2D ret = rects[0];
782

    
783
                for (int i = 1; i < rects.length; i++) {
784
                        ret.add(rects[i]);
785
                }
786

    
787
                return ret;
788
        }
789

    
790
    /**
791
     * The piece of the GetMap request that has the layer names.
792
     * @return
793
     */
794
        public String getQueryableLayerQuery() {
795
        ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
796
        WMSLayerNode[] layers = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]);
797
        //Nombre separado por comas de las capas
798
                String layersQuery = "";
799
                int i;
800

    
801
                for (i = 0; i < layers.length; i++) {
802
                        if (layers[i].isQueryable()) {
803
                                layersQuery = layers[i].getName();
804

    
805
                                break;
806
                        }
807
                }
808

    
809
                for (int j = i + 1; j < layers.length; j++) {
810
                        if (layers[j].isQueryable()) {
811
                                layersQuery += ("," + layers[j].getName());
812
                        }
813
                }
814

    
815
                return layersQuery;
816
        }
817

    
818
        /**
819
         * Returns the index of the CRS within the CRS list.
820
         * 
821
         * Devuelve la posicion que ocupa el CRS en la lista de CRS
822
         * 
823
         * @param crs
824
         * @return The CRS's index if it exists, -1 if it not exists.
825
         */
826
        public int getSRSIndex(String crs) {
827
                for (int i=0; i<getLstSRSs().getModel().getSize(); i++){
828
                        if (crs!=null && crs.equals(getLstSRSs().getModel().getElementAt(i)))
829
                                return i;
830
                }
831
                return -1;
832
        }
833
        
834
        /**
835
         * Returns the index of the format within the formats list.
836
         * 
837
         * Devuelve la posicion que ocupa el formato en la lista de formatos
838
         * @param format
839
         * 
840
         * @return The format's index if it exists, -1 if it not exists.
841
         */
842
        public int getFormatIndex(String format) {
843
                for (int i=0; i<getLstFormats().getModel().getSize(); i++){
844
                        if (format!=null && format.equals(getLstFormats().getModel().getElementAt(i)))
845
                                return i;
846
                }
847
                return -1;
848
        }
849

    
850
        /**
851
         * This method initializes jTabbedPane        
852
         *         
853
         * @return javax.swing.JTabbedPane        
854
         */    
855
        public JTabbedPane getJTabbedPane() {
856
                if (jTabbedPane == null) {
857
                        jTabbedPane = new JTabbedPane();
858
                        jTabbedPane.setBounds(3, 3, 475, 415);
859
                        jTabbedPane.addTab(PluginServices.getText(this, "info"), null, getTabInfo(), null);
860
                        jTabbedPane.addTab(PluginServices.getText(this, "capas"), null, getTabLayers(), null);
861
                        jTabbedPane.addTab(PluginServices.getText(this, "formatos"), null, getTabFormats(), null);
862
                        //jTabbedPane.addTab(PluginServices.getText(this, "estilos (old)"), null, getTabStyleSelect(), null);
863
                        jTabbedPane.addTab(PluginServices.getText(this, "estilos"), null, getTabStyle(), null);
864
                        //jTabbedPane.addTab(PluginServices.getText(this, "estilos tabla"), null, getTabStyles(), null);        
865
                        jTabbedPane.addTab(PluginServices.getText(this, "dimensiones"), null, getTabDimensions(), null);
866
            
867
                }
868
                return jTabbedPane;
869
        }
870

    
871
        /**
872
         * This method initializes jPanel        
873
         *         
874
         * @return javax.swing.JPanel        
875
         */    
876
        private JPanel getTabLayers() {
877
                if (tabLayers == null) {
878
                        tabLayers = new JPanel();
879
                        tabLayers.setLayout(null);
880
                        tabLayers.add(getJPanel4(), null);
881
                        tabLayers.add(getJPanel2(), null);
882
                }
883
                return tabLayers;
884
        }
885

    
886
        /**
887
         * This method initializes jPanel1        
888
         *         
889
         * @return javax.swing.JPanel        
890
         */    
891
        private JPanel getJPanel1() {
892
                if (jPanel1 == null) {
893
                        jPanel1 = new JPanel();
894
                        jPanel1.setLayout(null);
895
            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
896
                    null, PluginServices.getText(this, "seleccionar_formato"),
897
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
898
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
899
                        jPanel1.setBounds(7, 10, 453, 194);
900
                        jPanel1.add(getJScrollPane6(), null);
901
                        jPanel1.add(getChkTransparency(), null);
902
                }
903
                return jPanel1;
904
        }
905

    
906
        /**
907
         * This method initializes jPanel5        
908
         *         
909
         * @return javax.swing.JPanel        
910
         */    
911
        private JPanel getJPanel5() {
912
                if (jPanel5 == null) {
913
                        jPanel5 = new JPanel();
914
                        jPanel5.setLayout(null);
915
            jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(
916
                    null, PluginServices.getText(this, "seleccionar_srs"),
917
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
918
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
919
                        jPanel5.setBounds(7, 210, 453, 168);
920
                        jPanel5.add(getJScrollPane2(), null);
921
                }
922
                return jPanel5;
923
        }
924

    
925
        /**
926
         * This method initializes jPanel6        
927
         *         
928
         * @return javax.swing.JPanel        
929
         */    
930
        public StylesPanel getTabStyle() {
931
                if (tabStyle == null) {
932
                        tabStyle = new StylesPanel();
933
                }
934
                return tabStyle;
935
        }
936

    
937
        /**
938
         * This method initializes tabStyleSelect        
939
         *         
940
         * @return javax.swing.JPanel        
941
         */    
942
        private JPanel getTabStyleSelect() {
943
                if (tabStyleSelect == null) {
944
                        styleSelectPanel = new StylesSelectionPanel(this);
945
                        tabStyleSelect = new JPanel();
946
                        tabStyleSelect.setLayout(null);
947
                        tabStyleSelect.add(styleSelectPanel, null);
948
                        styleSelectPanel.setTabPanel(tabStyleSelect);
949
                }
950
                return tabStyleSelect;
951
        }
952

    
953
        /**
954
     * This method initializes jPanel7  
955
     *  
956
     * @return javax.swing.JPanel   
957
     */    
958
    private JPanel getJPanel8() {
959
        if (jPanel8 == null) {
960
            jPanel8 = new JPanel();
961
            jPanel8.setLayout(null);
962
            jPanel8.setBounds(5, 9, 456, 376);
963
            jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(
964
                    null, PluginServices.getText(this, "seleccionar_estilo_para_capa"),
965
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
966
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
967
            jPanel8.add(getJScrollPane(), null);
968
        }
969
        return jPanel8;
970
    }
971
                
972
        /**
973
         * Sets the focus to the tab next to the current one.
974
         * 
975
         * Enfoca a la solapa siguiente a la actualmente enfocada del TabbedPane
976
         *
977
         */
978
        public void avanzaTab(){
979
                int currentPage = currentPage();
980
                int nPages = getNumTabs();
981
                if (nPages -1 > currentPage){
982
                        getJTabbedPane().setSelectedIndex(nextPageEnabled());
983
                }
984
        }
985
        
986
        /**
987
         * Sets the focus to the tab previous to the current one. 
988
         * 
989
         * Enfoca a la solapa anterior a la actualmente enfocada del TabbedPane
990
         * 
991
         */
992
        public void retrocedeTab(){
993
                this.getJTabbedPane().setSelectedIndex(previousEnabledPage());
994
                
995
        }
996
    /**
997
     * Returns the index of the current tab.
998
     * 
999
     * Devuelve el ?ndice de la p?gina actual del wizard.
1000
     * 
1001
     * @return
1002
     */
1003
    public int currentPage(){
1004
        return getJTabbedPane().getSelectedIndex();
1005
    }
1006
    
1007
        /**
1008
         * Returns the tab amount that the WMSParamsPanel currently have
1009
         * 
1010
         * Devuelve el n?mero de solapas que tiene actualmente el WMSParamsPanel
1011
         * 
1012
         * @return int
1013
         */
1014
        public int getNumTabs(){
1015
                return getJTabbedPane().getTabCount();
1016
        }
1017
        
1018
    
1019
        /**
1020
     * <p>
1021
     * Returns the index of the previous enabled tab.
1022
     * </p>
1023
     * <p>
1024
     * Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay
1025
     * ninguna.
1026
     * </p>
1027
    * @return The index, or -1 if there is no one.
1028
     */
1029
    public int previousEnabledPage(){
1030
        int currentPage = currentPage();
1031
        int j=0;
1032
        if (currentPage == 0)
1033
            j= -1;
1034
        for (int i = currentPage-1; i>-1; i--){
1035
            if (getJTabbedPane().isEnabledAt(i)){
1036
                j= i;
1037
                    break;
1038
            }
1039
        }
1040
        return j;
1041
    }
1042
    
1043
    /**
1044
     * <p>
1045
     * Returns the previous of the previous enabled tab.
1046
     * </p>
1047
     * <p>
1048
     * Devuelve el ?ndice de la siguiente p?gina habilitada del wizard o -1 si no hay
1049
     * ninguna.
1050
     * </p>
1051
     * @return The index, or -1 if there is no one.
1052
     */
1053
    public int nextPageEnabled() {
1054
        int currentPage = currentPage();
1055
        int nPages = getNumTabs();
1056
        if (currentPage == nPages)
1057
                return -1;
1058
        for (int i=currentPage+1; i<nPages; i++){
1059
            if (getJTabbedPane().isEnabledAt(i)){
1060
                return i;
1061
            }
1062
        }
1063
        return -1;
1064
    }
1065

    
1066
    /**
1067
     * This method initializes chkTrasparency        
1068
     *         
1069
     * @return javax.swing.JCheckBox        
1070
     */    
1071
    public JCheckBox getChkTransparency() {
1072
            if (chkTransparency == null) {
1073
                    chkTransparency = new JCheckBox();
1074
            chkTransparency.setText(PluginServices.getText(this, "wms_transparency"));
1075
            chkTransparency.setSelected(true);
1076
                    chkTransparency.setBounds(5, 168, 441, 21);
1077
            }
1078
            return chkTransparency;
1079
    }
1080

    
1081
    /**
1082
     * This method initializes jPanel        
1083
     *         
1084
     * @return javax.swing.JPanel        
1085
     */    
1086
    private JPanel getTabStyles() {
1087
            if (tabStyles == null) {
1088
                    tabStyles = new JPanel();
1089
                    tabStyles.setLayout(null);
1090
                    tabStyles.add(getJPanel8(), null);
1091
            }
1092
            return tabStyles;
1093
    }
1094

    
1095
    /**
1096
     * This method initializes jScrollPane        
1097
     *         
1098
     * @return javax.swing.JScrollPane        
1099
     */    
1100
    private JScrollPane getJScrollPane() {
1101
            if (jScrollPane == null) {
1102
                    jScrollPane = new JScrollPane();
1103
                    jScrollPane.setBounds(8, 20, 441, 350);
1104
                    jScrollPane.setViewportView(getTblStyles());
1105
            }
1106
            return jScrollPane;
1107
    }
1108

    
1109
    /**
1110
     * This method initializes tblStyles        
1111
     *         
1112
     * @return javax.swing.JTable        
1113
     */    
1114
    private JTable getTblStyles() {
1115
            if (tblStyles == null) {
1116
                    tblStyles = new StylesTable(new StylesTableModel());
1117
        }
1118
            return tblStyles;
1119
    }
1120
    
1121
    /**
1122
     * Returns a vector of strings containing the styles selected for the
1123
     * layers. A blank style is correct and means that default style will 
1124
     * be used.
1125
     * 
1126
     * TODO Tenir en compte que poden haver dues capes amb estils diferents i tal 
1127
     * com est?. Sempre tornar? l'estil de la primera (clonar el hash? refrescar l'ordre?)
1128
     * 
1129
     * @return Vector
1130
     */
1131
    public Vector getStyles() {
1132
        return getTabStyle().getStyleTree().getStylesSelection();
1133
    }
1134

    
1135
    /**
1136
     * This method initializes tabInfo        
1137
     *         
1138
     * @return javax.swing.JPanel        
1139
     */    
1140
    private InfoPanel getTabInfo() {
1141
            if (tabInfo == null) {
1142
                    tabInfo = new InfoPanel();
1143
                    
1144
            }
1145
            return tabInfo;
1146
    }
1147

    
1148

    
1149

    
1150

    
1151

    
1152
    /**
1153
     * This method initializes tabDimension        
1154
     *         
1155
     * @return javax.swing.JPanel        
1156
     */    
1157
    private DimensionPanel getTabDimensions() {
1158
            if (tabDimensions == null) {
1159
                    tabDimensions = new DimensionPanel();
1160
            
1161
            }
1162
            return tabDimensions;
1163
    }
1164

    
1165
    
1166

    
1167
    /**
1168
     * @return
1169
     */
1170
    public boolean getTransparency() {
1171
        return getChkTransparency().isEnabled();
1172
    }
1173
}  //  @jve:decl-index=0:visual-constraint="10,10"
1174

    
1175
/**
1176
 * Panel de seleccion de estilos para cada capa seleccionada.
1177
 */
1178
class StylesSelectionPanel extends JPanel {
1179
        private WMSParamsPanel mainPanel = null;
1180
        private JPanel tabPanel = null;
1181
        private JScrollPane scrlLayerStyles = null;
1182
        private JScrollPane scrlSelectedStyles = null;
1183
        private JList lstLayerStyles = null;
1184
        private JList lstSelectedStyles = null;
1185
        private JButton setLayerStyleBtn = null;
1186
        private JButton deleteLayerStyleBtn = null;
1187
        private JComboBox cmbStyleLayers = null;
1188
    private ArrayList styles;
1189
    
1190
    public StylesSelectionPanel(WMSParamsPanel p) {
1191
            super();
1192
            mainPanel = p;
1193
            init();
1194
    }
1195
        
1196
        /**
1197
         * This method initializes Panel        
1198
         */    
1199
        
1200
        private void init() {
1201
                setLayout(null);
1202
                setBounds(5, 9, 456, 376);
1203
                setBorder(javax.swing.BorderFactory.createTitledBorder(
1204
                                null, PluginServices.getText(this, "seleccionar_estilo_para_capa"),
1205
                                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
1206
                                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
1207
                add(getScrlLayerStyles(), null);
1208
                add(getScrlSelectedStyles(), null);
1209
                add(getSetLayerStyleBtn(), null);
1210
                add(getDeleteLayerStyleBtn(), null);
1211
                add(getCmbStyleLayers(), null);
1212
                setSetLayerStyleButtonEnabled(false);
1213
                setDeleteButtonEnabled(false);
1214
        }
1215
        
1216
        protected void refresh() {
1217
                getCmbStyleLayers().removeAllItems();
1218
                int size = getLstSelectedLayers().getModel().getSize();
1219
        getTabPanel().setEnabled(size != 0); // TODO y que alguna de ellas tenga estilo
1220
        for (int i=0; i<size; i++){
1221
                        getCmbStyleLayers().addItem(getLstSelectedLayers().getModel().getElementAt(i));
1222
                }
1223
        }
1224
        
1225
        protected void setTabPanel(JPanel tab) {
1226
                tabPanel = tab;
1227
        }
1228

    
1229
        protected JPanel getTabPanel() {
1230
                return tabPanel;
1231
        }
1232
        
1233
        public JList getLstSelectedLayers() {
1234
                return mainPanel.getLstSelectedLayers();
1235
        }
1236

    
1237
        /**
1238
         * This method initializes scrlLayerStyles        
1239
         *         
1240
         * @return javax.swing.JScrollPane        
1241
         */    
1242
        private JScrollPane getScrlLayerStyles() {
1243
                if (scrlLayerStyles == null) {
1244
                        scrlLayerStyles = new JScrollPane();
1245
                        scrlLayerStyles.setBounds(14, 67, 430, 117);
1246
                        scrlLayerStyles.setViewportView(getLstLayerStyles());
1247
                }
1248
                return scrlLayerStyles;
1249
        }
1250

    
1251
        /**
1252
         * This method initializes scrlStyles        
1253
         *         
1254
         * @return javax.swing.JScrollPane        
1255
         */    
1256
        private JScrollPane getScrlSelectedStyles() {
1257
                if (scrlSelectedStyles == null) {
1258
                        scrlSelectedStyles = new JScrollPane();
1259
                        scrlSelectedStyles.setBounds(14, 250, 430, 111);
1260
                        scrlSelectedStyles.setViewportView(getLstSelectedStyles());
1261
                        
1262
                }
1263
                return scrlSelectedStyles;
1264
        }
1265

    
1266
        /**
1267
         * This method initializes lstLayerStyles        
1268
         *         
1269
         * @return javax.swing.JList        
1270
         */    
1271
        private JList getLstLayerStyles() {
1272
                if (lstLayerStyles == null) {
1273
                        lstLayerStyles = new JList();
1274
                }
1275
                return lstLayerStyles;
1276
        }
1277

    
1278

    
1279
    /**
1280
         * This method initializes lstStyles        
1281
         *         
1282
         * @return javax.swing.JList        
1283
         */    
1284
        private JList getLstSelectedStyles() {
1285
                if (lstSelectedStyles == null) {
1286
                        lstSelectedStyles = new JList();
1287
                }
1288
                return lstSelectedStyles;
1289
        }
1290

    
1291
        /**
1292
         * This method initializes setLayerStyleBtn        
1293
         *         
1294
         * @return javax.swing.JButton        
1295
         */    
1296
        private JButton getSetLayerStyleBtn() {
1297
                if (setLayerStyleBtn == null) {
1298
                        setLayerStyleBtn = new JButton();
1299
                        setLayerStyleBtn.setBounds(183, 199, 33, 33);
1300
                }
1301
                return setLayerStyleBtn;
1302
        }
1303

    
1304
        /**
1305
         * This method initializes deleteLayerStyleBtn        
1306
         *         
1307
         * @return javax.swing.JButton        
1308
         */    
1309
        private JButton getDeleteLayerStyleBtn() {
1310
                if (deleteLayerStyleBtn == null) {
1311
                        deleteLayerStyleBtn = new JButton();
1312
                        deleteLayerStyleBtn.setBounds(236, 199, 33, 33);
1313
                }
1314
                return deleteLayerStyleBtn;
1315
        }
1316

    
1317
        /**
1318
         * Enables or disables the delete style button, and also shifts the
1319
         * IconImage.
1320
         * @param enabled
1321
         */
1322
        private void setDeleteButtonEnabled(boolean enabled){
1323
                JButton btn = getDeleteLayerStyleBtn();
1324
                btn.setEnabled(enabled);
1325
                // TODO Faltan los iconos
1326
/*                if (enabled){
1327
                        btn.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/delete-on.png")));
1328
                } else{
1329
                        btn.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/delete-off.png")));
1330
                }*/
1331
        }
1332

    
1333
        /**
1334
         * Enables or disables the add style button, and also shifts the
1335
         * IconImage.
1336
         * @param enabled
1337
         */
1338
        private void setSetLayerStyleButtonEnabled(boolean enabled){
1339
                JButton btn = getSetLayerStyleBtn();
1340
                btn.setEnabled(enabled);
1341
                // TODO Faltan los iconos
1342
                ImageIcon icon = null;
1343
/*                if (enabled){
1344
                        icon = new ImageIcon(getClass().getClassLoader().getResource("images/arrow-down-on.png"));
1345
                        if (icon != null)
1346
                                btn.setIcon(icon);
1347
                } else{
1348
                        icon = new ImageIcon(getClass().getClassLoader().getResource("images/arrow-down-off.png"));
1349
                        if (icon != null)
1350
                                btn.setIcon(icon);
1351
                }*/
1352
        }
1353

    
1354
        /**
1355
         * This method initializes cmbStyleLayers        
1356
         *         
1357
         * @return javax.swing.JComboBox        
1358
         */    
1359
        private JComboBox getCmbStyleLayers() {
1360
                if (cmbStyleLayers == null) {
1361
                        cmbStyleLayers = new JComboBox();
1362
                        cmbStyleLayers.setBounds(14, 25, 430, 20);
1363
                        cmbStyleLayers.addItemListener(new java.awt.event.ItemListener() { 
1364
                                public void itemStateChanged(java.awt.event.ItemEvent e) {    
1365
                                        setStyleList((WMSLayerNode)getCmbStyleLayers().getSelectedItem());
1366
                                }
1367
                        });
1368
                }
1369
                return cmbStyleLayers;
1370
        }
1371

    
1372
        /**
1373
         * Sets the styles of the layer passed as the layer's title
1374
         * 
1375
         * @param layerTitle
1376
         */
1377
        private void setStyleList(WMSLayerNode layer){
1378
        if (layer == null) 
1379
            return; 
1380
        ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel()).getElements();
1381
        WMSLayerNode[] layers = (WMSLayerNode[]) elements.toArray(new WMSLayerNode[0]);
1382
        for (int i = 0; i < layers.length; i++) {
1383
                        if (layers[i].getName().equals(layer.getName())){
1384
                styles = layers[i].getStyles();
1385
                if (styles == null)
1386
                    continue;
1387
                String[] styleTitles = new String[styles.size()];
1388
                for (int j=0; j < styles.size(); j++){
1389
                    WMSLayerNode.FMapWMSStyle style = (WMSLayerNode.FMapWMSStyle) styles.get(j);
1390
                    styleTitles[j] = style.title;
1391
                }
1392
                                getLstLayerStyles().setModel(new FormatListModel(styleTitles));                
1393
                        }
1394
                }
1395
        }
1396
}
1397

    
1398
/**
1399
 * Panel de informaci?n del Service
1400
 */
1401

    
1402
class InfoPanel extends JPanel {
1403
        private JTable tblInfo = null;
1404
        public InfoPanel() {
1405
                super();
1406
        JScrollPane src = new JScrollPane();
1407
        add(src, null);
1408
        src.setViewportView(getTblInfo());
1409
        }
1410
    /**
1411
     * This method initializes tblInfo        
1412
     *         
1413
     * @return javax.swing.JTable        
1414
     */    
1415
    private JTable getTblInfo() {
1416
            if (tblInfo == null) {
1417
            tblInfo = new JTable(new DefaultTableModel(0,2));
1418
            tblInfo.setRowSelectionAllowed(true);
1419
            tblInfo.setRowMargin(1);
1420
            }
1421
            return tblInfo;
1422
    }
1423

    
1424
    /**
1425
     * Rellena la tabla de datos de informaci?n del servicio.
1426
     * @param dataSource
1427
     */
1428
    
1429
    public void refresh(WMSWizardData dataSource) {
1430
        DefaultTableModel tbl = (DefaultTableModel) getTblInfo().getModel();
1431
        for (int i = tbl.getRowCount()-1; i >=0 ; i--) {
1432
            tbl.removeRow(i);
1433
        }
1434
        String[] row = new String[tbl.getColumnCount()];
1435
        
1436
        // No Column names
1437
        row[0] = " ";
1438
        row[1] = " ";
1439
        tbl.setColumnIdentifiers(row);
1440
        
1441
        // URL row
1442
        row[0] = PluginServices.getText(this, "servidor");
1443
        row[1] = dataSource.getHost();
1444
        tbl.addRow( row );
1445

    
1446
        // Server type row
1447
        row[0] = PluginServices.getText(this, "tipo_servidor");
1448
        row[1] = dataSource.getServerType();
1449
        tbl.addRow( row );
1450
        
1451
        // Server Title
1452
        row[0] = PluginServices.getText(this, "titulo_wms");
1453
        row[1] = dataSource.getTitle();
1454
        tbl.addRow( row );
1455
        
1456
        // Abstract
1457
        row[0] = PluginServices.getText(this, "abstract");
1458
        row[1] = dataSource.getAbstract();
1459
        tbl.addRow( row );
1460
    }
1461
}
1462

    
1463
class StylesPanel extends JPanel {
1464
    private JScrollPane jScrollPane = null;
1465
    private StyleTree treeStyles = null;
1466
    public StylesPanel(){
1467
        super();
1468
        setLayout(null);
1469
        add(getJScrollPane(), null);
1470
    }
1471
    /**
1472
     * This method initializes jScrollPane3 
1473
     *  
1474
     * @return javax.swing.JScrollPane  
1475
     */    
1476
    private JScrollPane getJScrollPane() {
1477
        if (jScrollPane == null) {
1478
            jScrollPane = new JScrollPane();
1479
            jScrollPane.setBounds(7, 50, 455, 327);
1480
            jScrollPane.setViewportView(getStyleTree());
1481
        }
1482
        return jScrollPane;
1483
    }
1484
    
1485
    /**
1486
     * This method initializes treeStyles   
1487
     *  
1488
     * @return javax.swing.JTree    
1489
     */    
1490
    public StyleTree getStyleTree() {
1491
        if (treeStyles == null) {
1492
            treeStyles = new StyleTree();
1493
        }
1494
        return treeStyles;
1495
    }
1496
}
1497

    
1498
class DimensionPanel extends JPanel {
1499
    
1500
    private JScrollPane jScrollPane;
1501
    private DimensionTree tree;
1502

    
1503
    public DimensionPanel(){
1504
        super();
1505
        setLayout(null);
1506
        setLayout(null);
1507
        add(getJScrollPane(), null);
1508
    }
1509
    /**
1510
     * This method initializes jScrollPane3 
1511
     *  
1512
     * @return javax.swing.JScrollPane  
1513
     */    
1514
    private JScrollPane getJScrollPane() {
1515
        if (jScrollPane == null) {
1516
            jScrollPane = new JScrollPane();
1517
            jScrollPane.setBounds(7, 50, 455, 327);
1518
            jScrollPane.setViewportView(getDimensionTree());
1519
        }
1520
        return jScrollPane;
1521
    }
1522
    
1523
    /**
1524
     * This method initializes treeStyles   
1525
     *  
1526
     * @return javax.swing.JTree    
1527
     */    
1528
    public DimensionTree getDimensionTree() {
1529
        if (tree == null) {
1530
            tree = new DimensionTree();
1531
        }
1532
        return tree;
1533
    }
1534
}