Statistics
| Revision:

root / org.gvsig.wfs.app / trunk / org.gvsig.wfs.app / org.gvsig.wfs.app.mainplugin / src / main / java / org / gvsig / wfs / gui / panels / WFSOptionsPanel.java @ 107

History | View | Annotate | Download (22.4 KB)

1
package org.gvsig.wfs.gui.panels;
2

    
3
import java.awt.Component;
4
import java.awt.Dimension;
5
import java.awt.Rectangle;
6
import java.awt.event.ActionEvent;
7
import java.awt.event.ActionListener;
8
import java.util.Iterator;
9
import java.util.List;
10
import java.util.Vector;
11

    
12
import javax.swing.BorderFactory;
13
import javax.swing.JCheckBox;
14
import javax.swing.JComboBox;
15
import javax.swing.JLabel;
16
import javax.swing.JOptionPane;
17
import javax.swing.JPanel;
18
import javax.swing.JPasswordField;
19
import javax.swing.JSpinner;
20
import javax.swing.JTextField;
21
import javax.swing.SpinnerModel;
22
import javax.swing.SpinnerNumberModel;
23
import javax.swing.border.TitledBorder;
24
import org.apache.commons.lang3.StringUtils;
25

    
26
import org.cresques.cts.IProjection;
27

    
28
import org.gvsig.andami.PluginServices;
29
import org.gvsig.app.ApplicationLocator;
30
import org.gvsig.fmap.crs.CRSFactory;
31
import org.gvsig.gui.beans.panelGroup.IPanelGroup;
32
import org.gvsig.i18n.Messages;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.i18n.I18nManager;
35
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature;
36

    
37

    
38
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
39
 *
40
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
41
 *
42
 * This program is free software; you can redistribute it and/or
43
 * modify it under the terms of the GNU General Public License
44
 * as published by the Free Software Foundation; either version 2
45
 * of the License, or (at your option) any later version.
46
 *
47
 * This program is distributed in the hope that it will be useful,
48
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
50
 * GNU General Public License for more details.
51
 *
52
 * You should have received a copy of the GNU General Public License
53
 * along with this program; if not, write to the Free Software
54
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
55
 *
56
 */
57
/**
58
 * <p>
59
 * Panel with options about the timeout, maximum number of features, the
60
 * projection reference system, and if it's implemented, user and password.</p>
61
 *
62
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
63
 * @author Pablo Piqueras Bartolom?
64
 */
