Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / General.java @ 24759

History | View | Annotate | Download (26.4 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.GridLayout;
51
import java.awt.SystemColor;
52
import java.awt.event.ActionEvent;
53
import java.awt.event.ActionListener;
54
import java.text.NumberFormat;
55
import java.text.ParseException;
56
import java.util.Iterator;
57

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

    
73
import org.cresques.cts.ICoordTrans;
74
import org.cresques.cts.IProjection;
75
import org.gvsig.fmap.dal.DataStoreParameters;
76
import org.gvsig.fmap.dal.exception.DataException;
77
import org.gvsig.fmap.dal.exception.ReadException;
78
import org.gvsig.fmap.dal.explorer.filesystem.FilesystemStoreParameters;
79
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
80
import org.gvsig.fmap.dal.feature.FeatureStore;
81
import org.gvsig.fmap.dal.feature.FeatureType;
82
import org.gvsig.fmap.data.feature.db.DBParameters;
83
import org.gvsig.fmap.data.feature.db.DBStoreParameters;
84
import org.gvsig.fmap.geom.primitive.Envelope;
85
import org.gvsig.fmap.mapcontext.layers.FLayer;
86
import org.gvsig.fmap.mapcontext.layers.FLyrDefault;
87
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
88
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
89
import org.gvsig.gui.beans.swing.JBlank;
90
import org.gvsig.tools.exception.DriverException;
91

    
92
import com.iver.andami.PluginServices;
93
import com.iver.andami.messages.NotificationManager;
94
import com.iver.cit.gvsig.project.documents.view.IProjectView;
95
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
96
import com.iver.cit.gvsig.project.documents.view.legend.CreateSpatialIndexMonitorableTask;
97
import com.iver.utiles.swing.threads.IMonitorableTask;
98

    
99

    
100

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

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

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

    
164

    
165

    
166
                aux.setPreferredSize(getPreferredSize());
167
                this.add(aux, BorderLayout.CENTER);
168
                this.add(new JBlank(5, 10), BorderLayout.WEST);
169
                this.add(new JBlank(5, 10), BorderLayout.EAST);
170

    
171
        }
172

    
173

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

    
183
        if (layer instanceof FLyrVect) {
184
            FLyrVect lyrVect = (FLyrVect) layer;
185

    
186

    
187
            //TODO
188
//            if(lyrVect.getISpatialIndex() == null) {
189
//                getJCheckBoxSpatialIndex().setSelected(false);
190
//            } else {
191
//                getJCheckBoxSpatialIndex().setSelected(true);
192
//            }
193
        }
194
                if (layer.getMinScale() != -1) {
195
                        getTxtMaxScale().setText(nf.format(layer.getMinScale()));
196
                }
197
                if (layer.getMaxScale() != -1) {
198
                        getTxtMinScale().setText(nf.format(layer.getMaxScale()));
199
                }
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
                if (PluginServices.getMainFrame() != null) {
215
                        if  (PluginServices.getMDIManager().getActiveWindow() instanceof BaseView ){
216
                            BaseView theView = (BaseView)PluginServices.getMDIManager().getActiveWindow();
217
                            view = theView.getModel();
218
                            try {
219
                                if (layer instanceof FLyrVect) {
220
                                    FLyrVect ad = (FLyrVect) layer;
221
                                    FeatureStore fs;
222
                                    fs = ad.getFeatureStore();
223
                                    FeatureType ftype = fs.getDefaultFeatureType();
224
                                    String[] names = new String[ftype.size()];
225
                                    Iterator iter = ftype.iterator();
226
                                    int i=0;
227
                                    while (iter.hasNext()){
228
                                        names[i] = ((FeatureAttributeDescriptor)iter.next()).getName();
229
                                        i++;
230
                                    }
231
                                    DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(names);
232
                                    cmbLinkField.setModel(defaultModel);
233

    
234
                                    if (layer.getLinkProperties().getField()!=null) {
235
                                                        cmbLinkField.setSelectedItem(layer.getLinkProperties().getField());
236
                                                } else {
237
                                                        cmbLinkField.setSelectedItem(view.getSelectedField());
238
                                                }
239
                                } else {
240
                                    cmbLinkField = new JComboBox();
241
                                }
242
                             } catch (DataException e) {
243
                                NotificationManager.addError("No se pudo obtener la tabla", e);
244
                            }
245

    
246

    
247
                            if(layer.getLinkProperties().getExt()!=null) {
248
                                        getTxtLinkExtension().setText(layer.getLinkProperties().getExt());
249
                                }
250

    
251
                            getCmbLinkType().addItem(PluginServices.getText(this,
252
                                       "Enlazar_a_ficheros_de_imagen"));
253
                            getCmbLinkType().addItem(PluginServices.getText(this,
254
                                    "Enlazar_a_fichero_de_texto"));
255

    
256
                            getCmbLinkType().addItem(PluginServices.getText(this,
257
                                    "Enlazar_a_documento_PDF"));
258
                            getCmbLinkType().addItem(PluginServices.getText(this,
259
                                        "Enlazar_a_imagen_SVG"));
260

    
261
                            if (layer.getLinkProperties().getType()!=-1) {
262
                                        getCmbLinkType().setSelectedIndex(layer.getLinkProperties().getType());
263
                                }
264

    
265
                        }
266
                }
