Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / General.java @ 11971

History | View | Annotate | Download (23.6 KB)

1
/*
2
 * Created on 31-ene-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.cit.gvsig.project.documents.view.legend.gui;
45

    
46
import java.awt.BorderLayout;
47
import java.text.NumberFormat;
48
import java.text.ParseException;
49

    
50
import javax.swing.ButtonGroup;
51
import javax.swing.DefaultComboBoxModel;
52
import javax.swing.JCheckBox;
53
import javax.swing.JComboBox;
54
import javax.swing.JLabel;
55
import javax.swing.JPanel;
56
import javax.swing.JRadioButton;
57
import javax.swing.JScrollPane;
58
import javax.swing.JTextArea;
59
import javax.swing.JTextField;
60

    
61
import org.apache.log4j.Logger;
62

    
63
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
64
import com.hardcode.gdbms.engine.data.DataSource;
65
import com.hardcode.gdbms.engine.data.driver.DriverException;
66
import com.iver.andami.PluginServices;
67
import com.iver.andami.messages.NotificationManager;
68
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
69
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition;
70
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
71
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
72
import com.iver.cit.gvsig.fmap.layers.FLayer;
73
import com.iver.cit.gvsig.fmap.layers.FLyrDefault;
74
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
75
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
76
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter;
77
import com.iver.cit.gvsig.fmap.layers.VectorialDBAdapter;
78
import com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter;
79
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
80
import com.iver.cit.gvsig.project.documents.view.IProjectView;
81
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
82
import com.iver.cit.gvsig.project.documents.view.legend.CreateSpatialIndexMonitorableTask;
83
import com.iver.utiles.swing.threads.IMonitorableTask;
84
/**
85
 * @author jmorell
86
 *
87
 * TODO To change the template for this generated type comment go to
88
 * Window - Preferences - Java - Code Style - Code Templates
89
 */