65
public class WFSOptionsPanel extends AbstractWFSPanel {
66

    
67
    private static final long serialVersionUID = -769956995699452173L;
68

    
69
    public static final int DEFAULT_TIMEOUT_MILLISECONDS = 20000;
70

    
71
    private JPanel credentialsPanel = null;
72
    private JLabel usernameLabel = null;
73
    private JTextField usernameText = null;
74
    private JLabel passwordLabel = null;
75
    private JPasswordField passwordText = null;
76
    private JPanel connectionParamsPanel = null;
77
    private JLabel timeoutLabel = null;
78

    
79
    private JSpinner maxFeaturesSpinner = null;
80

    
81
    private JLabel bufferLabel = null;
82
    private JComboBox timeoutCombo = null;
83
    private JPanel formatPanel = null;
84
    private JLabel srsLabel = null;
85
    private JLabel verLabel = null;
86
    // private JTextField srsText = null;
87
    private JComboBox ver_Combo = null;
88
    private JPanel versionPanel = null;
89

    
90
    private JComboBox srsCombo = null;
91
    // private JLabel jLabelMiliSeconds = null;
92
    private JPanel bufferPanel = null;
93
    private JPanel timeOutPanel = null;
94
    private JPanel northPanel = null;
95
    //Cache panel
96
    private JPanel cachePanel = null;
97
    private JCheckBox enableCacheCheckBox = null;
98
    private JPanel axisOrderPanel;
99
    private JCheckBox axisOrderYXCheckBox;
100

    
101
    /**
102
     * Creates a new WFS options panel.
103
     */
104
    public WFSOptionsPanel() {
105
        super();
106
        initialize();
107
    }
108

    
109
    /**
110
     * This method initializes usernameText
111
     *
112
     * @return javax.swing.JTextField
113
     */
114
    private JTextField getUsernameText() {
115
        if (usernameText == null) {
116
            usernameText = new JTextField();
117
            usernameText.setBounds(new java.awt.Rectangle(100, 25, 200, 20));
118
            usernameText.addKeyListener(new java.awt.event.KeyAdapter() {
119
                public void keyTyped(java.awt.event.KeyEvent e) {
120
                    IPanelGroup panelGroup = getPanelGroup();
121

    
122
                    if (panelGroup == null) {
123
                        return;
124
                    }
125

    
126
                    ((WFSParamsPanel) panelGroup).setApplicable(true);
127
                }
128
            });
129
        }
130
        return usernameText;
131
    }
132

    
133
    /**
134
     * This method initializes passwordText
135
     *
136
     * @return javax.swing.JTextField
137
     */
138
    private JPasswordField getPasswordText() {
139
        if (passwordText == null) {
140
            passwordText = new JPasswordField();
141
            passwordText.setBounds(new java.awt.Rectangle(100, 50, 200, 20));
142
            passwordText.addKeyListener(new java.awt.event.KeyAdapter() {
143
                public void keyTyped(java.awt.event.KeyEvent e) {
144
                    IPanelGroup panelGroup = getPanelGroup();
145

    
146
                    if (panelGroup == null) {
147
                        return;
148
                    }
149

    
150
                    ((WFSParamsPanel) panelGroup).setApplicable(true);
151
                }
152
            });
153
        }
154
        return passwordText;
155
    }
156

    
157
    /**
158
     * This method initializes jPanel
159
     *
160
     * @return javax.swing.JPanel
161
     */
162
    private JPanel getConnectionParamsPanel() {
163
        if (connectionParamsPanel == null) {
164
            java.awt.GridBagConstraints gridBagConstraints;
165

    
166
            bufferPanel = new JPanel();
167
            bufferLabel = new JLabel();
168
            bufferLabel.setText(PluginServices.getText(this, "max_features"));
169
            bufferLabel.setPreferredSize(new Dimension(90, 20));
170
            bufferPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
171
            bufferPanel.add(bufferLabel);
172
            bufferPanel.add(getMaxFeatSpinner());
173

    
174
            timeOutPanel = new JPanel();
175
            timeoutLabel = new JLabel();
176
            timeoutLabel.setText(PluginServices.getText(this, "timeout"));
177
            timeoutLabel.setPreferredSize(new Dimension(90, 20));
178
            timeOutPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
179
            timeOutPanel.add(timeoutLabel);
180
            timeOutPanel.add(getTimeoutCombo());
181
            // timeOutPanel.add(getJLabelMiliSeconds());
182

    
183
            connectionParamsPanel = new JPanel();
184
            connectionParamsPanel.setLayout(new java.awt.GridBagLayout());
185
            connectionParamsPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "conection"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
186

    
187
            gridBagConstraints = new java.awt.GridBagConstraints();
188
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
189
            gridBagConstraints.weightx = 1.0;
190
            connectionParamsPanel.add(bufferPanel, gridBagConstraints);
191

    
192
            gridBagConstraints = new java.awt.GridBagConstraints();
193
            gridBagConstraints.gridx = 0;
194
            gridBagConstraints.gridy = 1;
195
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
196
            gridBagConstraints.weightx = 1.0;
197
            connectionParamsPanel.add(timeOutPanel, gridBagConstraints);
198
        }
199

    
200
        return connectionParamsPanel;
201
    }
202

    
203
    private JSpinner getMaxFeatSpinner() {
204

    
205
        if (maxFeaturesSpinner == null) {
206
            SpinnerModel model = new SpinnerNumberModel(10000, 1, 1000000, 1);
207
            maxFeaturesSpinner = new JSpinner(model);
208
            // maxFeaturesSpinner.setBounds(new Rectangle(100, 25, 100, 20));
209
        }
210
        return maxFeaturesSpinner;
211
    }
212

    
213
    /**
214
     * This method initializes jTextField1
215
     *
216
     * @return javax.swing.JTextField
217
     */
218
    private JComboBox getTimeoutCombo() {
219
        if (timeoutCombo == null) {
220
            timeoutCombo = new JComboBox();
221
            timeoutCombo.setEditable(false);
222
            timeoutCombo.addItem("5 sec");
223
            timeoutCombo.addItem("20 sec");
224
            timeoutCombo.addItem("2 min");
225
            timeoutCombo.addItem("10 min");
226
            // timeoutCombo.setBounds(new Rectangle(100, 50, 100, 20));
227
            timeoutCombo.setToolTipText(PluginServices.getText(timeoutCombo, "set_TimeOut_Explanation"));
228
        }
229
        return timeoutCombo;
230
    }
231

    
232
    /**
233
     * Gets the name of the user.
234
     *
235
     * @return name of the user
236
     */
237
    public String getUserName() {
238
        return getUsernameText().getText();
239
    }
240

    
241
    public void setUserName(String userName) {
242
        getUsernameText().setText(userName);
243
    }
244

    
245
    /**
246
     * Gets the password of the user.
247
     *
248
     * @return password of the user
249
     */
250
    public String getPassword() {
251
        return getPasswordText().getText();
252
    }
253

    
254
    public void setPassword(String password) {
255
        getPasswordText().setText(password);
256
    }
257

    
258
    /**
259
     * Gets the maximum number of values that can load.
260
     *
261
     * @return the maximum number of values that can load
262
     */
263
    public int getBuffer() {
264
        try {
265
            Object val = getMaxFeatSpinner().getValue();
266
            return Integer.parseInt(val.toString());
267
        } catch (Exception e) {
268
            return 10000;
269
        }
270
    }
271

    
272
    public void setBuffer(int buffer) {
273
        try {
274
            getMaxFeatSpinner().setValue(buffer);
275
        } catch (Exception exc) {
276
            ApplicationLocator.getManager().messageDialog(
277
                    Messages.getText("_Unable_to_show_max_featcount"),
278
                    Messages.getText("error"),
279
                    JOptionPane.ERROR_MESSAGE);
280
        }
281
    }
282

    
283
    /**
284
     * Gets the timeout used during the loading process.
285
     *
286
     * @return the timeout used during the loading process
287
     */
288
    public int getTimeout() {
289

    
290
        String tou = this.getTimeoutCombo().getSelectedItem().toString();
291
        return toMilliseconds(tou);
292

    
293
    }
294

    
295
    public void setTimeOut(int timeOut) {
296
        int cnt = this.getTimeoutCombo().getItemCount();
297
        for (int i = 0; i < cnt; i++) {
298
            String aux = this.getTimeoutCombo().getItemAt(i).toString();
299
            if (timeOut == toMilliseconds(aux)) {
300
                this.getTimeoutCombo().setSelectedIndex(i);
301
                return;
302
            }
303
        }
304
        this.getTimeoutCombo().setSelectedIndex(1);
305
    }
306

    
307
    private int toMilliseconds(String txt) {
308

    
309
        try {
310
            String[] tt = txt.split(" ");
311
            int aux = Integer.parseInt(tt[0]);
312
            if (tt[1].compareToIgnoreCase("min") == 0) {
313
                aux = aux * 60;
314
            }
315
            return aux * 1000;
316
        } catch (Exception ex) {
317
            logger.info("Did not parse item. Timeout = " + DEFAULT_TIMEOUT_MILLISECONDS);
318
            return DEFAULT_TIMEOUT_MILLISECONDS;
319
        }
320
    }
321

    
322
    /**
323
     * Gets the reference system of the layer.
324
     *
325
     * @return the reference system of the layer
326
     */
327
    public String getSRS() {
328
        Object sel = getSrsCombo().getSelectedItem();
329
        if (sel == null) {
330
            String msg = Messages.getText("error")
331
                    + " (" + Messages.getText("srs") + ")";
332
            ApplicationLocator.getManager().message(
333
                    msg,
334
                    JOptionPane.ERROR_MESSAGE);
335
            return "";
336
        } else {
337
            return sel.toString();
338
        }
339
    }
340

    
341
    public boolean getUseAxisOrderYX() {
342
        return this.axisOrderYXCheckBox.isSelected();
343
    }
344

    
345
    public void setSRS(String srs) {
346
        getSrsCombo().setSelectedItem(srs);
347
        refreshAxisOrder();
348
    }
349

    
350
    public void setVersion(String str_ver) {
351
        getVersionCombo().setSelectedItem(str_ver);
352
    }
353

    
354
    /**
355
     * This method initializes formatPanel
356
     *
357
     * @return javax.swing.JPanel
358
     */
359
    private JPanel getFormatPanel() {
360
        if (formatPanel == null) {
361
            formatPanel = new JPanel();
362
            formatPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
363
            formatPanel.setBorder(BorderFactory.createTitledBorder(null,
364
                    PluginServices.getText(this, "srs"),
365
                    TitledBorder.DEFAULT_JUSTIFICATION,
366
                    TitledBorder.DEFAULT_POSITION, null, null));
367
            formatPanel.add(getSRSLabel());
368
            formatPanel.add(getSrsCombo());
369
        }
370
        return formatPanel;
371
    }
372

    
373
    /**
374
     * This method initializes srsLabel
375
     *
376
     * @return javax.swing.JLabel
377
     */
378
    private JLabel getSRSLabel() {
379
        if (srsLabel == null) {
380
            srsLabel = new JLabel();
381
            srsLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
382
            srsLabel.setText(PluginServices.getText(this, "srs"));
383
            srsLabel.setPreferredSize(new Dimension(90, 20));
384
        }
385

    
386
        return srsLabel;
387
    }
388

    
389
    private JLabel getVersionLabel() {
390
        if (verLabel == null) {
391
            verLabel = new JLabel();
392
            verLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
393
            verLabel.setText(PluginServices.getText(this, "_Version"));
394
            verLabel.setPreferredSize(new Dimension(90, 20));
395
        }
396
        return verLabel;
397
    }
398

    
399
    /**
400
     * This method initializes srsText
401
     *
402
     * @return javax.swing.JTextField
403
     */
404
    private JComboBox getSrsCombo() {
405
        if (srsCombo == null) {
406
            srsCombo = new JComboBox();
407
            // srsCombo.setBounds(new java.awt.Rectangle(110, 25, 100, 20));
408
            srsCombo.setEnabled(true);
409
            srsCombo.setEditable(false);
410
            srsCombo.setToolTipText(
411
                    PluginServices.getText(srsCombo, "select_Feature_Reference_System"));
412
        }
413
        return srsCombo;
414
    }
415

    
416
    private JComboBox getVersionCombo() {
417

    
418
        if (ver_Combo == null) {
419
            ver_Combo = new JComboBox();
420
            ver_Combo.setEnabled(true);
421
            ver_Combo.setEditable(false);
422
            ver_Combo.addActionListener(new ActionListener() {
423
                public void actionPerformed(ActionEvent ae) {
424
                    refreshAxisOrder();
425
                }
426
            });
427
        }
428
        return ver_Combo;
429
    }
430

    
431
    /**
432
     * Refresh the panel
433
     *
434
     * @param feature
435
     */
436
    public void refresh(WFSSelectedFeature layer) {
437

    
438
        Vector srs = layer.getSrs();
439
        Iterator iter = srs.iterator();
440
        JComboBox bx = this.getSrsCombo();
441
        bx.removeAllItems();
442
        while (iter.hasNext()) {
443
            bx.addItem(iter.next());
444
        }
445
        refreshAxisOrder();
446
    }
447

    
448
    private void refreshAxisOrder() {
449
        try {
450
            String version = this.getVersion();
451
            if (version != null && version.compareToIgnoreCase("1.1.0") >= 0) {
452
                String srs = this.getSRS();
453
                if( !StringUtils.isBlank(srs) ) {
454
                    IProjection proj = CRSFactory.getCRS(srs);
455
                    if (proj != null && !proj.isProjected()) {
456
                        this.axisOrderYXCheckBox.setSelected(true);
457
                    }
458
                }
459
            } else {
460
                this.axisOrderYXCheckBox.setSelected(false);
461
            }
462
        } catch (Exception ex) {
463
            logger.warn("Can't set axis order automatically", ex);
464
        }
465
    }
466

    
467
    public void refreshVersions(List vers) {
468
        Iterator iter = vers.iterator();
469
        JComboBox bx = this.getVersionCombo();
470
        bx.removeAllItems();
471
        while (iter.hasNext()) {
472
            bx.addItem(iter.next());
473
        }
474
        refreshAxisOrder();
475
    }
476

    
477
    /**
478
     * This method initializes jLabelMiliSeconds
479
     *
480
     * @return javax.swing.JLabel
481
     */
482
    /*
483
     public JLabel getJLabelMiliSeconds() {
484
     if (jLabelMiliSeconds == null) {
485
     jLabelMiliSeconds = new JLabel();
486
     jLabelMiliSeconds.setText(PluginServices.getText(jLabelMiliSeconds, "miliSeconds"));
487
     jLabelMiliSeconds.setBounds(new Rectangle(175, 50, 40, 16));
488
     }
489

490
     return jLabelMiliSeconds;
491
     }
492
     */
493
    private JPanel getCachePanel() {
494
        if (cachePanel == null) {
495
            cachePanel = new JPanel();
496
            cachePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
497
            cachePanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "vectorial_cache"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
498
            cachePanel.add(getEnableCacheCheckBox());
499
        }
500
        return cachePanel;
501
    }
502

    
503
    public JCheckBox getEnableCacheCheckBox() {
504
        if (enableCacheCheckBox == null) {
505
            enableCacheCheckBox = new JCheckBox();
506
            enableCacheCheckBox.setText(PluginServices.getText(null, "enable_cache"));
507
            enableCacheCheckBox.setBounds(new Rectangle(175, 50, 40, 16));
508
        }
509

    
510
        return enableCacheCheckBox;
511
    }
512

    
513
    private JPanel getAxisOrderPanel() {
514
        if (axisOrderPanel == null) {
515
            I18nManager i18nManager = ToolsLocator.getI18nManager();
516
            axisOrderPanel = new JPanel();
517
            axisOrderPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
518
            axisOrderPanel.setBorder(BorderFactory.createTitledBorder(
519
                    null,
520
                    i18nManager.getTranslation("_Axis_order"),
521
                    TitledBorder.DEFAULT_JUSTIFICATION,
522
                    TitledBorder.DEFAULT_POSITION,
523
                    null,
524
                    null
525
            ));
526
            axisOrderPanel.add(getAxisOrderYXCheckBox());
527
        }
528
        return axisOrderPanel;
529
    }
530

    
531
    public JCheckBox getAxisOrderYXCheckBox() {
532
        if (axisOrderYXCheckBox == null) {
533
            I18nManager i18nManager = ToolsLocator.getI18nManager();
534
            axisOrderYXCheckBox = new JCheckBox();
535
            axisOrderYXCheckBox.setText(i18nManager.getTranslation("_Use_axis_order_YX"));
536
            axisOrderYXCheckBox.setBounds(new Rectangle(175, 50, 40, 16));
537
        }
538

    
539
        return axisOrderYXCheckBox;
540
    }
541

    
542
    /*
543
     * (non-Javadoc)
544
     * @see com.iver.cit.gvsig.gui.panels.AbstractWFSPanel#initialize()
545
     */
546
    protected void initialize() {
547
        setLabel(PluginServices.getText(this, "options"));
548
        setLabelGroup(PluginServices.getText(this, "wfs"));
549
        this.setLayout(new java.awt.BorderLayout());
550
        java.awt.GridBagConstraints gridBagConstraints;
551

    
552
        northPanel = new JPanel();
553
        northPanel.setLayout(new java.awt.GridBagLayout());
554

    
555
        gridBagConstraints = new java.awt.GridBagConstraints();
556
        gridBagConstraints.gridx = 0;
557
        gridBagConstraints.gridy = 0;
558
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
559
        gridBagConstraints.weightx = 1.0;
560
        northPanel.add(getVersionPanel(), gridBagConstraints);
561

    
562
        gridBagConstraints = new java.awt.GridBagConstraints();
563
        gridBagConstraints.gridx = 0;
564
        gridBagConstraints.gridy = 1;
565
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
566
        gridBagConstraints.weightx = 1.0;
567
        northPanel.add(getConnectionParamsPanel(), gridBagConstraints);
568

    
569
        gridBagConstraints = new java.awt.GridBagConstraints();
570
        gridBagConstraints.gridx = 0;
571
        gridBagConstraints.gridy = 2;
572
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
573
        gridBagConstraints.weightx = 1.0;
574
        northPanel.add(getFormatPanel(), gridBagConstraints);
575

    
576
        gridBagConstraints = new java.awt.GridBagConstraints();
577
        gridBagConstraints.gridx = 0;
578
        gridBagConstraints.gridy = 3;
579
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
580
        gridBagConstraints.weightx = 1.0;
581
        northPanel.add(getCachePanel(), gridBagConstraints);
582

    
583
        gridBagConstraints = new java.awt.GridBagConstraints();
584
        gridBagConstraints.gridx = 0;
585
        gridBagConstraints.gridy = 4;
586
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
587
        gridBagConstraints.weightx = 1.0;
588
        northPanel.add(getAxisOrderPanel(), gridBagConstraints);
589

    
590
        add(northPanel, java.awt.BorderLayout.NORTH);
591
    }
592

    
593
    /**
594
     * @return
595
     */
596
    private Component getVersionPanel() {
597
        if (versionPanel == null) {
598
            versionPanel = new JPanel();
599
            versionPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
600
            versionPanel.setBorder(BorderFactory.createTitledBorder(null,
601
                    PluginServices.getText(this, "_WFS_protocol_version"),
602
                    TitledBorder.DEFAULT_JUSTIFICATION,
603
                    TitledBorder.DEFAULT_POSITION, null, null));
604
            versionPanel.add(getVersionLabel());
605
            versionPanel.add(getVersionCombo());
606
        }
607
        return versionPanel;
608
    }
609

    
610
    /**
611
     *
612
     * Returns the preferred CRS from a list. This is a utility and not very
613
     * elegant method used until the WFS wizard is able to show a combo with the
614
     * CRSs available in the server. Until then, we'll choose the CRS to prevent
615
     * issues with axis order
616
     *
617
     *
618
     * @param crs_list
619
     * @return
620
     * @deprecated
621
     */
622
    public static String getAxisOrderPreferredCrs(List crs_list) {
623

    
624
        if (crs_list == null || crs_list.size() == 0) {
625
            return "";
626
        }
627

    
628
        if (crs_list.size() == 1) {
629
            return crs_list.get(0).toString();
630
        }
631

    
632
        String item = null;
633
        IProjection ipro = null;
634

    
635
        for (int i = 0; i < crs_list.size(); i++) {
636
            item = crs_list.get(i).toString();
637
            try {
638
                ipro = CRSFactory.getCRS(item);
639
            } catch (Exception ex) {
640
                // Unable to parse CRS
641
                ipro = null;
642
            }
643
            if (ipro != null && ipro.isProjected()) {
644
                // If we find a projected one, return it
645
                return item;
646
            }
647
        }
648
        // If no CRS found, return first
649
        return crs_list.get(0).toString();
650
    }
651

    
652
    /**
653
     * @return
654
     */
655
    public String getVersion() {
656

    
657
        if (this.ver_Combo != null
658
                && this.ver_Combo.getSelectedItem() != null) {
659
            String v = this.ver_Combo.getSelectedItem().toString();
660
            return v;
661
        } else {
662
            // this should not happen
663
            return "-";
664
        }
665

    
666
    }
667
}