Statistics
| Revision:

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

History | View | Annotate | Download (25.3 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.awt.geom.Rectangle2D;
55
import java.text.NumberFormat;
56
import java.text.ParseException;
57
import java.util.Iterator;
58

    
59
import javax.swing.BorderFactory;
60
import javax.swing.ButtonGroup;
61
import javax.swing.DefaultComboBoxModel;
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.data.ReadException;
77
import org.gvsig.data.vectorial.FeatureAttributeDescriptor;
78
import org.gvsig.data.vectorial.FeatureStore;
79
import org.gvsig.data.vectorial.FeatureType;
80
import org.gvsig.fmap.mapcontext.layers.FLayer;
81
import org.gvsig.fmap.mapcontext.layers.FLyrDefault;
82
import org.gvsig.fmap.mapcontext.layers.operations.AlphanumericData;
83
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
84
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
85
import org.gvsig.gui.beans.swing.JBlank;
86

    
87
import com.iver.andami.PluginServices;
88
import com.iver.andami.messages.NotificationManager;
89
import com.iver.cit.gvsig.project.documents.view.IProjectView;
90
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
91
import com.iver.cit.gvsig.project.documents.view.legend.CreateSpatialIndexMonitorableTask;
92
import com.iver.utiles.swing.threads.IMonitorableTask;
93

    
94

    
95

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

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

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

    
168

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

    
178
        if (layer instanceof FLyrVect) {
179
            FLyrVect lyrVect = (FLyrVect) layer;
180

    
181

    
182
            //TODO
183
//            if(lyrVect.getISpatialIndex() == null) {
184
//                getJCheckBoxSpatialIndex().setSelected(false);
185
//            } else {
186
//                getJCheckBoxSpatialIndex().setSelected(true);
187
//            }
188
        }
189
                if (layer.getMinScale() != -1)
190
                    getTxtMaxScale().setText(nf.format(layer.getMinScale()));
191
                if (layer.getMaxScale() != -1)
192
                    getTxtMinScale().setText(nf.format(layer.getMaxScale()));
193
                if (layer.getMinScale() == -1 && layer.getMaxScale() == -1) {
194
                        getRdBtnShowAlways().setSelected(true);
195
                        txtMaxScale.setEnabled(false);
196
                        txtMinScale.setEnabled(false);
197
                        
198
                } else {
199
                        getRdBtnDoNotShowWhen().setSelected(true);
200
                        txtMaxScale.setEnabled(true);
201
                        txtMinScale.setEnabled(true);
202
                }
203
                txtLayerName.setText(layer.getName());
204
                showLayerInfo();
205

    
206

    
207
                if (PluginServices.getMainFrame() != null)
208
                if  (PluginServices.getMDIManager().getActiveWindow() instanceof BaseView ){
209
                    BaseView theView = (BaseView)PluginServices.getMDIManager().getActiveWindow();
210
                    view = theView.getModel();
211
            try {
212
                if (layer instanceof AlphanumericData) {
213
                    AlphanumericData ad = (AlphanumericData) layer;
214
                    FeatureStore fs;
215
                    fs = ad.getFeatureStore();
216
                    FeatureType ftype = fs.getDefaultFeatureType();
217
                    String[] names = new String[ftype.size()];
218
                    Iterator iter = ftype.iterator();
219
                    int i=0;
220
                    while (iter.hasNext()){
221
                        names[i] = ((FeatureAttributeDescriptor)iter.next()).getName();
222
                        i++;
223
                    }
224
                    DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(names);
225
                    cmbLinkField.setModel(defaultModel);
226

    
227
                    if (layer.getLinkProperties().getField()!=null)
228
                            cmbLinkField.setSelectedItem(layer.getLinkProperties().getField());
229
                    else 
230
                            cmbLinkField.setSelectedItem(view.getSelectedField());
231
                } else {
232
                    cmbLinkField = new JComboBox();
233
                }
234
             } catch (ReadException e) {
235
                NotificationManager.addError("No se pudo obtener la tabla", e);
236
            }
237

    
238

    
239
            if(layer.getLinkProperties().getExt()!=null)
240
                    getTxtLinkExtension().setText(layer.getLinkProperties().getExt());
241

    
242
            getCmbLinkType().addItem(PluginServices.getText(this,
243
                       "Enlazar_a_ficheros_de_imagen"));
244
            getCmbLinkType().addItem(PluginServices.getText(this,
245
                    "Enlazar_a_fichero_de_texto"));
246

    
247
            getCmbLinkType().addItem(PluginServices.getText(this,
248
                    "Enlazar_a_documento_PDF"));
249
            getCmbLinkType().addItem(PluginServices.getText(this,
250
                        "Enlazar_a_imagen_SVG"));
251

    
252
            if (layer.getLinkProperties().getType()!=-1)
253
                    getCmbLinkType().setSelectedIndex(layer.getLinkProperties().getType());
254

    
255
                }
256

    
257
        }
