Statistics
| Revision:

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

History | View | Annotate | Download (25.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.awt.ComponentOrientation;
48
import java.awt.Dimension;
49
import java.awt.FlowLayout;
50
import java.awt.GridBagConstraints;
51
import java.awt.GridBagLayout;
52
import java.awt.Insets;
53
import java.awt.SystemColor;
54
import java.awt.event.ActionEvent;
55
import java.awt.event.ActionListener;
56
import java.awt.geom.Rectangle2D;
57
import java.text.NumberFormat;
58
import java.text.ParseException;
59

    
60
import javax.swing.BorderFactory;
61
import javax.swing.ButtonGroup;
62
import javax.swing.JCheckBox;
63
import javax.swing.JComboBox;
64
import javax.swing.JLabel;
65
import javax.swing.JPanel;
66
import javax.swing.JRadioButton;
67
import javax.swing.JScrollPane;
68
import javax.swing.JTextArea;
69
import javax.swing.JTextField;
70
import javax.swing.border.BevelBorder;
71
import javax.swing.border.EtchedBorder;
72
import javax.swing.border.TitledBorder;
73

    
74
import org.cresques.cts.ICoordTrans;
75
import org.cresques.cts.IProjection;
76
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
77
import org.gvsig.gui.beans.swing.JBlank;
78

    
79
import com.hardcode.driverManager.Driver;
80
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
81
import com.hardcode.gdbms.engine.data.driver.DriverException;
82
import com.iver.andami.PluginServices;
83
import com.iver.andami.messages.NotificationManager;
84
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition;
85
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
86
import com.iver.cit.gvsig.fmap.drivers.dbf.DBFDriver;
87
import com.iver.cit.gvsig.fmap.drivers.shp.IndexedShpDriver;
88
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
89
import com.iver.cit.gvsig.fmap.layers.FLayer;
90
import com.iver.cit.gvsig.fmap.layers.FLyrDefault;
91
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
92
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
93
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter;
94
import com.iver.cit.gvsig.fmap.layers.VectorialDBAdapter;
95
import com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter;
96
import com.iver.cit.gvsig.project.documents.view.IProjectView;
97
import com.iver.cit.gvsig.project.documents.view.legend.CreateSpatialIndexMonitorableTask;
98
import com.iver.utiles.swing.threads.IMonitorableTask;
99

    
100

    
101

    
102
/**
103
 * This class implements an useful and intuitive graphic interface to change some
104
 * properties of the layer. This class extends AbstractThemeManager. The properties
105
 * that allow modified are the name of the layer, the scale, if the user want to use
106
 * Spatial index or not and the HyperLink. Also shows a scroll with a little resume
107
 * with the properties of the layer.
108
 * @author jmorell
109
 *
110
 * TODO To change the template for this generated type comment go to
111
 * Window - Preferences - Java - Code Style - Code Templates
112
 */
113
public class General extends AbstractThemeManagerPage {
114

    
115
        private static final long serialVersionUID = 1L;
116
    private FLayer layer;
117
        private IProjectView view;
118
        private NumberFormat nf = NumberFormat.getInstance();
119
        private JPanel pnlLayerName = null;
120
        private GridBagLayoutPanel pnlScale = null;
121
        private JPanel pnlProperties = null;
122
        private JLabel lblLayerName = null;
123
        private JTextField txtLayerName = null;
124
        private JTextField txtMaxScale = null;
125
        private JTextArea propertiesTextArea = null;
126
        private JRadioButton rdBtnShowAlways = null;
127
        private JRadioButton rdBtnDoNotShow = null;
128
        private JTextField txtMinScale = null;
129
        private JComboBox cmbLinkField = null;
130
    private JTextField txtLinkExtension = null;
131
    private JComboBox cmbLinkType = null;
132
    private JCheckBox jCheckBoxSpatialIndex = null;
133
        private JPanel pnlHyperLink;
134
        private JLabel lblLinkExtension;
135
        private JLabel lblLinkField;
136
        private JLabel lblDefaultAction;
137
        private JPanel pnlFieldAndExtension;
138
        private JPanel pnlHyperLinkAction;
139
        private JScrollPane scrlProperties;
140

    
141
    /**
142
         * This is the default constructor.
143
         */
144
        public General() {
145
                super();
146
                initialize();
147
        }
148
        /**
149
         * This method initializes this
150
         *
151
         * @return void
152
         */
153
        private  void initialize() {
154
                this.setLayout(new BorderLayout());
155
                GridBagLayoutPanel aux = new GridBagLayoutPanel();
156
                aux.addComponent(getPnlLayerName());
157
                aux.addComponent(new JBlank(10, 10));
158
                aux.addComponent(getJCheckBoxSpatialIndex());
159
                aux.addComponent("", getPnlScale());
160
//                JPanel aux2 = new JPanel(new GridLayout(1,1));
161
//                aux2.add(getPnlProperties());
162
//                aux2.add(getPnlHyperLink());
163
//                aux.addComponent("", aux2);
164

    
165
                aux.addComponent("", getPnlProperties());
166

    
167

    
168

    
169
                aux.setPreferredSize(getPreferredSize());
170
                this.add(aux, BorderLayout.CENTER);
171
                this.add(new JBlank(5, 10), BorderLayout.WEST);
172
                this.add(new JBlank(5, 10), BorderLayout.EAST);
173

    
174
        }
175

    
176

    
177
        /**
178
         * Sets the necessary properties in the panel. This properties are
179
         * extracted from the layer. With this properties fills the TextFields,
180
         * ComboBoxes and the rest of GUI components.
181
         * @param FLayer layer,
182
         */
183
        public void setModel(FLayer layer) {
184
                this.layer = layer;
185

    
186
        if (layer instanceof FLyrVect) {
187
            FLyrVect lyrVect = (FLyrVect) layer;
188

    
189

    
190
            if(lyrVect.getISpatialIndex() == null) {
191
                getJCheckBoxSpatialIndex().setSelected(false);
192
            } else {
193
                getJCheckBoxSpatialIndex().setSelected(true);
194
            }
195
        }
196
                if (layer.getMinScale() != -1)
197
                    getTxtMaxScale().setText(nf.format(layer.getMinScale()));
198
                if (layer.getMaxScale() != -1)
199
                    getTxtMinScale().setText(nf.format(layer.getMaxScale()));
200
                if (layer.getMinScale() == -1 && layer.getMaxScale() == -1) {
201
                        getRdBtnShowAlways().setSelected(true);
202
                        txtMaxScale.setEnabled(false);
203
                        txtMinScale.setEnabled(false);
204

    
205
                } else {
206
                        getRdBtnDoNotShowWhen().setSelected(true);
207
                        txtMaxScale.setEnabled(true);
208
                        txtMinScale.setEnabled(true);
209
                }
210
                txtLayerName.setText(layer.getName());
211
                showLayerInfo();
212

    
213

    
214
                // old hyperlink stuff
215
//                if (PluginServices.getMainFrame() != null)
216
//                if  (PluginServices.getMDIManager().getActiveWindow() instanceof BaseView ){
217
//                    BaseView theView = (BaseView)PluginServices.getMDIManager().getActiveWindow();
218
//                    view = theView.getModel();
219
//            try {
220
//                if (layer instanceof AlphanumericData) {
221
//                    AlphanumericData ad = (AlphanumericData) layer;
222
//                    DataSource ds;
223
//                    ds = ad.getRecordset();
224
//                    String[] names = new String[ds.getFieldCount()];
225
//                    for (int i = 0; i < ds.getFieldCount(); i++) {
226
//                        names[i] = ds.getFieldName(i);
227
//                    }
228
//                    DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(names);
229
//                    cmbLinkField.setModel(defaultModel);
230
//
231
//                    if (layer.getLinkProperties().getField()!=null)
232
//                            cmbLinkField.setSelectedItem(layer.getLinkProperties().getField());
233
//                    else
234
//                            cmbLinkField.setSelectedItem(view.getSelectedField());
235
//                } else {
236
//                    cmbLinkField = new JComboBox();
237
//                }
238
//             } catch (ReadDriverException e) {
239
//                NotificationManager.addError("No se pudo obtener la tabla", e);
240
//            }
241
//
242
//
243
//            if(layer.getLinkProperties().getExt()!=null)
244
//                    getTxtLinkExtension().setText(layer.getLinkProperties().getExt());
245
//
246
//            getCmbLinkType().addItem(PluginServices.getText(this,
247
//                       "Enlazar_a_ficheros_de_imagen"));
248
//            getCmbLinkType().addItem(PluginServices.getText(this,
249
//                    "Enlazar_a_fichero_de_texto"));
250
//
251
//            getCmbLinkType().addItem(PluginServices.getText(this,
252
//                    "Enlazar_a_documento_PDF"));
253
//            getCmbLinkType().addItem(PluginServices.getText(this,
254
//                        "Enlazar_a_imagen_SVG"));
255
//
256
//            if (layer.getLinkProperties().getType()!=-1)
257
//                    getCmbLinkType().setSelectedIndex(layer.getLinkProperties().getType());
258
//
259
//                }
260

    
261
        }
262

    
263
        /**
264
         * This method initializes jPanel
265
         *
266
         * @return javax.swing.JPanel
267
         */
268
        private JPanel getPnlLayerName() {
269
                if (pnlLayerName == null) {
270
                        lblLayerName = new JLabel();
271
                        pnlLayerName = new JPanel();
272
                        lblLayerName.setText(PluginServices.getText(this,"Nombre") + ":");
273
                        lblLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN);
274
                        pnlLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN);
275
                        pnlLayerName.add(lblLayerName, null);
276
                        pnlLayerName.add(getTxtLayerName(), null);
277
                }
278
                return pnlLayerName;
279
        }