90
public class General extends AbstractThemeManagerPage {
91

    
92
        private static final long serialVersionUID = 1L;
93
    private static Logger logger = Logger.getLogger(VectorialUniqueValue.class.getName());
94
        private FLayer layer;
95
    //private ComandosListener actionListener = new ComandosListener(this);
96
        private IProjectView view;
97
        private NumberFormat nf = NumberFormat.getInstance();
98

    
99
        private JPanel jPanel = null;
100
        private JPanel jPanel1 = null;
101
        private JPanel jPanel2 = null;
102
        private JPanel jPanel4 = null;
103
        private JPanel jPanel5 = null;
104
        private JLabel jLabel = null;
105
        private JTextField txtLayerName = null;
106
        private JLabel jLabel1 = null;
107
        private JTextField jTextField1 = null;
108
        private JLabel jLabel2 = null;
109
        private JTextArea jTextArea = null;
110
        private JScrollPane jScrollPane = null;
111
        private ButtonGroup buttonGroup = null;
112
        private JRadioButton jRadioButton = null;
113
        private JRadioButton jRadioButton1 = null;
114
        private JLabel jLabel3 = null;
115
        private JTextField txtMinScale = null;
116
        private JLabel jLabel4 = null;
117
        private JPanel jPanel3 = null;
118
    private JPanel jPanel6 = null;
119
    private JPanel jPanel7 = null;
120
    private JPanel jPanel8 = null;
121
    private JLabel jLabel5 = null;
122
    private JComboBox jComboBox = null;
123
    private JLabel jLabel6 = null;
124
    private JTextField jTextField = null;
125
    private JLabel jLabel7 = null;
126
    private JComboBox jComboBox1 = null;
127
    private JCheckBox jCheckBoxSpatialIndex = null;
128

    
129
    /**
130
         * This is the default constructor
131
         */
132
        public General() {
133
                super();
134
                initialize();
135
        }
136
        /**
137
         * This method initializes this
138
         *
139
         * @return void
140
         */
141
        private  void initialize() {
142
                //setView();
143
                this.setLayout(null);
144
                //this.setLayer(null);
145
                this.setBounds(0, 0, 635, 352);
146
                this.add(getJCheckBoxSpatialIndex(), null);
147
                this.add(getJPanel(), null);
148
                this.add(getJPanel1(), null);
149
                this.add(getJPanel2(), null);
150
                this.add(getJPanel3(), null);
151
        }
152

    
153

    
154
        private void fillFieldNames() {
155
                DataSource rs;
156
                try {
157
                        rs = ((AlphanumericData)layer).getRecordset();
158
                        logger.debug("rs.start()");
159
                        rs.start();
160
                        String[] nomFields = new String[rs.getFieldCount()];
161
                        for (int i = 0; i < rs.getFieldCount(); i++) {
162
                                nomFields[i] = rs.getFieldName(i).trim();
163
                        }
164
                        rs.stop();
165
                } catch (ReadDriverException e) {
166
                        e.printStackTrace();
167
                }
168
        }
169

    
170
        public void setModel(FLayer layer) {
171
                this.layer = layer;
172
        if (layer instanceof FLyrVect) {
173
            FLyrVect lyrVect = (FLyrVect) layer;
174

    
175
            if(lyrVect.getISpatialIndex() == null) {
176
                getJCheckBoxSpatialIndex().setSelected(false);
177
            } else {
178
                getJCheckBoxSpatialIndex().setSelected(true);
179
            }
180
        }
181
                if (layer.getMinScale() != -1)
182
                    getTxtMaxScale().setText(nf.format(layer.getMinScale()));
183
                if (layer.getMaxScale() != -1)
184
                    getTxtMinScale().setText(nf.format(layer.getMaxScale()));
185
                if (layer.getMinScale() == -1 && layer.getMaxScale() == -1) {
186
                        getJRadioButton().setSelected(true);
187
                        jLabel1.setEnabled(false);
188
                        jTextField1.setEnabled(false);
189
                        jLabel2.setEnabled(false);
190
                        jLabel3.setEnabled(false);
191
                        txtMinScale.setEnabled(false);
192
                        jLabel4.setEnabled(false);
193
                } else {
194
                        getJRadioButton1().setSelected(true);
195
                        jLabel1.setEnabled(true);
196
                        jTextField1.setEnabled(true);
197
                        jLabel2.setEnabled(true);
198
                        jLabel3.setEnabled(true);
199
                        txtMinScale.setEnabled(true);
200
                        jLabel4.setEnabled(true);
201
                }
202
                fillFieldNames();
203
                txtLayerName.setText(layer.getName());
204
                showLayerInfo();
205

    
206
                if (PluginServices.getMainFrame() != null)
207
                if  (PluginServices.getMDIManager().getActiveWindow() instanceof BaseView ){
208
                    BaseView theView = (BaseView)PluginServices.getMDIManager().getActiveWindow();
209
                    view = theView.getModel();
210
            try {
211
                if (layer instanceof AlphanumericData) {
212
                    AlphanumericData ad = (AlphanumericData) layer;
213
                    DataSource ds;
214
                    ds = ad.getRecordset();
215
                    String[] names = new String[ds.getFieldCount()];
216
                    for (int i = 0; i < ds.getFieldCount(); i++) {
217
                        names[i] = ds.getFieldName(i);
218
                    }
219
                    //jComboBox = new javax.swing.JComboBox(names);
220
                    DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(names);
221
                    jComboBox.setModel(defaultModel);
222
                    if (view.getSelectedField() != null) {
223
                        jComboBox.setSelectedItem(view.getSelectedField());
224
                    }
225
                }else{
226
                    jComboBox = new javax.swing.JComboBox();
227
                }
228
             } catch (ReadDriverException e) {
229
                NotificationManager.addError("No se pudo obtener la tabla", e);
230
            }
231

    
232
            if (view.getSelectedField() != null) {
233
                getJTextField().setText(view.getExtLink());
234
            }
235

    
236
            getJComboBox1().addItem(PluginServices.getText(this,
237
                    "Enlazar_a_ficheros_de_imagen"));
238
            getJComboBox1().addItem(PluginServices.getText(this,
239
            "Enlazar_a_fichero_de_texto"));
240
            if (view.getSelectedField() != null) {
241
                getJComboBox1().setSelectedIndex(view.getTypeLink());
242
            }
243
                }
244
        }
245

    
246
        /**
247
         * This method initializes jPanel
248
         *
249
         * @return javax.swing.JPanel
250
         */
251
        private JPanel getJPanel() {
252
                if (jPanel == null) {
253
                        jLabel = new JLabel();
254
                        jPanel = new JPanel();
255
                        jPanel.setLayout(null);
256
                        jLabel.setText(PluginServices.getText(this,"Nombre") + ":");
257
                        jLabel.setComponentOrientation(java.awt.ComponentOrientation.UNKNOWN);
258
                        jLabel.setBounds(0, 3, 78, 15);
259
                        jPanel.setComponentOrientation(java.awt.ComponentOrientation.UNKNOWN);
260
                        jPanel.setLocation(5, 6);
261
                        jPanel.setSize(357, 20);
262
                        jPanel.add(jLabel, null);
263
                        jPanel.add(getTxtLayerName(), null);
264
                }
265
                return jPanel;
266
        }
267
        /**
268
         * This method initializes jPanel1
269
         *
270
         * @return javax.swing.JPanel
271
         */
272
        private JPanel getJPanel1() {
273
                if (jPanel1 == null) {
274
                        jPanel1 = new JPanel();
275
                        jPanel1.setLayout(null);
276
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"rango_de_escalas"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
277
                        jPanel1.setBounds(5, 61, 432, 137);
278
                        jPanel1.add(getJPanel4(), null);
279
                        jPanel1.add(getJPanel5(), null);
280
                }
281
                return jPanel1;
282
        }
283
        /**
284
         * This method initializes jPanel2
285
         *
286
         * @return javax.swing.JPanel
287
         */
288
        private JPanel getJPanel2() {
289
                if (jPanel2 == null) {
290
                        jPanel2 = new JPanel();
291
                        jPanel2.setLayout(null);
292
                        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"propiedades"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
293
                        jPanel2.setBounds(5, 196, 303, 155);
294
                        jPanel2.add(getJScrollPane(), null);
295
                }
296
                return jPanel2;
297
        }
298
        /**
299
         * This method initializes jPanel4
300
         *
301
         * @return javax.swing.JPanel
302
         */
303
        private JPanel getJPanel4() {
304
                if (jPanel4 == null) {
305
                        jPanel4 = new JPanel();
306
                        jPanel4.setLayout(null);
307
                        jPanel4.setBounds(6, 21, 398, 46);
308
                        jPanel4.add(getJRadioButton(), null);
309
                        jPanel4.add(getJRadioButton1(), null);
310
                        buttonGroup = new ButtonGroup();
311
                        buttonGroup.add(getJRadioButton());
312
                        buttonGroup.add(getJRadioButton1());
313
                }
314
                return jPanel4;
315
        }
316
        /**
317
         * This method initializes jPanel5
318
         *
319
         * @return javax.swing.JPanel
320
         */
321
        private JPanel getJPanel5() {
322
                if (jPanel5 == null) {
323
                        jLabel4 = new JLabel();
324
                        jLabel3 = new JLabel();
325
                        jLabel2 = new JLabel();
326
                        jLabel1 = new JLabel();
327
                        jPanel5 = new JPanel();
328
                        jPanel5.setLayout(null);
329
                        jLabel1.setText(PluginServices.getText(this,"este_por_debajo_de_"));
330
                        jLabel1.setBounds(6, 6, 138, 20);
331
                        jLabel1.setEnabled(false);
332
                        jLabel2.setText("(" + PluginServices.getText(this,"escala_minima") + ")");
333
                        jLabel2.setBounds(302, 6, 111, 20);
334
                        jLabel2.setEnabled(false);
335
                        jPanel5.setBounds(15, 69, 414, 53);
336
                        jLabel3.setBounds(6, 31, 138, 20);
337
                        jLabel3.setText(PluginServices.getText(this,"este_por_encima_de"));
338
                        jLabel3.setEnabled(false);
339
                        jLabel4.setBounds(302, 31, 111, 20);
340
                        jLabel4.setText("(" + PluginServices.getText(this,"escala_maxima") + ")");
341
                        jLabel4.setEnabled(false);
342
                        jPanel5.add(jLabel1, null);
343
                        jPanel5.add(getTxtMaxScale(), null);
344
                        jPanel5.add(jLabel2, null);
345
                        jPanel5.add(jLabel3, null);
346
                        jPanel5.add(getTxtMinScale(), null);
347
                        jPanel5.add(jLabel4, null);
348
                }
349
                return jPanel5;
350
        }
351
        /**
352
         * This method initializes jTextField
353
         *
354
         * @return javax.swing.JTextField
355
         */
356
        private JTextField getTxtLayerName() {
357
                if (txtLayerName == null) {
358
                        //System.out.println("getJTestField(): layer = " + layer);
359
                        //layerName = layer.getName();
360
                        txtLayerName = new JTextField();
361
                        //jTextField.setText(layerName);
362
                        txtLayerName.setEditable(true);
363
                        txtLayerName.setBounds(80, 0, 229, 20);
364
                }
365
                return txtLayerName;
366
        }
367

    
368
        private JTextField getTxtMaxScale() {
369
                if (jTextField1 == null) {
370
                        jTextField1 = new JTextField();
371
                        jTextField1.setBounds(147, 6, 152, 20);
372
                        jTextField1.setEnabled(false);
373
                }
374
                return jTextField1;
375
        }
376

    
377
        private JTextArea getJTextArea() {
378
                if (jTextArea == null) {
379
                        jTextArea = new JTextArea();
380
                        jTextArea.setEditable(false);
381
                        jTextArea.setBackground(java.awt.SystemColor.control);
382
                        //jTextArea.setText("Extent\n\tSuperior\n\tInferior\n\tIzquierda\n\tDerecha\n\nOrigen de datos\n\n... y movidas ...");
383
                }
384
                return jTextArea;
385
        }
386

    
387
        /*public void setLayer(FLayer layer) {
388
                this.layer = layer;
389
        }*/
390
        /**
391
         * This method initializes jScrollPane
392
         *
393
         * @return javax.swing.JScrollPane
394
         */
395
        private JScrollPane getJScrollPane() {
396
                if (jScrollPane == null) {
397
                        jScrollPane = new JScrollPane();
398
                        jScrollPane.setViewportView(getJTextArea());
399
                        jScrollPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
400
                        jScrollPane.setPreferredSize(new java.awt.Dimension(100,100));
401
                        jScrollPane.setBounds(6, 21, 283, 120);
402
                }
403
                return jScrollPane;
404
        }
405
        /**
406
         * This method initializes jRadioButton
407
         *
408
         * @return javax.swing.JRadioButton
409
         */
410
        private JRadioButton getJRadioButton() {
411
                if (jRadioButton == null) {
412
                        jRadioButton = new JRadioButton();
413
                        jRadioButton.setText(PluginServices.getText(this,"Mostrar_siempre"));
414
                        jRadioButton.setBounds(0, 0, 301, 23);
415
                        jRadioButton.setSelected(true);
416
                        jRadioButton.addActionListener(new java.awt.event.ActionListener() {
417
                                public void actionPerformed(java.awt.event.ActionEvent e) {
418
                                        //jPanel5.setEnabled(false);
419
                                        jLabel1.setEnabled(false);
420
                                        jTextField1.setEnabled(false);
421
                                        jLabel2.setEnabled(false);
422
                                        jLabel3.setEnabled(false);
423
                                        txtMinScale.setEnabled(false);
424
                                        jLabel4.setEnabled(false);
425
                                }
426
                        });
427
                }
428
                return jRadioButton;
429
        }
430
        /**
431
         * This method initializes jRadioButton1
432
         *
433
         * @return javax.swing.JRadioButton
434
         */
435
        private JRadioButton getJRadioButton1() {
436
                if (jRadioButton1 == null) {
437
                        jRadioButton1 = new JRadioButton();
438
                        jRadioButton1.setText(PluginServices.getText(this,"No_mostrar_la_capa_cuando_la_escala"));
439
                        jRadioButton1.setBounds(0, 23, 301, 23);
440
                        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
441
                                public void actionPerformed(java.awt.event.ActionEvent e) {
442
                                        //jPanel5.setEnabled(true);
443
                                        jLabel1.setEnabled(true);
444
                                        jTextField1.setEnabled(true);
445
                                        jLabel2.setEnabled(true);
446
                                        jLabel3.setEnabled(true);
447
                                        txtMinScale.setEnabled(true);
448
                                        jLabel4.setEnabled(true);
449
                                }
450
                        });
451
                }