258

    
259
        /**
260
         * This method initializes jPanel
261
         *
262
         * @return javax.swing.JPanel
263
         */
264
        private JPanel getPnlLayerName() {
265
                if (pnlLayerName == null) {
266
                        lblLayerName = new JLabel();
267
                        pnlLayerName = new JPanel();
268
                        lblLayerName.setText(PluginServices.getText(this,"Nombre") + ":");
269
                        lblLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN);
270
                        pnlLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN);
271
                        pnlLayerName.add(lblLayerName, null);
272
                        pnlLayerName.add(getTxtLayerName(), null);
273
                }
274
                return pnlLayerName;
275
        }
276
        /**
277
         * This method initializes jPanel1
278
         *
279
         * @return javax.swing.JPanel
280
         */
281
        private GridBagLayoutPanel getPnlScale() {
282
                if (pnlScale == null) {
283
                        pnlScale = new GridBagLayoutPanel();
284
                        pnlScale.setBorder(BorderFactory.createTitledBorder(
285
                                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
286
                                        PluginServices.getText(this, "rango_de_escalas"),
287
                                        TitledBorder.DEFAULT_JUSTIFICATION,
288
                                        TitledBorder.DEFAULT_POSITION, null, null)
289
                                );
290
                        ButtonGroup buttonGroup = new ButtonGroup();
291
                        buttonGroup.add(getRdBtnShowAlways());
292
                        buttonGroup.add(getRdBtnDoNotShowWhen());
293
                        pnlScale.addComponent(getRdBtnShowAlways());
294
                        pnlScale.addComponent(getRdBtnDoNotShowWhen());
295
                        JPanel aux;
296
                        
297
                        
298
                        aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
299
                        aux.add(getTxtMaxScale());
300
                        aux.add(new JLabel("(" + PluginServices.getText(this,"escala_minima") + ")"));
301
                        
302
                        GridBagLayoutPanel aux2;
303
                        aux2 = new GridBagLayoutPanel();
304
                        aux2.addComponent(PluginServices.getText(
305
                                        this,"este_por_debajo_de_"),
306
                                        aux);
307
                        aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
308
                        aux.add(getTxtMinScale());
309
                        aux.add(new JLabel("(" + PluginServices.getText(this,"escala_maxima") + ")"));
310
                        
311
                        aux2.addComponent(PluginServices.getText(
312
                                        this,"este_por_encima_de"),
313
                                        aux);
314
                        
315
                        pnlScale.addComponent(new JBlank(20, 1), aux2);
316
                        
317
                        pnlScale.addComponent(new JBlank(20, 1), aux2);
318
                        
319
                }
320
                return pnlScale;
321
        }
322
        /**
323
         * This method initializes jPanel2, this contains the ScrollPane with the
324
         * properies.
325
         *
326
         * @return javax.swing.JPanel
327
         */
328
        private JPanel getPnlProperties() {
329
                if (pnlProperties == null) {
330
                        pnlProperties = new JPanel();
331
                        pnlProperties.setBorder(BorderFactory.createTitledBorder(
332
                                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
333
                                        PluginServices.getText(this, "propiedades"),
334
                                        TitledBorder.DEFAULT_JUSTIFICATION,
335
                                        TitledBorder.DEFAULT_POSITION, null, null)
336
                                );
337
                        pnlProperties.add(getScrlProperties(), null);
338
                }
339
                return pnlProperties;
340
        }
341

    
342
        /**
343
         * This method initializes jTextField
344
         *
345
         * @return javax.swing.JTextField
346
         */
347
        private JTextField getTxtLayerName() {
348
                if (txtLayerName == null) {
349
                        txtLayerName = new JTextField(25);
350
                        txtLayerName.setEditable(true);
351
                }
352
                return txtLayerName;
353
        }
354

    
355
        /**
356
         * This method initializes TxtMaxScale
357
         * @return jTextField1
358
         */
359
        private JTextField getTxtMaxScale() {
360
                if (txtMaxScale == null) {
361
                        txtMaxScale = new JTextField(15);
362
                        txtMaxScale.setEnabled(false);
363
                }
364
                return txtMaxScale;
365
        }
366
        /**
367
         * This method initilizes TxtArea, in this TextArea sets the text with
368
         * the properties of the layer
369
         * @return
370
         */