280
        /**
281
         * This method initializes jPanel1
282
         *
283
         * @return javax.swing.JPanel
284
         */
285
        private GridBagLayoutPanel getPnlScale() {
286
                if (pnlScale == null) {
287
                        pnlScale = new GridBagLayoutPanel();
288
                        pnlScale.setBorder(BorderFactory.createTitledBorder(
289
                                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
290
                                        PluginServices.getText(this, "rango_de_escalas"),
291
                                        TitledBorder.DEFAULT_JUSTIFICATION,
292
                                        TitledBorder.DEFAULT_POSITION, null, null)
293
                                );
294
                        ButtonGroup buttonGroup = new ButtonGroup();
295
                        buttonGroup.add(getRdBtnShowAlways());
296
                        buttonGroup.add(getRdBtnDoNotShowWhen());
297
                        pnlScale.addComponent(getRdBtnShowAlways());
298
                        pnlScale.addComponent(getRdBtnDoNotShowWhen());
299
                        JPanel aux;
300

    
301

    
302
                        aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
303
                        aux.add(getTxtMaxScale());
304
                        aux.add(new JLabel("(" + PluginServices.getText(this,"escala_maxima") + ")"));
305

    
306
                        GridBagLayoutPanel aux2;
307
                        aux2 = new GridBagLayoutPanel();
308
                        aux2.addComponent(PluginServices.getText(
309
                                        this,"este_por_encima_de")+" 1:",
310
                                        aux);
311
                        aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
312
                        aux.add(getTxtMinScale());
313
                        aux.add(new JLabel("(" + PluginServices.getText(this,"escala_minima") + ")"));
314

    
315
                        aux2.addComponent(PluginServices.getText(
316
                                        this,"este_por_debajo_de_")+" 1:",
317
                                        aux);
318

    
319
                        pnlScale.addComponent(new JBlank(20, 1), aux2);
320

    
321
                        pnlScale.addComponent(new JBlank(20, 1), aux2);
322

    
323
                }
324
                return pnlScale;
325
        }
