Statistics
| Revision:

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

History | View | Annotate | Download (28.1 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.feature.FeatureAttributeDescriptor;
79
import org.gvsig.fmap.dal.feature.FeatureSet;
80
import org.gvsig.fmap.dal.feature.FeatureStore;
81
import org.gvsig.fmap.dal.feature.FeatureType;
82
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
83
import org.gvsig.fmap.geom.Geometry;
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

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

    
98

    
99

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

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

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

    
163

    
164

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

    
170
        }
171

    
172

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

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

    
185

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

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

    
212

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

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

    
245

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

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

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

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

    
264
                        }
265
                }
266

    
267
        }
268

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

    
307

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

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

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

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

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

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

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

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

    
387
                }
388
                return propertiesTextArea;
389
        }
390

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

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

    
483

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

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

    
574
    }
575

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

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

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

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

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

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

    
645
                                        DataStoreParameters parameters=fStore.getParameters();
646
                                        if (parameters instanceof FilesystemStoreParameters) {
647
                                                info = info  + "\n" +
648
                                                PluginServices.getText(this, "fichero")
649
                                                                + ": "
650
                                                                + ((FilesystemStoreParameters) parameters)
651
                                                                                .getFile();
652
//                                        FIXME
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
                                        info += "\n" + PluginServices.getText(this,"type")+ ": "+getTypeVectorLayer() + "\n";
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
                } catch (DataException e) {
707
                        NotificationManager.addError(e.getMessage(), e);
708
                }
709

    
710
    }
711
    private String getTypeVectorLayer() throws DataException {
712
            if (layer instanceof FLyrVect){
713
                String typeString="";
714
                int typeShape=((FLyrVect)layer).getShapeType();
715
                FeatureStore fs=((FLyrVect)layer).getFeatureStore();
716
                        FeatureSet set=fs.getFeatureSet();
717

    
718
                if (Geometry.TYPES.GEOMETRY==typeShape){
719
                                if (set.getSize()>0){
720
                                        int type=((Geometry)set.getDefaultFeatureType().get(set.getDefaultFeatureType().getDefaultGeometryAttributeIndex())).getType();
721
                                        if ((type & Geometry.TYPES.Z) > Geometry.TYPES.Z){
722
                                                typeString="Geometries3D";
723
                                        }else{
724
                                                typeString="Geometries2D";
725
                                        }
726
                                }
727
                        }else{
728
                                if (set.getSize()>0){
729
                                        int type=((Geometry)set.getDefaultFeatureType().get(set.getDefaultFeatureType().getDefaultGeometryAttributeIndex())).getType();
730
                                        if (Geometry.TYPES.POINT == type){
731
                                                typeString="Point2D";
732
                                        } else if (Geometry.TYPES.SURFACE == type){
733
                                                typeString="Line2D";
734
                                        } else if (Geometry.TYPES.SOLID == type){
735
                                                typeString="Polygon2D";
736
                                        } else if (Geometry.TYPES.MULTIPOINT == type){
737
                                                typeString="MultiPint2D";
738
                                        } else if ((Geometry.TYPES.POINT | Geometry.TYPES.Z)  == type ){
739
                                                typeString="Point3D";
740
                                        } else if ((Geometry.TYPES.SURFACE | Geometry.TYPES.Z)  == type ){
741
                                                typeString="Line3D";
742
                                        } else if ((Geometry.TYPES.SOLID | Geometry.TYPES.Z)  == type ){
743
                                                typeString="Polygon3D";
744
                                        } else if ((Geometry.TYPES.MULTIPOINT | Geometry.TYPES.Z)  == type ){
745
                                                typeString="MultiPoint3D";
746
                                        }
747

    
748
                                        return typeString;
749
                                }
750
                        }
751
        }
752
            return "";
753
        }
754

    
755
    /**
756
     * Returns true or false if the scale is activa
757
     */
758
        private boolean isScaleActive() {
759
                return getRdBtnDoNotShowWhen().isSelected();
760
        }
761

    
762
    /**
763
     * Instanciates a ITask (@see com.iver.utiles.swing.threads.ITask)
764
     * to create a spatial index for the selected layer in background.
765
     * This task also allow to monitor process evolution, and to cancel
766
     * this process.
767
     * @throws DriverException
768
     * @throws DriverIOException
769
     */