452
                return jRadioButton1;
453
        }
454
        /**
455
         * This method initializes jTextField2
456
         *
457
         * @return javax.swing.JTextField
458
         */
459
        private JTextField getTxtMinScale() {
460
                if (txtMinScale == null) {
461
                        txtMinScale = new JTextField();
462
                        txtMinScale.setBounds(147, 31, 152, 20);
463
                        txtMinScale.setEnabled(false);
464
                }
465
                return txtMinScale;
466
        }
467

    
468
        private String getLayerName(){
469
                return txtLayerName.getText().toString();
470
        }
471
    /**
472
     * This method initializes jPanel3
473
     *
474
     * @return javax.swing.JPanel
475
     */
476
    private JPanel getJPanel3() {
477
            if (jPanel3 == null) {
478
                    jPanel3 = new JPanel();
479
                    jPanel3.setLayout(null);
480
                    jPanel3.setBounds(315, 195, 313, 154);
481
                    jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED), PluginServices.getText(this, "Hiperenlace"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
482
                    jPanel3.add(getJPanel6(), null);
483
            }
484
            return jPanel3;
485
    }
486
    /**
487
     * This method initializes jPanel6
488
     *
489
     * @return javax.swing.JPanel
490
     */
491
    private JPanel getJPanel6() {
492
            if (jPanel6 == null) {
493
                    jPanel6 = new JPanel();
494
                    jPanel6.setLayout(new BorderLayout());
495
                    jPanel6.setBounds(7, 22, 298, 119);
496
                    jPanel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
497
                    jPanel6.add(getJPanel7(), java.awt.BorderLayout.NORTH);
498
                    jPanel6.add(getJPanel8(), java.awt.BorderLayout.CENTER);
499
            }
500
            return jPanel6;
501
    }