326
        /**
327
         * This method initializes jPanel2, this contains the ScrollPane with the
328
         * properies.
329
         *
330
         * @return javax.swing.JPanel
331
         */
332
        private JPanel getPnlProperties() {
333
                if (pnlProperties == null) {
334
                        pnlProperties = new JPanel(new GridBagLayout());
335
                        pnlProperties.setBorder(BorderFactory.createTitledBorder(
336
                                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
337
                                        PluginServices.getText(this, "propiedades"),
338
                                        TitledBorder.DEFAULT_JUSTIFICATION,
339
                                        TitledBorder.DEFAULT_POSITION, null, null)
340
                                );
341
                        GridBagConstraints constraints = new GridBagConstraints();
342
                        constraints.insets = new Insets(5, 5, 5, 5);
343
                        constraints.fill = constraints.BOTH;
344
                        constraints.weightx = 1.0;
345
                        constraints.weighty = 1.0;
346
                        pnlProperties.add(getScrlProperties(), constraints);
347
                }
348
                return pnlProperties;
349
        }
350

    
351
        /**
352
         * This method initializes jTextField
353
         *
354
         * @return javax.swing.JTextField
355
         */
356
        private JTextField getTxtLayerName() {
357
                if (txtLayerName == null) {
358
                        txtLayerName = new JTextField(25);
359
                        txtLayerName.setEditable(true);
360
                }
361
                return txtLayerName;
362
        }