267

    
268
        }
269

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

    
308

    
309
                        aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
310
                        aux.add(getTxtMaxScale());
311
                        aux.add(new JLabel("(" + PluginServices.getText(this,"escala_minima") + ")"));
312

    
313
                        GridBagLayoutPanel aux2;
314
                        aux2 = new GridBagLayoutPanel();
315
                        aux2.addComponent(PluginServices.getText(
316
                                        this,"este_por_debajo_de_"),
317
                                        aux);
318
                        aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
319
                        aux.add(getTxtMinScale());
320
                        aux.add(new JLabel("(" + PluginServices.getText(this,"escala_maxima") + ")"));
321

    
322
                        aux2.addComponent(PluginServices.getText(
323
                                        this,"este_por_encima_de"),
324
                                        aux);
325

    
326
                        pnlScale.addComponent(new JBlank(20, 1), aux2);
327

    
328
                        pnlScale.addComponent(new JBlank(20, 1), aux2);
329

    
330
                }
331
                return pnlScale;
332
        }
333
        /**
334
         * This method initializes jPanel2, this contains the ScrollPane with the
335
         * properies.
336
         *
337
         * @return javax.swing.JPanel
338
         */
339
        private JPanel getPnlProperties() {
340
                if (pnlProperties == null) {
341
                        pnlProperties = new JPanel();
342
                        pnlProperties.setBorder(BorderFactory.createTitledBorder(
343
                                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
344
                                        PluginServices.getText(this, "propiedades"),
345
                                        TitledBorder.DEFAULT_JUSTIFICATION,
346
                                        TitledBorder.DEFAULT_POSITION, null, null)
347
                                );
348
                        pnlProperties.add(getScrlProperties(), null);
349
                }
350
                return pnlProperties;
351
        }
352

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

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

    
388
                }
389
                return propertiesTextArea;
390
        }
391

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

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

    
484

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

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

    
575
    }
576

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

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

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

    
598
    /**
599
     * Add the information of the layer to the textArea
600
     */