502
    /**
503
     * This method initializes jPanel7
504
     *
505
     * @return javax.swing.JPanel
506
     */
507
    private JPanel getJPanel7() {
508
            if (jPanel7 == null) {
509
                    jLabel6 = new JLabel();
510
                    jLabel6.setText(PluginServices.getText(this,"extension"));
511
                    jLabel5 = new JLabel();
512
                    jLabel5.setText(PluginServices.getText(this, "Campo") + "   ");
513
                    jPanel7 = new JPanel();
514
                    jPanel7.add(jLabel5, null);
515
                    jPanel7.add(getJComboBox(), null);
516
                    jPanel7.add(jLabel6, null);
517
                    jPanel7.add(getJTextField(), null);
518
            }
519
            return jPanel7;
520
    }
521
    /**
522
     * This method initializes jPanel8
523
     *
524
     * @return javax.swing.JPanel
525
     */
526
    private JPanel getJPanel8() {
527
            if (jPanel8 == null) {
528
                    jLabel7 = new JLabel();
529
                    jLabel7.setText(PluginServices.getText(this, "Accion_Predefinida") + "  ");
530
                    jPanel8 = new JPanel();
531
                    jPanel8.add(jLabel7, null);
532
                    jPanel8.add(getJComboBox1(), null);
533
            }
534
            return jPanel8;
535
    }