363

    
364
        /**
365
         * This method initializes TxtMaxScale
366
         * @return jTextField1
367
         */
368
        private JTextField getTxtMaxScale() {
369
                if (txtMaxScale == null) {
370
                        txtMaxScale = new JTextField(15);
371
                        txtMaxScale.setEnabled(false);
372
                }
373
                return txtMaxScale;
374
        }
375
        /**
376
         * This method initilizes TxtArea, in this TextArea sets the text with
377
         * the properties of the layer
378
         * @return
379
         */
380
        private JTextArea getPropertiesTextArea() {
381
                if (propertiesTextArea == null) {
382
                        propertiesTextArea = new JTextArea();
383
                        propertiesTextArea.setEditable(false);
384
                        propertiesTextArea.setBackground(SystemColor.control);
385

    
386
                }
387
                return propertiesTextArea;
388
        }
389

    
390
        /**
391
         * This method initializes jScrollPane
392
         *
393
         * @return javax.swing.JScrollPane
394
         */
395
        private JScrollPane getScrlProperties() {
396
                if (scrlProperties == null) {
397
                        scrlProperties = new JScrollPane();
398
                        scrlProperties.setViewportView(getPropertiesTextArea());
399
                        scrlProperties.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
400
                        scrlProperties.setPreferredSize(new Dimension(350, 180));
401
                }
402
                return scrlProperties;
403
        }
404
        /**
405
         * This method initializes jRadioButton
406
         *
407
         * @return javax.swing.JRadioButton
408
         */
409
        private JRadioButton getRdBtnShowAlways() {
410
                if (rdBtnShowAlways == null) {
411
                        rdBtnShowAlways = new JRadioButton();
412
                        rdBtnShowAlways.setText(PluginServices.getText(this,"Mostrar_siempre"));
413
                        rdBtnShowAlways.setSelected(true);
414
                        rdBtnShowAlways.addActionListener(new ActionListener() {
415
                                public void actionPerformed(ActionEvent e) {
416
                                        txtMaxScale.setEnabled(false);
417
                                        txtMinScale.setEnabled(false);
418
                                }
419
                        });
420
                }
421
                return rdBtnShowAlways;
422
        }