601
    private void showLayerInfo() {
602
                try {
603
                        String info = ((FLyrDefault)layer).getInfoString();
604
                        if (info == null) {
605
                                StringBuffer buff= new StringBuffer();
606
                                Envelope fullExtentViewPort = layer.getFullEnvelope();
607
                                IProjection viewPortProj = layer.getMapContext().getProjection();
608
                                buff.append(PluginServices.getText(this,"Extent"));
609
                                buff.append(" ");
610
                                buff.append(viewPortProj.getAbrev());
611
                                buff.append(" (" + PluginServices.getText(this, "view_projection") + "):\n\t");
612
                                buff.append(PluginServices.getText(this,"Superior") + ":\t" + fullExtentViewPort.getMaximum(1) + "\n\t");
613
                                buff.append(PluginServices.getText(this,"Inferior") + ":\t" + fullExtentViewPort.getMinimum(1) + "\n\t");
614
                                buff.append(PluginServices.getText(this,"Izquierda") + ":\t" + fullExtentViewPort.getMinimum(0) + "\n\t");
615
                                buff.append(PluginServices.getText(this,"Derecha") + ":\t" + fullExtentViewPort.getMaximum(0) + "\n\n");
616
                                // show layer native projection
617
                                if (!layer.getProjection().getAbrev().equals(viewPortProj.getAbrev())) {
618
                                        IProjection nativeLayerProj = layer.getProjection();
619
                                        ICoordTrans ct = viewPortProj.getCT(nativeLayerProj);
620
//                                        Rectangle2D r=new Rectangle2D.Double(fullExtentViewPort.getMinimum(0),fullExtentViewPort.getMinimum(1),fullExtentViewPort.getLength(0),fullExtentViewPort.getLength(1));
621
//                                        Rectangle2D nativeLayerExtent = ct.convert(r);
622
                                        Envelope nativeLayerExtent = ct.convert(fullExtentViewPort);
623
                                        buff.append(PluginServices.getText(this,"Extent") + " ");
624
                                        buff.append(nativeLayerProj.getAbrev());
625
                                        buff.append(" (" + PluginServices.getText(this, "layer_native_projection") + "):\n\t");
626
                                        buff.append(PluginServices.getText(this, "Superior")
627
                                                        + ":\t" + nativeLayerExtent.getMaximum(1) + "\n\t");
628
                                        buff.append(PluginServices.getText(this, "Inferior")
629
                                                        + ":\t" + nativeLayerExtent.getMinimum(1) + "\n\t");
630
                                        buff.append(PluginServices.getText(this, "Izquierda")
631
                                                        + ":\t" + nativeLayerExtent.getMinimum(0) + "\n\t");
632
                                        buff.append(PluginServices.getText(this, "Derecha") + ":\t"
633
                                                        + nativeLayerExtent.getMaximum(0) + "\n\n");
634

    
635
                                }
636
                                if (layer instanceof FLyrVect) {
637
                                        FeatureStore fStore=((FLyrVect)layer).getFeatureStore();
638
//                                        if (rv instanceof VectorialEditableAdapter) {
639
//                                                rv=((VectorialEditableAdapter) ((FLyrVect)layer).getSource()).getOriginalAdapter();
640
//                                        }
641

    
642
                                        buff.append(PluginServices.getText(this,"Origen_de_datos") + ": ");
643
                                        buff.append(fStore.getName());
644
                                        info=buff.toString();
645

    
646
                                        DataStoreParameters parameters=fStore.getParameters();
647
                                        if (parameters instanceof FilesystemStoreParameters) {
648
                                                info = info  + "\n" +
649
                                                PluginServices.getText(this, "fichero")
650
                                                                + ": "
651
                                                                + ((FilesystemStoreParameters) parameters)
652
                                                                                .getFile();
653
                                        }else if (parameters instanceof DBParameters){
654
                                                info = info + "\n" + fStore.getName() + "\n";
655

    
656
                                                try {
657
                                                        info = info +
658
                                                        PluginServices.getText(this,"url") +": " + ((DBParameters)parameters).getHost() + "\n";
659
                                                } catch (Exception e) {
660
                                                        //TODO: Que hacer aqui?
661
                                                        e.printStackTrace();
662
                                                }
663

    
664
                                                info = info +
665
                                                PluginServices.getText(this, "Tabla")
666
                                                                + ": "
667
                                                                + ((DBStoreParameters) parameters)
668
                                                                                .getTableName() + "\n";
669
                                        }else{
670
                                                info = info + "\n" + fStore.getName() + "\n";
671
                                        }
672
//                                        if (rv instanceof VectorialFileAdapter) {
673
//                                                info = info + "\n" + rv.getDriver().getName() + "\n" +
674
//                                                PluginServices.getText(this,"fichero") +": " + ((VectorialFileAdapter)rv).getFile();
675
//
676
//                                        } else if (rv instanceof VectorialDBAdapter) {
677
//                                                DBLayerDefinition dbdef = ((VectorialDBAdapter) rv).getLyrDef();
678
//                                                info = info + "\n" + rv.getDriver().getName() + "\n";
679
//
680
//                                                try {
681
//                                                        info = info +
682
//                                                        PluginServices.getText(this,"url") +": " + dbdef.getConnection().getURL() + "\n";
683
//                                                } catch (Exception e) {
684
//                                                        //TODO: Que hacer aqui?
685
//                                                        e.printStackTrace();
686
//                                                }
687
//
688
//                                                info = info +
689
//                                                PluginServices.getText(this,"Tabla") +": " + dbdef.getTableName() + "\n";
690
//                                        } else if (rv instanceof VectorialAdapter){
691
//                                                info = info + "\n" + rv.getDriver().getName() + "\n";
692
//                                        }
693

    
694

    
695

    
696
                                } else {
697
                                        info=buff.toString();
698
                                        info = info + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName();
699
                                }
700

    
701
                        }
702
                        getPropertiesTextArea().setText(info);
703

    
704
                } catch (ReadException e) {
705
                        NotificationManager.addError(e.getMessage(), e);
706
                }
707

    
708
    }
709

    
710
    /**
711
     * Returns true or false if the scale is activa
712
     */
713
        private boolean isScaleActive() {
714
                return getRdBtnDoNotShowWhen().isSelected();
715
        }
