Statistics
| Revision:

root / branches / gvSIG_WMSv2 / extensions / extWMS / src / com / iver / cit / gvsig / gui / panels / WMSParamsPanel.java @ 3335

History | View | Annotate | Download (24.1 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.HashSet;
46
import java.util.Iterator;
47
import java.util.TreeSet;
48

    
49
import javax.swing.DefaultListModel;
50
import javax.swing.JList;
51
import javax.swing.JPanel;
52
import javax.swing.JScrollPane;
53
import javax.swing.JTabbedPane;
54
import javax.swing.JTextField;
55
import javax.swing.tree.TreePath;
56

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

    
158
                return jPanel2;
159
        }
160
        
161
        /**
162
         * This method initializes jPanel4
163
         *
164
         * @return javax.swing.JPanel
165
         */
166
        private JPanel getJPanel4() {
167
                if (jPanel4 == null) {
168
                        jPanel4 = new JPanel();
169
                        jPanel4.setLayout(null);
170
                        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(
171
                                        null, PluginServices.getText(this, "nombre_capa"),
172
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
173
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
174
                        jPanel4.setBounds(4, 8, 457, 49);
175
                        jPanel4.add(getJTxtNomCapa(), null);
176
                }
177

    
178
                return jPanel4;
179
        }
180
        
181
        /**
182
         * This method initializes jPanel3
183
         *
184
         * @return javax.swing.JPanel
185
         */
186
        private javax.swing.JPanel getTabFormats() {
187
                if (tabFormats == null) {
188
                        tabFormats = new javax.swing.JPanel();
189
                        tabFormats.setLayout(null);
190
                        tabFormats.setBorder(javax.swing.BorderFactory.createTitledBorder(
191
                                        null, PluginServices.getText(this, "seleccionar_formato"),
192
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
193
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
194
                        tabFormats.add(getJPanel1(), null);
195
                        tabFormats.add(getJPanel5(), null);
196
                }
197

    
198
                return tabFormats;
199
        }
200
        /**
201
         * This method initializes jScrollPane1
202
         *
203
         * @return javax.swing.JScrollPane
204
         */
205
        private javax.swing.JScrollPane getJScrollPane1() {
206
                if (jScrollPane1 == null) {
207
                        jScrollPane1 = new javax.swing.JScrollPane();
208
                        jScrollPane1.setBounds(11, 22, 430, 124);
209
                        jScrollPane1.setViewportView(getTreeLayers());
210
                        jScrollPane1.setPreferredSize(new java.awt.Dimension(205, 75));
211
                }
212

    
213
                return jScrollPane1;
214
        }
215
        
216
        /**
217
         * This method initializes btnDel
218
         *
219
         * @return javax.swing.JButton
220
         */
221
        public javax.swing.JButton getBtnDel() {
222
                if (btnDel == null) {
223
                        btnDel = new javax.swing.JButton();
224
                        btnDel.setPreferredSize(new java.awt.Dimension(23, 23));
225
                        btnDel.setText("quitar");
226
                        btnDel.setMargin(new java.awt.Insets(2, 0, 2, 0));
227
                        btnDel.setBounds(246, 158, 101, 23);
228
                        btnDel.setEnabled(false);
229
                        btnDel.addActionListener(new java.awt.event.ActionListener() {
230
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
231
                                                delLayer();
232
                                        }
233
                                });
234
                }
235
                return btnDel;
236
        }
237
        
238
        /**
239
         * This method initializes btnAdd
240
         *
241
         * @return javax.swing.JButton
242
         */
243
        public javax.swing.JButton getBtnAdd() {
244
                if (btnAdd == null) {
245
                        btnAdd = new javax.swing.JButton();
246
                        btnAdd.setPreferredSize(new java.awt.Dimension(23, 23));
247
                        btnAdd.setText("anadir");
248
                        btnAdd.setMargin(new java.awt.Insets(2, 0, 2, 0));
249
                        btnAdd.setBounds(133, 158, 101, 23);
250
                        btnAdd.setEnabled(false);
251
                        btnAdd.addActionListener(new java.awt.event.ActionListener() {
252
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
253
                                                addLayer();
254
                                        }
255
                                });
256
                }
257

    
258
                return btnAdd;
259
        }
260
        
261
        /**
262
         * This method initializes jScrollPane5
263
         *
264
         * @return javax.swing.JScrollPane
265
         */
266
        private javax.swing.JScrollPane getJScrollPane5() {
267
                if (jScrollPane5 == null) {
268
                        jScrollPane5 = new javax.swing.JScrollPane();
269
                        jScrollPane5.setBounds(11, 195, 431, 131);
270
                        jScrollPane5.setViewportView(getLstSelectedLayers());
271
                        jScrollPane5.setPreferredSize(new java.awt.Dimension(205, 75));
272
                }
273

    
274
                return jScrollPane5;
275
        }
276
        
277
        /**
278
         * This method initializes jTextField
279
         *
280
         * @return javax.swing.JTextField
281
         */
282
        public JTextField getJTxtNomCapa() {
283
                if (jTxtNomCapa == null) {
284
                        jTxtNomCapa = new JTextField();
285
                        jTxtNomCapa.setBounds(10, 19, 437, 20);
286
                        jTxtNomCapa.setText(PluginServices.getText(this, "capaWMS"));
287
                }
288

    
289
                return jTxtNomCapa;
290
        }
291

    
292

    
293
        /**
294
         * This method initializes jScrollPane6
295
         *
296
         * @return javax.swing.JScrollPane
297
         */
298
        private javax.swing.JScrollPane getJScrollPane6() {
299
                if (jScrollPane6 == null) {
300
                        jScrollPane6 = new javax.swing.JScrollPane();
301
                        jScrollPane6.setBounds(5, 5, 442, 158);
302
                        jScrollPane6.setViewportView(getLstFormats());
303
                        jScrollPane6.setPreferredSize(new java.awt.Dimension(250, 200));
304
                }
305

    
306
                return jScrollPane6;
307
        }
308
        
309
        /**
310
         * This method initializes jScrollPane2
311
         *
312
         * @return javax.swing.JScrollPane
313
         */
314
        private javax.swing.JScrollPane getJScrollPane2() {
315
                if (jScrollPane2 == null) {
316
                        jScrollPane2 = new javax.swing.JScrollPane();
317
                        jScrollPane2.setBounds(5, 5, 442, 172);
318
                        jScrollPane2.setViewportView(getLstSRSs());
319
                        jScrollPane2.setPreferredSize(new java.awt.Dimension(100, 200));
320
                }
321

    
322
                return jScrollPane2;
323
        }
324
        
325
        /**
326
         * This method initializes treeLayers
327
         *
328
         * @return javax.swing.JTree
329
         */
330
        public javax.swing.JTree getTreeLayers() {
331
                if (treeLayers == null) {
332
                        treeLayers = new javax.swing.JTree();
333
                        treeLayers.setRootVisible(true);
334
                        treeLayers.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
335
                                        public void valueChanged(
336
                                                javax.swing.event.TreeSelectionEvent e) {
337
                                                // activarVisualizarBotones();
338
                                                getBtnAdd().setEnabled(treeLayers.getSelectionCount()>0);
339
                                                listenerSupport.callStateChanged(isCorretlyConfigured());
340
                                        }
341
                                });
342
                }