423
        /**
424
         * This method initializes jRadioButton1
425
         *
426
         * @return javax.swing.JRadioButton
427
         */
428
        private JRadioButton getRdBtnDoNotShowWhen() {
429
                if (rdBtnDoNotShow == null) {
430
                        rdBtnDoNotShow = new JRadioButton();
431
                        rdBtnDoNotShow.setText(PluginServices.getText(this,"No_mostrar_la_capa_cuando_la_escala"));
432
                        rdBtnDoNotShow.addActionListener(new ActionListener() {
433
                                public void actionPerformed(ActionEvent e) {
434
                                        txtMaxScale.setEnabled(true);
435
                                        txtMinScale.setEnabled(true);
436
                                }
437
                        });
438
                }
439
                return rdBtnDoNotShow;
440
        }
441
        /**
442
         * This method initializes jTextField2
443
         *
444
         * @return javax.swing.JTextField
445
         */
446
        private JTextField getTxtMinScale() {
447
                if (txtMinScale == null) {
448
                        txtMinScale = new JTextField(15);
449
                        txtMinScale.setEnabled(false);
450
                }
451
                return txtMinScale;
452
        }
453

    
454
        private String getLayerName(){
455
                return txtLayerName.getText().toString();
456
        }
457
    /**
458
     * This method initializes jPanel3, this panel contains the components of the
459
     * HyperLink
460
     *
461
     * @return javax.swing.JPanel
462
     */
463
    private JPanel getPnlHyperLink() {
464
            if (pnlHyperLink == null) {
465
                    pnlHyperLink = new JPanel();
466
                    pnlHyperLink.setBorder(BorderFactory.createTitledBorder(
467
                                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
468
                                            PluginServices.getText(this, "Hiperenlace"),
469
                                            TitledBorder.DEFAULT_JUSTIFICATION,
470
                                            TitledBorder.DEFAULT_POSITION, null, null)
471
                                    );
472
                    JPanel aux = new JPanel(new BorderLayout());
473
                    pnlHyperLink.setLayout(new BorderLayout());
474
                    aux.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
475
                    aux.add(getPnlFieldAndExtension(), BorderLayout.NORTH);
476
                    aux.add(getPnlHyperLinkAction(), BorderLayout.CENTER);
477
                    pnlHyperLink.add(aux);
478
            }
479
            return pnlHyperLink;
480
    }
481

    
482

    
483
    private JPanel getPnlFieldAndExtension() {
484
            if (pnlFieldAndExtension == null) {
485
                    lblLinkExtension = new JLabel();
486
                    lblLinkExtension.setText(" \t \t"+PluginServices.getText(this,"extension"));
487
                    lblLinkField = new JLabel();
488
                    lblLinkField.setText(PluginServices.getText(this, "Campo"));
489
                    pnlFieldAndExtension = new JPanel();
490
                    pnlFieldAndExtension.add(lblLinkField, null);
491
                    pnlFieldAndExtension.add(getCmbLinkField(), null);
492
                    pnlFieldAndExtension.add(lblLinkExtension, null);
493
                    pnlFieldAndExtension.add(getTxtLinkExtension(), null);
494
            }
495
            return pnlFieldAndExtension;
496
    }
497
    /**
498
     * This method initializes jPanel8. This panel contains the ComboBox to select
499
     * the action, (type of HyperLink)
500
     *
501
     * @return javax.swing.JPanel
502
     */
503
    private JPanel getPnlHyperLinkAction() {
504
            if (pnlHyperLinkAction == null) {
505
                    lblDefaultAction = new JLabel();
506
                    lblDefaultAction.setText(PluginServices.getText(this, "Accion_Predefinida") + "  ");
507
                    pnlHyperLinkAction = new JPanel();
508
                    pnlHyperLinkAction.add(lblDefaultAction, null);
509
                    pnlHyperLinkAction.add(getCmbLinkType(), null);
510
            }
511
            return pnlHyperLinkAction;
512
    }