536
    /**
537
     * This method initializes jComboBox
538
     *
539
     * @return javax.swing.JComboBox
540
     */
541
    private JComboBox getJComboBox() {
542
            if (jComboBox == null) {
543
            jComboBox = new JComboBox();
544
            }
545
            return jComboBox;
546
    }
547
    /**
548
     * This method initializes jTextField
549
     *
550
     * @return javax.swing.JTextField
551
     */
552
    private JTextField getJTextField() {
553
            if (jTextField == null) {
554
                    jTextField = new JTextField();
555
            jTextField.setPreferredSize(new java.awt.Dimension(40,20));
556
            }
557
            return jTextField;
558
    }
559
    /**
560
     * This method initializes jComboBox1
561
     *
562
     * @return javax.swing.JComboBox
563
     */
564
    private JComboBox getJComboBox1() {
565
            if (jComboBox1 == null) {
566
                    jComboBox1 = new JComboBox();
567
            }
568
            return jComboBox1;
569
    }
570
    /**
571
     * @return Returns the view.
572
     */
573
    private IProjectView getView() {
574
        return view;
575
    }
576
    /**
577
     * This method initializes jCheckBox
578
     *
579
     * @return javax.swing.JCheckBox
580
     */
581
    private JCheckBox getJCheckBoxSpatialIndex() {
582
            if (jCheckBoxSpatialIndex == null) {
583
                    jCheckBoxSpatialIndex = new JCheckBox();
584
                    jCheckBoxSpatialIndex.setBounds(2, 33, 242, 23);
585
                    jCheckBoxSpatialIndex.setText(PluginServices.getText(this,"Usar_indice_espacial"));
586
            }
587
            return jCheckBoxSpatialIndex;
588
    }