343

    
344
                return treeLayers;
345
        }
346
        
347
        /**
348
         * This method checks for the options selected within the configuration dialog are 
349
         * correct and enough to perform a GetMap request.
350
         * @return true if you're done, false if not.
351
         */
352
        public boolean isCorretlyConfigured() {
353
                boolean b;
354
                if ((getLstSRSs().getSelectedIndex() != -1) &&
355
                                (getLstFormats().getSelectedIndex() != -1) &&
356
                                (getLstSelectedLayers().getModel().getSize() > 0)) {
357
                        b = true;
358
                } else {
359
                        b = false;
360
                }
361

    
362
                /*if (getTreeLayers1().getSelectionCount() > 0) {
363
                        LayerInfo nodo = (LayerInfo) getTreeLayers1().getSelectionPath()
364
                                                                                         .getLastPathComponent();
365
                        String name = nodo.name;
366

367
                        if (name != null) {
368
                                getBtnAdd().setEnabled(true);
369
                        } else {
370
                                getBtnAdd().setEnabled(false);
371
                        }
372
                } else {
373
                        getBtnAdd().setEnabled(false);
374
                }
375

376
                if (getLstSelectedLayers().getSelectedIndex() != -1) {
377
                        getBtnDel().setEnabled(true);
378
                } else {
379
                        getBtnDel().setEnabled(false);
380
                }*/
381
                return b;
382
        }