513
    /**
514
     * This method initializes jComboBox
515
     *
516
     * @return javax.swing.JComboBox
517
     */
518
    private JComboBox getCmbLinkField() {
519
            if (cmbLinkField == null) {
520
            cmbLinkField = new JComboBox();
521
            }
522
            return cmbLinkField;
523
    }
524
    /**
525
     * This method initializes jTextField
526
     *
527
     * @return javax.swing.JTextField
528
     */
529
    private JTextField getTxtLinkExtension() {
530
            if (txtLinkExtension == null) {
531
                    txtLinkExtension = new JTextField();
532
            txtLinkExtension.setPreferredSize(new Dimension(40,20));
533
            }
534
            return txtLinkExtension;
535
    }
536
    /**
537
     * This method initializes jComboBox1
538
     *
539
     * @return javax.swing.JComboBox
540
     */
541
    private JComboBox getCmbLinkType() {
542
            if (cmbLinkType == null) {
543
                    cmbLinkType = new JComboBox();
544
            }
545
            return cmbLinkType;
546
    }
547
    /**
548
     * @return Returns the view.
549
     */
550
    private IProjectView getView() {
551
        return view;
552
    }
553
    /**
554
     * This method initializes jCheckBox
555
     *
556
     * @return javax.swing.JCheckBox
557
     */
558
    private JCheckBox getJCheckBoxSpatialIndex() {
559
            if (jCheckBoxSpatialIndex == null) {
560
                    jCheckBoxSpatialIndex = new JCheckBox();
561
                    jCheckBoxSpatialIndex.setBounds(2, 33, 242, 23);
562
                    jCheckBoxSpatialIndex.setText(PluginServices.getText(this,"Usar_indice_espacial"));
563
            }
564
            return jCheckBoxSpatialIndex;
565
    }
566

    
567
    /**
568
     * Returns the selected Type in the ComboBox
569
     */
570
    private int getLinkType() {
571
        return getCmbLinkType().getSelectedIndex();
572

    
573
    }
574

    
575
    /**
576
     * Returns the Selected Field in the ComboBox
577
     */
578
    private String getSelectedLinkField() {
579
        return (String) getCmbLinkField().getSelectedItem();
580
    }
581

    
582
    /**
583
     * Returns the Extension in the TextField
584
     */
585
    private String getExtensionLink() {
586
        return getTxtLinkExtension().getText();
587
    }
588

    
589
    /**
590
     * Returns true or false if the CheckBox is marked or not
591
     */
592
    private boolean isSpatialIndexSelected() {
593
        return getJCheckBoxSpatialIndex().isSelected();
594
    }
595

    
596
    /**
597
     * Add the information of the layer to the textArea
598
     */