589

    
590
    private int getLinkType() {
591
        return getJComboBox1().getSelectedIndex();
592
    }
593

    
594
    private String getSelectedLinkField() {
595
        return (String) getJComboBox().getSelectedItem();
596
    }
597

    
598
    private String getExtensionLink() {
599
        return getJTextField().getText();
600
    }
601

    
602
    private boolean isSpatialIndexSelected() {
603
        return getJCheckBoxSpatialIndex().isSelected();
604
    }
605

    
606
    private void showLayerInfo() {
607
                try {
608
                        String info = ((FLyrDefault)layer).getInfoString();
609
                        if (info == null) {
610
                                info = PluginServices.getText(this,"Extent") + "\n\t" +
611
                                PluginServices.getText(this,"Superior") + ":\t" + layer.getFullExtent().getMaxY() + "\n\t" +
612
                                PluginServices.getText(this,"Inferior") + ":\t" + layer.getFullExtent().getMinY() + "\n\t" +
613
                                PluginServices.getText(this,"Izquierda") + ":\t" + layer.getFullExtent().getMinX() + "\n\t" +
614
                                PluginServices.getText(this,"Derecha") + ":\t" + layer.getFullExtent().getMaxX() + "\n\n";
615

    
616
                                if (layer instanceof FLyrVect) {
617
                                        ReadableVectorial rv=((FLyrVect)layer).getSource();
618
                                        if (rv instanceof VectorialEditableAdapter) {
619
                                                rv=((VectorialEditableAdapter) ((FLyrVect)layer).getSource()).getOriginalAdapter();
620
                                        }
621

    
622
                                        info = info + PluginServices.getText(this,"Origen_de_datos") + ": ";
623
                                        if (rv instanceof VectorialFileAdapter) {
624
                                                info = info + "\n" + rv.getDriver().getName() + "\n" +
625
                                                PluginServices.getText(this,"fichero") +": " + ((VectorialFileAdapter)rv).getFile();
626

    
627
                                        } else if (rv instanceof VectorialDBAdapter) {
628
                                                DBLayerDefinition dbdef = ((VectorialDBAdapter) rv).getLyrDef();
629
                                                info = info + "\n" + rv.getDriver().getName() + "\n";
630

    
631
                                                try {
632
                                                        info = info +
633
                                                        PluginServices.getText(this,"url") +": " + dbdef.getConnection().getURL() + "\n";
634
                                                } catch (Exception e) {
635
                                                        //TODO: Que hacer aqui?
636
                                                        e.printStackTrace();
637
                                                }
638

    
639
                                                info = info +
640
                                                PluginServices.getText(this,"Tabla") +": " + dbdef.getTableName() + "\n";
641
                                        } else if (rv instanceof VectorialAdapter){
642
                                                info = info + "\n" + rv.getDriver().getName() + "\n";
643
                                        }
644

    
645

    
646

    
647
                                } else {
648
                                        info = info + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName();
649
                                }
650

    
651
                        }
652
                        getJTextArea().setText(info);
653

    
654
                } catch (ReadDriverException e) {
655
                        NotificationManager.addError(e.getMessage(), e);
656
                } catch (ExpansionFileReadException e) {
657
                        NotificationManager.addError(e.getMessage(), e);
658
                }
659

    
660
    }