716

    
717
    /**
718
     * Instanciates a ITask (@see com.iver.utiles.swing.threads.ITask)
719
     * to create a spatial index for the selected layer in background.
720
     * This task also allow to monitor process evolution, and to cancel
721
     * this process.
722
     * @throws DriverException
723
     * @throws DriverIOException
724
     */
725
    private IMonitorableTask getCreateSpatialIndexTask() throws DataException {
726
            // FIXME REVISAR ESTO (Quizas lanzar TaskException)
727
            return new CreateSpatialIndexMonitorableTask((FLyrVect)layer);
728
    }
729

    
730
        public void acceptAction() {
731
             // Implementaci?n para hacer funcionar el hyperlink ...
732
        //com.iver.cit.gvsig.gui.View theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView();
733
        //ProjectView view = theView.getModel();
734
            if (PluginServices.getMainFrame() != null)
735
            {
736
                    IProjectView view = getView();
737
                    view.setTypeLink(getLinkType());
738
                    if (getSelectedLinkField()!=null)
739
                    {
740
                            view.setSelectedField(getSelectedLinkField().toString().trim());
741
                            view.setExtLink(getExtensionLink());
742

    
743
                    }
744
            }
745

    
746

    
747
        }
748

    
749
        public void cancelAction() {
750
                // does nothing
751
        }
752

    
753
        /**
754
         * When we press the apply button, sets the new properties of the layer thar the
755
         * user modified using the UI components
756
         */
757
        public void applyAction() {
758
                if (isScaleActive()) {
759
                        try        {
760
                                layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue());
761
                        } catch (ParseException ex)        {
762
                            if (getTxtMaxScale().getText().compareTo("") == 0) {
763
                                        layer.setMinScale(-1);
764
                                } else {
765
                                        System.err.print(ex.getLocalizedMessage());
766
                                }
767
                        }
768

    
769
                        try        {
770
                            layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue());
771
                        } catch (ParseException ex)        {
772
                            if (getTxtMinScale().getText().compareTo("") == 0) {
773
                                        layer.setMaxScale(-1);
774
                                } else {
775
                                        System.err.print(ex.getLocalizedMessage());
776
                                }
777
                        }
778

    
779
                } else {
780
                layer.setMinScale(-1);
781
                layer.setMaxScale(-1);
782
                }
783

    
784
                if (!getLayerName().equals(layer.getName())){
785
                        layer.setName(getLayerName());
786
                }
787

    
788
        if (layer instanceof FLyrVect){
789
            FLyrVect lyrVect = (FLyrVect) layer;
790
            if (isSpatialIndexSelected()) {
791
                        // TODO
792

    
793
//                    if(lyrVect.getISpatialIndex() == null) {
794
//                        //AZABALA
795
//                        try {
796
//                                                PluginServices.
797
//                                                        cancelableBackgroundExecution(getCreateSpatialIndexTask());
798
//                                        } catch (ReadDriverException e) {
799
//                                                // TODO Auto-generated catch block
800
//                                                NotificationManager.addError(e.getMessage(), e);
801
//                                        }
802
//                }
803
            }
804
            //AZABALA
805
            /*
806
             * If we unselect the spatial index checkbox...Must we delete
807
             * spatial index file, or we only have to put Spatial Index
808
             * reference to null?. I have followed the second choice
809
             */
810
            else{
811
//                lyrVect.deleteSpatialIndex();
812
            }
813

    
814

    
815
        }
816
        //Codigo relacionado
817
        if (layer instanceof FLyrVect ){
818
                        FLyrVect vectlyr=(FLyrVect) layer;
819
                        if (getSelectedLinkField()!=null){
820
                                vectlyr.getLinkProperties().setExt(getExtensionLink());
821
                                vectlyr.getLinkProperties().setField(getSelectedLinkField().toString().trim());
822
                                vectlyr.getLinkProperties().setType(getLinkType());
823

    
824
                                System.out.println("Link Properties");
825
                                System.out.println("Extensi?n: " + vectlyr.getLinkProperties().getExt());
826
                                System.out.println("Campo: " + vectlyr.getLinkProperties().getField());
827
                                System.out.println("Tipo: " + vectlyr.getLinkProperties().getType());
828
                        }
829
        }
830
        }
831

    
832
        /*
833
         *  (non-Javadoc)
834
         * @see java.awt.Component#getName()
835
         */
836
        public String getName() {
837
                return PluginServices.getText(this,"General");
838
        }
839
}  //  @jve:decl-index=0:visual-constraint="10,10"
840