599
    private void showLayerInfo() {
600
                try {
601
                        String info = ((FLyrDefault)layer).getInfoString();
602
                        if (info == null) {
603
                                Rectangle2D fullExtentViewPort = layer.getFullExtent();
604
                                IProjection viewPortProj = layer.getMapContext().getProjection();
605
                                info = PluginServices.getText(this,"Extent") + " " +
606
                                viewPortProj.getAbrev() +
607
                                " (" + PluginServices.getText(this, "view_projection") + "):\n\t" +
608
                                PluginServices.getText(this,"Superior") + ":\t" + fullExtentViewPort.getMaxY() + "\n\t" +
609
                                PluginServices.getText(this,"Inferior") + ":\t" + fullExtentViewPort.getMinY() + "\n\t" +
610
                                PluginServices.getText(this,"Izquierda") + ":\t" + fullExtentViewPort.getMinX() + "\n\t" +
611
                                PluginServices.getText(this,"Derecha") + ":\t" + fullExtentViewPort.getMaxX() + "\n";
612

    
613
                                // show layer native projection
614
                                if (!layer.getProjection().getAbrev().equals(viewPortProj.getAbrev())) {
615
                                        IProjection nativeLayerProj = layer.getProjection();
616
                                        ICoordTrans ct = viewPortProj.getCT(nativeLayerProj);
617
                                        Rectangle2D nativeLayerExtent = ct.convert(fullExtentViewPort);
618
                                        info += PluginServices.getText(this,"Extent") + " " +
619
                                        nativeLayerProj.getAbrev() +
620
                                        " (" + PluginServices.getText(this, "layer_native_projection") + "):\n\t" +
621
                                        PluginServices.getText(this,"Superior") + ":\t" + nativeLayerExtent.getMaxY() + "\n\t" +
622
                                        PluginServices.getText(this,"Inferior") + ":\t" + nativeLayerExtent.getMinY() + "\n\t" +
623
                                        PluginServices.getText(this,"Izquierda") + ":\t" + nativeLayerExtent.getMinX() + "\n\t" +
624
                                        PluginServices.getText(this,"Derecha") + ":\t" + nativeLayerExtent.getMaxX() + "\n";
625

    
626
                                }
627
                                if (layer instanceof FLyrVect) {
628
                                        ReadableVectorial rv=((FLyrVect)layer).getSource();
629
                                        if (rv instanceof VectorialEditableAdapter) {
630
                                                rv=((VectorialEditableAdapter) ((FLyrVect)layer).getSource()).getOriginalAdapter();
631
                                        }
632

    
633
                                        info = info + PluginServices.getText(this,"Origen_de_datos") + ": ";
634
                                        if (rv instanceof VectorialFileAdapter) {
635
                                                Driver driver=rv.getDriver();
636
                                                info = info + "\n" + driver.getName() + "\n" +
637
                                                PluginServices.getText(this,"fichero") +": " + ((VectorialFileAdapter)rv).getFile();
638
                                        } else if (rv instanceof VectorialDBAdapter) {
639
                                                DBLayerDefinition dbdef = ((VectorialDBAdapter) rv).getLyrDef();
640
                                                info = info + "\n" + rv.getDriver().getName() + "\n";
641

    
642
                                                try {
643
                                                        info = info +
644
                                                        PluginServices.getText(this,"url") +": " + dbdef.getConnection().getURL() + "\n";
645
                                                } catch (Exception e) {
646
                                                        //TODO: Que hacer aqui?
647
                                                        e.printStackTrace();
648
                                                }
649

    
650
                                                info = info +
651
                                                PluginServices.getText(this,"Tabla") +": " + dbdef.getTableName() + "\n";
652
                                        } else if (rv instanceof VectorialAdapter){
653
                                                info = info + "\n" + rv.getDriver().getName() + "\n";
654
                                        }
655

    
656
                                        info+="\n" + PluginServices.getText(this,"type")+ ": "+((FLyrVect)layer).getTypeStringVectorLayer() + "\n";
657

    
658

    
659

    
660

    
661
                                } else {
662
                                        info = info + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName();
663
                                }
664

    
665
                        }
666
                        getPropertiesTextArea().setText(info);
667

    
668
                } catch (ReadDriverException e) {
669
                        NotificationManager.addError(e.getMessage(), e);
670
                }
671

    
672
    }
673

    
674
    /**
675
     * Returns true or false if the scale is activa
676
     */
677
        private boolean isScaleActive() {
678
                return getRdBtnDoNotShowWhen().isSelected();
679
        }
680

    
681
    /**
682
     * Instanciates a ITask (@see com.iver.utiles.swing.threads.ITask)
683
     * to create a spatial index for the selected layer in background.
684
     * This task also allow to monitor process evolution, and to cancel
685
     * this process.
686
     * @throws DriverException
687
     * @throws DriverIOException
688
     */
689
    private IMonitorableTask getCreateSpatialIndexTask() throws ReadDriverException {
690
            // FIXME REVISAR ESTO (Quizas lanzar TaskException)
691
            return new CreateSpatialIndexMonitorableTask((FLyrVect)layer);
692
    }