383

    
384
        /**
385
         * DOCUMENT ME!
386
         */
387
        private void delLayer() {
388
                int[] index = lstSelectedLayers.getSelectedIndices();
389

    
390
                ArrayList removeList = new ArrayList();
391
                LayerListModel modelo = (LayerListModel) lstSelectedLayers.getModel();
392
                LayerInfo[] infos = modelo.getElements();
393

    
394
                for (int i = 0; i < index.length; i++) {
395
                        removeList.add(infos[index[i]]);
396
                }
397

    
398
                modelo.delElements(removeList);
399
                lstSelectedLayers.clearSelection();
400
                listenerSupport.callStateChanged(true);
401
                //activarVisualizarBotones();
402

    
403
                actualizarSRS();
404
        }
405
        
406
        /**
407
         * DOCUMENT ME!
408
         */
409
        private void addLayer() {
410
                boolean alguno = false;
411

    
412
                TreePath[] selecciones = getTreeLayers().getSelectionPaths();
413

    
414
                for (int i = 0; i < selecciones.length; i++) {
415
                        LayerInfo nodo = (LayerInfo) selecciones[i].getLastPathComponent();
416

    
417
                        String name = nodo.name;
418
                        String text = nodo.text;
419
                        ArrayList srs = nodo.getSRSs();
420

    
421
                        //Se a?ade a la lista de layers seleccionados
422
                        LayerListModel modelo = (LayerListModel) lstSelectedLayers.getModel();
423

    
424
                        if (modelo.addElement(nodo)) {
425
                                alguno = true;
426
                        }
427
                }
428

    
429
                if (alguno) {
430
                        // activarVisualizarBotones();
431
                        actualizarSRS();
432
                }
433
        }
434
        
435
        /**
436
         * This method initializes lstSelectedLayers
437
         *
438
         * @return javax.swing.JList
439
         */
440
        public javax.swing.JList getLstSelectedLayers() {
441
                if (lstSelectedLayers == null) {
442
                        lstSelectedLayers = new javax.swing.JList();
443
                        lstSelectedLayers.setModel(selectedLayersModel);
444
                        lstSelectedLayers.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
445
                        lstSelectedLayers.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
446
                                        public void valueChanged(
447
                                                javax.swing.event.ListSelectionEvent e) {
448
                                                //activarVisualizarBotones();
449
                                                listenerSupport.callStateChanged(isCorretlyConfigured());
450
                                        }
451
                                });
452
                }
453

    
454
                return lstSelectedLayers;
455
        }
456
        /**
457
         * This method initializes lstSRSs
458
         *
459
         * @return javax.swing.JList
460
         */