371
        private JTextArea getPropertiesTextArea() {
372
                if (propertiesTextArea == null) {
373
                        propertiesTextArea = new JTextArea();
374
                        propertiesTextArea.setEditable(false);
375
                        propertiesTextArea.setBackground(SystemColor.control);
376

    
377
                }
378
                return propertiesTextArea;
379
        }
380

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

    
445
        private String getLayerName(){
446
                return txtLayerName.getText().toString();
447
        }
448
    /**
449
     * This method initializes jPanel3, this panel contains the components of the
450
     * HyperLink
451
     *
452
     * @return javax.swing.JPanel
453
     */
454
    private JPanel getPnlHyperLink() {
455
            if (pnlHyperLink == null) {
456
                    pnlHyperLink = new JPanel();
457
                    pnlHyperLink.setBorder(BorderFactory.createTitledBorder(
458
                                    BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
459
                                            PluginServices.getText(this, "Hiperenlace"),
460
                                            TitledBorder.DEFAULT_JUSTIFICATION,
461
                                            TitledBorder.DEFAULT_POSITION, null, null)
462
                                    );
463
                    JPanel aux = new JPanel(new BorderLayout());
464
                    pnlHyperLink.setLayout(new BorderLayout());
465
                    aux.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
466
                    aux.add(getPnlFieldAndExtension(), BorderLayout.NORTH);
467
                    aux.add(getPnlHyperLinkAction(), BorderLayout.CENTER);
468
                    pnlHyperLink.add(aux);
469
            }
470
            return pnlHyperLink;
471
    }
472
   
473
    
474
    private JPanel getPnlFieldAndExtension() {
475
            if (pnlFieldAndExtension == null) {
476
                    lblLinkExtension = new JLabel();
477
                    lblLinkExtension.setText(" \t \t"+PluginServices.getText(this,"extension"));
478
                    lblLinkField = new JLabel();
479
                    lblLinkField.setText(PluginServices.getText(this, "Campo"));
480
                    pnlFieldAndExtension = new JPanel();
481
                    pnlFieldAndExtension.add(lblLinkField, null);
482
                    pnlFieldAndExtension.add(getCmbLinkField(), null);
483
                    pnlFieldAndExtension.add(lblLinkExtension, null);
484
                    pnlFieldAndExtension.add(getTxtLinkExtension(), null);
485
            }
486
            return pnlFieldAndExtension;
487
    }
488
    /**
489
     * This method initializes jPanel8. This panel contains the ComboBox to select
490
     * the action, (type of HyperLink)
491
     *
492
     * @return javax.swing.JPanel
493
     */
494
    private JPanel getPnlHyperLinkAction() {
495
            if (pnlHyperLinkAction == null) {
496
                    lblDefaultAction = new JLabel();
497
                    lblDefaultAction.setText(PluginServices.getText(this, "Accion_Predefinida") + "  ");
498
                    pnlHyperLinkAction = new JPanel();
499
                    pnlHyperLinkAction.add(lblDefaultAction, null);
500
                    pnlHyperLinkAction.add(getCmbLinkType(), null);
501
            }
502
            return pnlHyperLinkAction;
503
    }
504
    /**
505
     * This method initializes jComboBox
506
     *
507
     * @return javax.swing.JComboBox
508
     */
509
    private JComboBox getCmbLinkField() {
510
            if (cmbLinkField == null) {
511
            cmbLinkField = new JComboBox();
512
            }
513
            return cmbLinkField;
514
    }
515
    /**
516
     * This method initializes jTextField
517
     *
518
     * @return javax.swing.JTextField
519
     */
520
    private JTextField getTxtLinkExtension() {
521
            if (txtLinkExtension == null) {
522
                    txtLinkExtension = new JTextField();
523
            txtLinkExtension.setPreferredSize(new Dimension(40,20));
524
            }
525
            return txtLinkExtension;
526
    }
527
    /**
528
     * This method initializes jComboBox1
529
     *
530
     * @return javax.swing.JComboBox
531
     */
532
    private JComboBox getCmbLinkType() {
533
            if (cmbLinkType == null) {
534
                    cmbLinkType = new JComboBox();
535
            }
536
            return cmbLinkType;
537
    }
538
    /**
539
     * @return Returns the view.
540
     */
541
    private IProjectView getView() {
542
        return view;
543
    }
544
    /**
545
     * This method initializes jCheckBox
546
     *
547
     * @return javax.swing.JCheckBox
548
     */