693

    
694
        public void acceptAction() {
695
             // Implementaci?n para hacer funcionar el hyperlink ...
696
        //com.iver.cit.gvsig.gui.View theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView();
697
        //ProjectView view = theView.getModel();
698
            if (PluginServices.getMainFrame() != null)
699
            {
700
                    IProjectView view = getView();
701
                    view.setTypeLink(getLinkType());
702
                    if (getSelectedLinkField()!=null)
703
                    {
704
                            view.setSelectedField(getSelectedLinkField().toString().trim());
705
                            view.setExtLink(getExtensionLink());
706

    
707
                    }
708
            }
709

    
710

    
711
        }
712

    
713
        public void cancelAction() {
714
                // does nothing
715
        }
716

    
717
        /**
718
         * When we press the apply button, sets the new properties of the layer thar the
719
         * user modified using the UI components
720
         */
721
        public void applyAction() {
722
                if (isScaleActive()) {
723
                        try        {
724
                                layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue());
725
                        } catch (ParseException ex)        {
726
                            if (getTxtMaxScale().getText().compareTo("") == 0)
727
                                layer.setMinScale(-1);
728
                            else
729
                                System.err.print(ex.getLocalizedMessage());
730
                        }
731

    
732
                        try        {
733
                            layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue());
734
                        } catch (ParseException ex)        {
735
                            if (getTxtMinScale().getText().compareTo("") == 0)
736
                                layer.setMaxScale(-1);
737
                            else
738
                                System.err.print(ex.getLocalizedMessage());
739
                        }
740

    
741
                } else {
742
                layer.setMinScale(-1);
743
                layer.setMaxScale(-1);
744
                }
745

    
746
                if (!getLayerName().equals(layer.getName())){
747
                        layer.setName(getLayerName());
748
                }
749

    
750
        if (layer instanceof FLyrVect){
751
            FLyrVect lyrVect = (FLyrVect) layer;
752
            if (isSpatialIndexSelected()) {
753
                    if(lyrVect.getISpatialIndex() == null) {
754
                        //AZABALA
755
                        try {
756
                                                PluginServices.
757
                                                        cancelableBackgroundExecution(getCreateSpatialIndexTask());
758
                                        } catch (ReadDriverException e) {
759
                                                // TODO Auto-generated catch block
760
                                                NotificationManager.addError(e.getMessage(), e);
761
                                        }
762
                }
763
            }
764
            //AZABALA
765
            /*
766
             * If we unselect the spatial index checkbox...Must we delete
767
             * spatial index file, or we only have to put Spatial Index
768
             * reference to null?. I have followed the second choice
769
             */
770
            else{
771
                lyrVect.deleteSpatialIndex();
772
            }
773

    
774

    
775
        }
776
        //Codigo relacionado
777
        if (layer instanceof FLyrVect ){
778
                        FLyrVect vectlyr=(FLyrVect) layer;
779
                        if (getSelectedLinkField()!=null){
780
                                vectlyr.getLinkProperties().setExt(getExtensionLink());
781
                                vectlyr.getLinkProperties().setField(getSelectedLinkField().toString().trim());
782
                                vectlyr.getLinkProperties().setType(getLinkType());
783

    
784
                                System.out.println("Link Properties");
785
                                System.out.println("Extensi?n: " + vectlyr.getLinkProperties().getExt());
786
                                System.out.println("Campo: " + vectlyr.getLinkProperties().getField());
787
                                System.out.println("Tipo: " + vectlyr.getLinkProperties().getType());
788
                        }
789
        }
790
        }
791

    
792
        /*
793
         *  (non-Javadoc)
794
         * @see java.awt.Component#getName()
795
         */
796
        public String getName() {
797
                return PluginServices.getText(this,"General");
798
        }
799
}  //  @jve:decl-index=0:visual-constraint="10,10"
800