770
    private IMonitorableTask getCreateSpatialIndexTask() throws DataException {
771
            // FIXME REVISAR ESTO (Quizas lanzar TaskException)
772
            return new CreateSpatialIndexMonitorableTask((FLyrVect)layer);
773
    }
774

    
775
        public void acceptAction() {
776
             // Implementaci?n para hacer funcionar el hyperlink ...
777
        //com.iver.cit.gvsig.gui.View theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView();
778
        //ProjectView view = theView.getModel();
779
            if (PluginServices.getMainFrame() != null)
780
            {
781
                    IProjectView view = getView();
782
                    view.setTypeLink(getLinkType());
783
                    if (getSelectedLinkField()!=null)
784
                    {
785
                            view.setSelectedField(getSelectedLinkField().toString().trim());
786
                            view.setExtLink(getExtensionLink());
787

    
788
                    }
789
            }
790

    
791

    
792
        }
793

    
794
        public void cancelAction() {
795
                // does nothing
796
        }
797

    
798
        /**
799
         * When we press the apply button, sets the new properties of the layer thar the
800
         * user modified using the UI components
801
         */
802
        public void applyAction() {
803
                if (isScaleActive()) {
804
                        try        {
805
                                layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue());
806
                        } catch (ParseException ex)        {
807
                            if (getTxtMaxScale().getText().compareTo("") == 0) {
808
                                        layer.setMinScale(-1);
809
                                } else {
810
                                        System.err.print(ex.getLocalizedMessage());
811
                                }
812
                        }
813

    
814
                        try        {
815
                            layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue());
816
                        } catch (ParseException ex)        {
817
                            if (getTxtMinScale().getText().compareTo("") == 0) {
818
                                        layer.setMaxScale(-1);
819
                                } else {
820
                                        System.err.print(ex.getLocalizedMessage());
821
                                }
822
                        }
823

    
824
                } else {
825
                layer.setMinScale(-1);
826
                layer.setMaxScale(-1);
827
                }
828

    
829
                if (!getLayerName().equals(layer.getName())){
830
                        layer.setName(getLayerName());
831
                }
832

    
833
        if (layer instanceof FLyrVect){
834
            FLyrVect lyrVect = (FLyrVect) layer;
835
            if (isSpatialIndexSelected()) {
836
                        // TODO
837

    
838
//                    if(lyrVect.getISpatialIndex() == null) {
839
//                        //AZABALA
840
//                        try {
841
//                                                PluginServices.
842
//                                                        cancelableBackgroundExecution(getCreateSpatialIndexTask());
843
//                                        } catch (ReadDriverException e) {
844
//                                                // TODO Auto-generated catch block
845
//                                                NotificationManager.addError(e.getMessage(), e);
846
//                                        }
847
//                }
848
            }
849
            //AZABALA
850
            /*
851
             * If we unselect the spatial index checkbox...Must we delete
852
             * spatial index file, or we only have to put Spatial Index
853
             * reference to null?. I have followed the second choice
854
             */
855
            else{
856
//                lyrVect.deleteSpatialIndex();
857
            }
858

    
859

    
860
        }
861
        //Codigo relacionado
862
        if (layer instanceof FLyrVect ){
863
                        FLyrVect vectlyr=(FLyrVect) layer;
864
                        if (getSelectedLinkField()!=null){
865
                                vectlyr.getLinkProperties().setExt(getExtensionLink());
866
                                vectlyr.getLinkProperties().setField(getSelectedLinkField().toString().trim());
867
                                vectlyr.getLinkProperties().setType(getLinkType());
868

    
869
                                System.out.println("Link Properties");
870
                                System.out.println("Extensi?n: " + vectlyr.getLinkProperties().getExt());
871
                                System.out.println("Campo: " + vectlyr.getLinkProperties().getField());
872
                                System.out.println("Tipo: " + vectlyr.getLinkProperties().getType());
873
                        }
874
        }
875
        }
876

    
877
        /*
878
         *  (non-Javadoc)
879
         * @see java.awt.Component#getName()
880
         */
881
        public String getName() {
882
                return PluginServices.getText(this,"General");
883
        }
884
}  //  @jve:decl-index=0:visual-constraint="10,10"
885