549
    private JCheckBox getJCheckBoxSpatialIndex() {
550
            if (jCheckBoxSpatialIndex == null) {
551
                    jCheckBoxSpatialIndex = new JCheckBox();
552
                    jCheckBoxSpatialIndex.setBounds(2, 33, 242, 23);
553
                    jCheckBoxSpatialIndex.setText(PluginServices.getText(this,"Usar_indice_espacial"));
554
            }
555
            return jCheckBoxSpatialIndex;
556
    }
557

    
558
    /**
559
     * Returns the selected Type in the ComboBox
560
     */
561
    private int getLinkType() {
562
        return getCmbLinkType().getSelectedIndex();
563

    
564
    }
565

    
566
    /**
567
     * Returns the Selected Field in the ComboBox
568
     */
569
    private String getSelectedLinkField() {
570
        return (String) getCmbLinkField().getSelectedItem();
571
    }
572

    
573
    /**
574
     * Returns the Extension in the TextField
575
     */
576
    private String getExtensionLink() {
577
        return getTxtLinkExtension().getText();
578
    }
579

    
580
    /**
581
     * Returns true or false if the CheckBox is marked or not
582
     */
583
    private boolean isSpatialIndexSelected() {
584
        return getJCheckBoxSpatialIndex().isSelected();
585
    }
586

    
587
    /**
588
     * Add the information of the layer to the textArea
589
     */
590
    private void showLayerInfo() {
591
                try {
592
                        String info = ((FLyrDefault)layer).getInfoString();
593
                        if (info == null) {
594
                                StringBuffer buff= new StringBuffer();
595
                                Rectangle2D fullExtentViewPort = layer.getFullEnvelope();
596
                                IProjection viewPortProj = layer.getMapContext().getProjection();
597
                                buff.append(PluginServices.getText(this,"Extent"));
598
                                buff.append(" ");
599
                                buff.append(viewPortProj.getAbrev());
600
                                buff.append(" (" + PluginServices.getText(this, "view_projection") + "):\n\t");
601
                                buff.append(PluginServices.getText(this,"Superior") + ":\t" + fullExtentViewPort.getMaxY() + "\n\t");
602
                                buff.append(PluginServices.getText(this,"Inferior") + ":\t" + fullExtentViewPort.getMinY() + "\n\t");
603
                                buff.append(PluginServices.getText(this,"Izquierda") + ":\t" + fullExtentViewPort.getMinX() + "\n\t");
604
                                buff.append(PluginServices.getText(this,"Derecha") + ":\t" + fullExtentViewPort.getMaxX() + "\n\n");
605

    
606
                                // show layer native projection
607
                                if (!layer.getProjection().getAbrev().equals(viewPortProj.getAbrev())) {
608
                                        IProjection nativeLayerProj = layer.getProjection();
609
                                        ICoordTrans ct = viewPortProj.getCT(nativeLayerProj);
610
                                        Rectangle2D nativeLayerExtent = ct.convert(fullExtentViewPort);
611
                                        buff.append(PluginServices.getText(this,"Extent") + " ");
612
                                        buff.append(nativeLayerProj.getAbrev());
613
                                        buff.append(" (" + PluginServices.getText(this, "layer_native_projection") + "):\n\t");
614
                                        buff.append(PluginServices.getText(this,"Superior") + ":\t" + nativeLayerExtent.getMaxY() + "\n\t");
615
                                        buff.append(PluginServices.getText(this,"Inferior") + ":\t" + nativeLayerExtent.getMinY() + "\n\t");
616
                                        buff.append(PluginServices.getText(this,"Izquierda") + ":\t" + nativeLayerExtent.getMinX() + "\n\t");
617
                                        buff.append(PluginServices.getText(this,"Derecha") + ":\t" + nativeLayerExtent.getMaxX() + "\n\n");
618

    
619
                                }
620
                                if (layer instanceof FLyrVect) {
621
                                        FeatureStore fStore=((FLyrVect)layer).getFeatureStore();
622
//                                        if (rv instanceof VectorialEditableAdapter) {
623
//                                                rv=((VectorialEditableAdapter) ((FLyrVect)layer).getSource()).getOriginalAdapter();
624
//                                        }
625

    
626
                                        buff.append(PluginServices.getText(this,"Origen_de_datos") + ": ");
627
                                        buff.append(fStore.getName());
628
                                        // TODO: Falta rellenar
629
//                                        if (rv instanceof VectorialFileAdapter) {
630
//                                                info = info + "\n" + rv.getDriver().getName() + "\n" +
631
//                                                PluginServices.getText(this,"fichero") +": " + ((VectorialFileAdapter)rv).getFile();
632
//
633
//                                        } else if (rv instanceof VectorialDBAdapter) {
634
//                                                DBLayerDefinition dbdef = ((VectorialDBAdapter) rv).getLyrDef();
635
//                                                info = info + "\n" + rv.getDriver().getName() + "\n";
636
//
637
//                                                try {
638
//                                                        info = info +
639
//                                                        PluginServices.getText(this,"url") +": " + dbdef.getConnection().getURL() + "\n";
640
//                                                } catch (Exception e) {
641
//                                                        //TODO: Que hacer aqui?
642
//                                                        e.printStackTrace();
643
//                                                }
644
//
645
//                                                info = info +
646
//                                                PluginServices.getText(this,"Tabla") +": " + dbdef.getTableName() + "\n";
647
//                                        } else if (rv instanceof VectorialAdapter){
648
//                                                info = info + "\n" + rv.getDriver().getName() + "\n";
649
//                                        }
650

    
651

    
652

    
653
                                } else {
654
                                        info = info + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName();
655
                                }
656

    
657
                        }
658
                        getPropertiesTextArea().setText(info);
659

    
660
                } catch (ReadException e) {
661
                        NotificationManager.addError(e.getMessage(), e);
662
                } 
663

    
664
    }