461
        public javax.swing.JList getLstSRSs() {
462
                if (lstSRSs == null) {
463
                        lstSRSs = new javax.swing.JList();
464
                        lstSRSs.setModel(new SRSListModel());
465
                        lstSRSs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
466
                        lstSRSs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
467
                                        public void valueChanged(
468
                                                javax.swing.event.ListSelectionEvent e) {
469
                                                //activarVisualizarBotones();
470
                                                listenerSupport.callStateChanged(isCorretlyConfigured());
471
                                        }
472
                                });
473
                }
474

    
475
                return lstSRSs;
476
        }
477

    
478
        /**
479
         * This method initializes lstFormats1
480
         *
481
         * @return javax.swing.JList
482
         */
483
        public javax.swing.JList getLstFormats() {
484
                if (lstFormats == null) {
485
                        lstFormats = new javax.swing.JList();
486
                        lstFormats.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
487
                        lstFormats.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
488
                                        public void valueChanged(
489
                                                javax.swing.event.ListSelectionEvent e) {
490
                                                //activarVisualizarBotones();
491
                                                listenerSupport.callStateChanged(isCorretlyConfigured());
492
                                        }
493
                                });
494
                }
495

    
496
                return lstFormats;
497
        }
498

    
499
        /**
500
         * DOCUMENT ME!
501
         */
502
        private void actualizarSRS() {
503
                LayerInfo[] layers = ((LayerListModel) lstSelectedLayers.getModel()).getElements();
504

    
505
                if (layers.length == 0) {
506
                        lstSRSs.setModel(new DefaultListModel());
507
                } else {
508
                        TreeSet srsSet = new TreeSet();
509
                        srsSet.addAll(layers[0].getSRSs());
510

    
511
                        for (int i = 1; i < layers.length; i++) {
512
                                HashSet nuevo = new HashSet(layers[i].getSRSs());
513
                                Iterator it = srsSet.iterator();
514

    
515
                                while (it.hasNext()) {
516
                                        String srs = (String) it.next();
517

    
518
                                        if (!nuevo.contains(srs)) {
519
                                                srsSet.remove(srs);
520
                                        }
521
                                }
522
                        }
523

    
524
                        DefaultListModel model = new DefaultListModel();
525
                        String[] array = (String[]) srsSet.toArray(new String[0]);
526

    
527
                        for (int i = 0; i < array.length; i++) {
528
                                model.addElement(array[i]);
529
                        }
530

    
531
                        lstSRSs.setModel(model);
532
                }
533
        }
534

    
535
        public void setListenerSupport(WizardListenerSupport support) {
536
                listenerSupport = support;
537
        }
538

    
539
        public void setWizardData(WizardData data) {
540
                this.data = data;
541
                ((LayerListModel) getLstSelectedLayers().getModel()).clear();
542
                getLstSelectedLayers().repaint();
543
                getLstFormats().setModel(new FormatListModel(this.data.getFormats()));
544
                getTreeLayers().setModel(new LayerTreeModel(this.data.getLayer()));
545
                getLstLayerStyles().setModel(getLstSelectedLayers().getModel());
546
                getLstLayerStyles().repaint();
547
        }
548

    
549
        public void setDataSource(WizardDataSource dataSource) {
550
                this.dataSource = dataSource;
551
        }
552

    
553
        public String getFormat() {
554
                return (String) getLstFormats().getSelectedValue();
555
        }
556

    
557
        public String getLayersQuery() {
558
                LayerInfo[] layers = ((LayerListModel) getLstSelectedLayers().getModel()).getElements();
559

    
560
                //Nombre separado por comas de las capas
561
                String layersQuery = layers[0].name;
562

    
563
                for (int i = 1; i < layers.length; i++) {
564
                        layersQuery += ("," + layers[i].name);
565
                }
566

    
567
                return layersQuery;
568
                
569
        }
570

    
571
        public String getSRS() {
572
                return (String) getLstSRSs().getSelectedValue();
573
        }
574

    
575
        public String getLayerName() {
576
                return getJTxtNomCapa().getText();        
577
        }
578
        
