Statistics
| Revision:

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

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

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

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

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

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

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

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

    
291
                return jTxtNomCapa;
292
        }
293

    
294

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

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

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

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

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

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

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

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

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

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

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

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

    
414
                TreePath[] selecciones = getTreeLayers().getSelectionPaths();
415

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

    
419
                        String name = nodo.name;
420
                        String text = nodo.text;
421
                        ArrayList srs = nodo.getSRSs();
422

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

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

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

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

    
477
                return lstSRSs;
478
        }
479

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

    
498
                return lstFormats;
499
        }
500

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

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

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

    
517
                                while (it.hasNext()) {
518
                                        String srs = (String) it.next();
519

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

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

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

    
533
                        lstSRSs.setModel(model);
534
                }
535
        }
536

    
537
        public void setListenerSupport(WizardListenerSupport support) {
538
                listenerSupport = support;
539
        }
540

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

    
551
        public void setDataSource(WMSWizardDataSource dataSource) {
552
                this.dataSource = dataSource;
553
        }
554

    
555
        public String getFormat() {
556
                return (String) getLstFormats().getSelectedValue();
557
        }
558

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

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

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

    
569
                return layersQuery;
570
                
571
        }
572

    
573
        public String getSRS() {
574
                return (String) getLstSRSs().getSelectedValue();
575
        }
576

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

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

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

    
627
                return ret;
628
        }
629

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

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

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

    
641
                                break;
642
                        }
643
                }
644

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

    
651
                return layersQuery;
652
        }
653

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

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

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

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

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

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

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

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

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

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

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

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

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

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