661

    
662
        private boolean isScaleActive() {
663
                return getJRadioButton1().isSelected();
664
        }
665

    
666
    /**
667
     * Instanciates a ITask (@see com.iver.utiles.swing.threads.ITask)
668
     * to create a spatial index for the selected layer in background.
669
     * This task also allow to monitor process evolution, and to cancel
670
     * this process.
671
     * @throws DriverException
672
     * @throws DriverIOException
673
     */
674
    private IMonitorableTask getCreateSpatialIndexTask() throws ReadDriverException {
675
            // FIXME REVISAR ESTO (Quizas lanzar TaskException)
676
            return new CreateSpatialIndexMonitorableTask((FLyrVect)layer);
677
    }
678

    
679
        public void acceptAction() {
680
             // Implementaci?n para hacer funcionar el hyperlink ...
681
        //com.iver.cit.gvsig.gui.View theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView();
682
        //ProjectView view = theView.getModel();
683
            if (PluginServices.getMainFrame() != null)
684
            {
685
                    IProjectView view = getView();
686
                    view.setTypeLink(getLinkType());
687
                    if (getSelectedLinkField()!=null)
688
                    {
689
                            view.setSelectedField(getSelectedLinkField().toString().trim());
690
                            view.setExtLink(getExtensionLink());
691
                    }
692
            }
693
        }
694

    
695
        public void cancelAction() {
696
                // does nothing
697
        }
698

    
699
        public void applyAction() {
700
                if (isScaleActive()) {
701
                        try        {
702
                                layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue());
703
                        } catch (ParseException ex)        {
704
                            if (getTxtMaxScale().getText().compareTo("") == 0)
705
                                layer.setMinScale(-1);
706
                            else
707
                                System.err.print(ex.getLocalizedMessage());
708
                        }
709

    
710
                        try        {
711
                            layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue());
712
                        } catch (ParseException ex)        {
713
                            if (getTxtMinScale().getText().compareTo("") == 0)
714
                                layer.setMaxScale(-1);
715
                            else
716
                                System.err.print(ex.getLocalizedMessage());
717
                        }
718

    
719
                } else {
720
                layer.setMinScale(-1);
721
                layer.setMaxScale(-1);
722
                }
723

    
724
                if (!getLayerName().equals(layer.getName())){
725
                        layer.setName(getLayerName());
726
                }
727

    
728
        if (layer instanceof FLyrVect){
729
            FLyrVect lyrVect = (FLyrVect) layer;
730
            if (isSpatialIndexSelected()) {
731
                    if(lyrVect.getISpatialIndex() == null) {
732
                        //AZABALA
733
                        try {
734
                                                PluginServices.
735
                                                        cancelableBackgroundExecution(getCreateSpatialIndexTask());
736
                                        } catch (ReadDriverException e) {
737
                                                // TODO Auto-generated catch block
738
                                                NotificationManager.addError(e.getMessage(), e);
739
                                        }
740
                }
741
            }
742
            //AZABALA
743
            /*
744
             * If we unselect the spatial index checkbox...Must we delete
745
             * spatial index file, or we only have to put Spatial Index
746
             * reference to null?. I have followed the second choice
747
             */
748
            else{
749
                lyrVect.deleteSpatialIndex();
750
            }
751

    
752

    
753
        }
754
        }
755

    
756
        public String getName() {
757
                return PluginServices.getText(this,"General");
758
        }
759
}  //  @jve:decl-index=0:visual-constraint="10,10"
760