579
        public Rectangle2D getLayersRectangle(){        
580
                TreePath[] layers = getSelectedLayers();
581
                
582
                //Boundingbox de todas las capas
583
                ArrayList rectangulos = new ArrayList();
584
                
585
                Rectangle2D rect;
586
                
587
                for (int i = 0; i < layers.length; i++) {
588
                        String[] rutaCapa = new String[layers[i].getPathCount()];
589
                        
590
                        for (int j = 0; j < layers[i].getPathCount(); j++) {
591
                                rutaCapa[j] = ((LayerInfo) layers[i].getPathComponent(j)).text;
592
                        }
593
                        
594
                        rect = dataSource.getBoundingBox(rutaCapa, getSRS());
595
                        
596
                        if (rect != null) {
597
                                rectangulos.add(rect);
598
                        }
599
                }
600
                
601
                rect = getRectangle((Rectangle2D.Double[]) rectangulos.toArray(
602
                                new Rectangle2D.Double[0]));
603
                
604
                return rect;
605
        }
606

    
607
        public TreePath[] getSelectedLayers() {
608
                return getTreeLayers().getSelectionPaths();
609
        }
610
        
611
        /**
612
         * Obtiene el rect?ngulo que contiene a todos los otros
613
         *
614
         * @param rects rectangulos
615
         *
616
         * @return Rectangulo que contiene a todos los demas
617
         */
618
        private Rectangle2D getRectangle(Rectangle2D[] rects) {
619
                Rectangle2D ret = rects[0];
620

    
621
                for (int i = 1; i < rects.length; i++) {
622
                        ret.add(rects[i]);
623
                }
624

    
625
                return ret;
626
        }
627

    
628
        public String getQueryableLayerQuery() {
629
                LayerInfo[] layers = ((LayerListModel) getLstSelectedLayers().getModel()).getElements();
630

    
631
                //Nombre separado por comas de las capas
632
                String layersQuery = "";
633
                int i;
634

    
635
                for (i = 0; i < layers.length; i++) {
636
                        if (layers[i].queryable) {
637
                                layersQuery = layers[i].name;
638

    
639
                                break;
640
                        }
641
                }
642

    
643
                for (int j = i + 1; j < layers.length; j++) {
644
                        if (layers[j].queryable) {
645
                                layersQuery += ("," + layers[j].name);
646
                        }
647
                }
648

    
649
                return layersQuery;
650
        }
651

    
652
        /**
653
         * Returns the index of the CRS within the CRS list.
654
         * 
655
         * Devuelve la posicion que ocupa el CRS en la lista de CRS
656
         * 
657
         * @param crs
658
         * @return The CRS's index if it exists, -1 if it not exists.
659
         */
660
        public int getSRSIndex(String crs) {
661
                for (int i=0; i<getLstSRSs().getModel().getSize(); i++){
662
                        if (crs.equals(getLstSRSs().getModel().getElementAt(i)))
663
                                return i;
664
                }
665
                return -1;
666
        }
667
        
668
        /**
669
         * Returns the index of the format within the formats list.
670
         * 
671
         * Devuelve la posicion que ocupa el formato en la lista de formatos
672
         * @param format
673
         * 
674
         * @return The format's index if it exists, -1 if it not exists.
675
         */
676
        public int getFormatIndex(String format) {
677
                for (int i=0; i<getLstFormats().getModel().getSize(); i++){
678
                        if (format.equals(getLstFormats().getModel().getElementAt(i)))
679
                                return i;
680
                }
681
                return -1;
682
        }
683

    
684
        /**
685
         * This method initializes jTabbedPane        
686
         *         
687
         * @return javax.swing.JTabbedPane        
688
         */    