665

    
666
    /**
667
     * Returns true or false if the scale is activa
668
     */
669
        private boolean isScaleActive() {
670
                return getRdBtnDoNotShowWhen().isSelected();
671
        }
672

    
673
    /**
674
     * Instanciates a ITask (@see com.iver.utiles.swing.threads.ITask)
675
     * to create a spatial index for the selected layer in background.
676
     * This task also allow to monitor process evolution, and to cancel
677
     * this process.
678
     * @throws DriverException
679
     * @throws DriverIOException
680
     */
681
    private IMonitorableTask getCreateSpatialIndexTask() throws ReadException {
682
            // FIXME REVISAR ESTO (Quizas lanzar TaskException)
683
            return new CreateSpatialIndexMonitorableTask((FLyrVect)layer);
684
    }
685

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

    
699
                    }
700
            }
701

    
702

    
703
        }
704

    
705
        public void cancelAction() {
706
                // does nothing
707
        }
708

    
709
        /**
710
         * When we press the apply button, sets the new properties of the layer thar the
711
         * user modified using the UI components
712
         */
713
        public void applyAction() {
714
                if (isScaleActive()) {
715
                        try        {
716
                                layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue());
717
                        } catch (ParseException ex)        {
718
                            if (getTxtMaxScale().getText().compareTo("") == 0)
719
                                layer.setMinScale(-1);
720
                            else
721
                                System.err.print(ex.getLocalizedMessage());
722
                        }
723

    
724
                        try        {
725
                            layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue());
726
                        } catch (ParseException ex)        {
727
                            if (getTxtMinScale().getText().compareTo("") == 0)
728
                                layer.setMaxScale(-1);
729
                            else
730
                                System.err.print(ex.getLocalizedMessage());
731
                        }
732

    
733
                } else {
734
                layer.setMinScale(-1);
735
                layer.setMaxScale(-1);
736
                }
737

    
738
                if (!getLayerName().equals(layer.getName())){
739
                        layer.setName(getLayerName());
740
                }
741

    
742
        if (layer instanceof FLyrVect){
743
            FLyrVect lyrVect = (FLyrVect) layer;
744
            if (isSpatialIndexSelected()) {
745
                        // TODO
746

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

    
768

    
769
        }
770
        //Codigo relacionado
771
        if (layer instanceof FLyrVect ){
772
                        FLyrVect vectlyr=(FLyrVect) layer;
773
                        if (getSelectedLinkField()!=null){
774
                                vectlyr.getLinkProperties().setExt(getExtensionLink());
775
                                vectlyr.getLinkProperties().setField(getSelectedLinkField().toString().trim());
776
                                vectlyr.getLinkProperties().setType(getLinkType());
777

    
778
                                System.out.println("Link Properties");
779
                                System.out.println("Extensi?n: " + vectlyr.getLinkProperties().getExt());
780
                                System.out.println("Campo: " + vectlyr.getLinkProperties().getField());
781
                                System.out.println("Tipo: " + vectlyr.getLinkProperties().getType());
782
                        }
783
        }
784
        }
785

    
786
        /*
787
         *  (non-Javadoc)
788
         * @see java.awt.Component#getName()
789
         */
790
        public String getName() {
791
                return PluginServices.getText(this,"General");
792
        }
793
}  //  @jve:decl-index=0:visual-constraint="10,10"
794