689
        private JTabbedPane getJTabbedPane() {
690
                if (jTabbedPane == null) {
691
                        jTabbedPane = new JTabbedPane();
692
                        jTabbedPane.setBounds(3, 3, 475, 415);
693
                        jTabbedPane.addTab(PluginServices.getText(this, "capas"), null, getTabLayers(), null);
694
                        jTabbedPane.addTab(PluginServices.getText(this, "formatos"), null, getTabFormats(), null);
695
                        jTabbedPane.addTab(PluginServices.getText(this, "estilos"), null, getTabStyle(), null);
696
                        
697
                }
698
                return jTabbedPane;
699
        }
700

    
701
        /**
702
         * This method initializes jPanel        
703
         *         
704
         * @return javax.swing.JPanel        
705
         */    
706
        private JPanel getTabLayers() {
707
                if (tabLayers == null) {
708
                        tabLayers = new JPanel();
709
                        tabLayers.setLayout(null);
710
                        tabLayers.add(getJPanel4(), null);
711
                        tabLayers.add(getJPanel2(), null);
712
                }
713
                return tabLayers;
714
        }
715

    
716
        /**
717
         * This method initializes jPanel1        
718
         *         
719
         * @return javax.swing.JPanel        
720
         */    
721
        private JPanel getJPanel1() {
722
                if (jPanel1 == null) {
723
                        jPanel1 = new JPanel();
724
                        jPanel1.setLayout(null);
725
                        jPanel1.setBounds(7, 20, 452, 168);
726
                        jPanel1.add(getJScrollPane6(), null);
727
                }
728
                return jPanel1;
729
        }
730

    
731
        /**
732
         * This method initializes jPanel5        
733
         *         
734
         * @return javax.swing.JPanel        
735
         */    
736
        private JPanel getJPanel5() {
737
                if (jPanel5 == null) {
738
                        jPanel5 = new JPanel();
739
                        jPanel5.setLayout(null);
740
                        jPanel5.setBounds(7, 194, 453, 184);
741
                        jPanel5.add(getJScrollPane2(), null);
742
                }
743
                return jPanel5;
744
        }
745

    
746
        /**
747
         * This method initializes jPanel6        
748
         *         
749
         * @return javax.swing.JPanel        
750
         */    
751
        private JPanel getTabStyle() {
752
                if (tabStyles == null) {
753
                        tabStyles = new JPanel();
754
                        tabStyles.setLayout(null);
755
                        tabStyles.add(getJPanel7(), null);
756
                }
757
                return tabStyles;
758
        }
759

    
760
        /**
761
         * This method initializes jPanel7        
762
         *         
763
         * @return javax.swing.JPanel        
764
         */    
765
        private JPanel getJPanel7() {
766
                if (jPanel7 == null) {
767
                        jPanel7 = new JPanel();
768
                        jPanel7.setLayout(null);
769
                        jPanel7.setBounds(5, 9, 456, 376);
770
                        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(
771
                                        null, PluginServices.getText(this, "seleccionar_estilo_para_capa"),
772
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
773
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
774
                        jPanel7.add(getScrlLayerStyles(), null);
775
                        jPanel7.add(getScrlStyles(), null);
776
                }
777
                return jPanel7;
778
        }
779

    
780
        /**
781
         * This method initializes scrlLayerStyles        
782
         *         
783
         * @return javax.swing.JScrollPane        
784
         */    
785
        private JScrollPane getScrlLayerStyles() {
786
                if (scrlLayerStyles == null) {
787
                        scrlLayerStyles = new JScrollPane();
788
                        scrlLayerStyles.setBounds(14, 23, 430, 147);
789
                        scrlLayerStyles.setViewportView(getLstLayerStyles());
790
                }
791
                return scrlLayerStyles;
792
        }
793

    
794
        /**
795
         * This method initializes scrlStyles        
796
         *         
797
         * @return javax.swing.JScrollPane        
798
         */    
799
        private JScrollPane getScrlStyles() {
800
                if (scrlStyles == null) {
801
                        scrlStyles = new JScrollPane();
802
                        scrlStyles.setBounds(14, 176, 430, 187);
803
                        scrlStyles.setViewportView(getLstStyles());
804
                }
805
                return scrlStyles;
806
        }
807

    
808
        /**
809
         * This method initializes lstLayerStyles        
810
         *         
811
         * @return javax.swing.JList        
812
         */    
813
        private JList getLstLayerStyles() {
814
                if (lstLayerStyles == null) {
815
                        lstLayerStyles = new JList();
816
                }
817
                return lstLayerStyles;
818
        }
819

    
820
        /**
821
         * This method initializes lstStyles        
822
         *         
823
         * @return javax.swing.JList        
824
         */    
825
        private JList getLstStyles() {
826
                if (lstStyles == null) {
827
                        lstStyles = new JList();
828
                }
829
                return lstStyles;
830
        }
831

    
832
                
833
        /**
834
         * Sets the focus to the tab next to the current one.
835
         * 
836
         * Enfoca a la solapa siguiente a la actualmente enfocada del TabbedPane
837
         *
838
         */
839
        public void avanzaTab(){
840
                int currentPage = currentPage();
841
                int nPages = getNumTabs();
842
                if (nPages -1 > currentPage){
843
                        getJTabbedPane().setSelectedIndex(nextPageEnabled());
844
                }
845
        }
846
        
847
        /**
848
         * Sets the focus to the tab previous to the current one. 
849
         * 
850
         * Enfoca a la solapa anterior a la actualmente enfocada del TabbedPane
851
         * 
852
         */
853
        public void retrocedeTab(){
854
                this.getJTabbedPane().setSelectedIndex(previousEnabledPage());
855

    
856
        }
857
    /**
858
     * Returns the index of the current tab.
859
     * 
860
     * Devuelve el ?ndice de la p?gina actual del wizard.
861
     * 
862
     * @return
863
     */
864
    public int currentPage(){
865
        return getJTabbedPane().getSelectedIndex();
866
    }
867
    
868
        /**
869
         * Returns the tab amount that the WMSParamsPanel currently have
870
         * 
871
         * Devuelve el n?mero de solapas que tiene actualmente el WMSParamsPanel
872
         * 
873
         * @return int
874
         */
875
        public int getNumTabs(){
876
                return getJTabbedPane().getTabCount();
877
        }
878
        
879
    
880
        /**
881
     * <p>
882
     * Returns the index of the previous enabled tab.
883
     * </p>
884
     * <p>
885
     * Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay
886
     * ninguna.
887
     * </p>
888
    * @return The index, or -1 if there is no one.
889
     */
890
    public int previousEnabledPage(){
891
        int currentPage = currentPage();
892
        int j=0;
893
        if (currentPage == 0)
894
            j= -1;
895
        for (int i = currentPage-1; i>-1; i--){
896
            if (getJTabbedPane().isEnabledAt(i)){
897
                j= i;
898
                    break;
899
            }
900
        }
901
        return j;
902
    }
903
    
904
    /**
905
     * <p>
906
     * Returns the previous of the previous enabled tab.
907
     * </p>
908
     * <p>
909
     * Devuelve el ?ndice de la siguiente p?gina habilitada del wizard o -1 si no hay
910
     * ninguna.
911
     * </p>
912
     * @return The index, or -1 if there is no one.
913
     */
914
    public int nextPageEnabled() {
915
        int currentPage = currentPage();
916
        int nPages = getNumTabs();
917
        if (currentPage == nPages)
918
                return -1;
919
        for (int i=currentPage+1; i<nPages; i++){
920
            if (getJTabbedPane().isEnabledAt(i)){
921
                return i;
922
            }
923
        }
924
        return -1;
925
    }
926
    
927
        public int getIndiceSolapaActual() {
928
                // TODO Auto-generated method stub
929
                return 0;
930
        }
931

    
932
}  //  @jve:decl-index=0:visual-constraint="10,10"