Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / scale / gui / FPanelScaleManager.java @ 10626

History | View | Annotate | Download (25.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.scale.gui;
45

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

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

    
60
import org.apache.log4j.Logger;
61

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

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

    
98
        private JPanel jPanel = null;
99
        private JPanel jPanel1 = null;
100
        private JPanel jPanel2 = null;
101
        private JPanel jPanel4 = null;
102
        private JPanel jPanel5 = null;
103
        private JLabel jLabel = null;
104
        private JTextField txtLayerName = null;
105
        private JLabel jLabel1 = null;
106
        private JTextField jTextField1 = null;
107
        private JLabel jLabel2 = null;
108
        private JTextArea jTextArea = null;
109
        private JScrollPane jScrollPane = null;
110
        private ButtonGroup buttonGroup = null;
111
        private JRadioButton jRadioButton = null;
112
        private JRadioButton jRadioButton1 = null;
113
        private JLabel jLabel3 = null;
114
        private JTextField jTextField2 = null;
115
        private JLabel jLabel4 = null;
116
        private JPanel jPanel3 = null;
117
    private JPanel jPanel6 = null;
118
    private JPanel jPanel7 = null;
119
    private JPanel jPanel8 = null;
120
    private JLabel jLabel5 = null;
121
    private JComboBox jComboBox = null;
122
    private JLabel jLabel6 = null;
123
    private JTextField jTextField = null;
124
    private JLabel jLabel7 = null;
125
    private JComboBox jComboBox1 = null;
126
    private JCheckBox jCheckBoxSpatialIndex = null;
127
    /**
128
         * This is the default constructor
129
         */
130
        public FPanelScaleManager() {
131
                super();
132
                initialize();
133
        }
134
        /**
135
         * This method initializes this
136
         *
137
         * @return void
138
         */
139
        private  void initialize() {
140
                //setView();
141
                this.setLayout(null);
142
                //this.setLayer(null);
143
                this.setBounds(0, 0, 635, 352);
144
                this.add(getJCheckBoxSpatialIndex(), null);
145
                this.add(getJPanel(), null);
146
                this.add(getJPanel1(), null);
147
                this.add(getJPanel2(), null);
148
                this.add(getJPanel3(), null);
149
        }
150

    
151

    
152
    /**
153
     * Inicializa el ProjectView view. Es necesario para implementar el control de
154
     * escalas y para hiperenlazar documentos.
155
     * @return
156
     */
157
    /*private void setView() {
158
                View vista = (View) PluginServices.getMDIManager().getActiveView();
159
            view = vista.getModel();
160
    }*/
161

    
162
    /**
163
     * En esta funci?n se coge el primer tema activo del TOC y se usa su
164
     * renderer para inicializar. Hay que llamarla SIEMPRE que se abra el
165
     * cuadro de di?logo, en el  openLegendManager() de la vista.
166
     *
167
     * @param mapContext TOC que abre este cuadro de di?logo.
168
     * @throws DriverException
169
     */
170
    public void setMapContext(MapContext mapContext) throws ReadDriverException {
171
        layer = getFirstActiveLayerVect(mapContext.getLayers());
172
               /*try {
173
                                ClassifiableVectorial aux = (ClassifiableVectorial) layer;
174
                                renderer = (Legend) aux.getLegend().cloneLegend();
175
                        } catch (XMLException e) {
176
                                // TODO Auto-generated catch block
177
                                e.printStackTrace();
178
                        }*/
179
        actualizar();
180
    }
181

    
182
    /**
183
     * DOCUMENT ME!
184
     */
185
    private void actualizar() {
186
            // Avisar si no es Vectorial
187
            //FLayer lyrSelected = getFirstActiveLayerVect(mapContext.getLayers());
188

    
189
        /*m_defaultLegendPanel.setLayer(lyrSelected, renderer);
190
        m_valuesLegendPanel.setLayer(lyrSelected, renderer);
191
        m_breaksLegendPanel.setLayer(lyrSelected, renderer);
192
        m_labelsLegendPanel.setLayer(lyrSelected, renderer);*/
193

    
194
        /*CardLayout cl = (CardLayout)(cards.getLayout());
195
        if (renderer instanceof SingleSymbolLegend) {
196
                //organizador.setSelectedIndex(0);
197
            cl.show(cards, "symbol");
198
        }
199
        if (renderer instanceof UniqueValueLegend) {
200
                //organizador.setSelectedIndex(1);
201
            cl.show(cards, "values");
202
        }
203
        if (renderer instanceof IntervalLegend) {
204
                //organizador.setSelectedIndex(2);
205
            cl.show(cards, "intervals");
206
        }*/
207

    
208
        /* switch (m_Renderer.getLegendType()) {
209
        case FConstant.LEGEND_TYPE_DEFAULT:
210
            organizador.setSelectedIndex(0);
211

212
            break;
213

214
        case FConstant.LEGEND_TYPE_VALUE:
215
            organizador.setSelectedIndex(1);
216

217
            break;
218

219
        case FConstant.LEGEND_TYPE_BREAK:
220
            organizador.setSelectedIndex(2);
221

222
            break;
223
        } */
224
    }
225

    
226
        private void fillFieldNames() {
227
                DataSource rs;
228
                try {
229
                        rs = ((AlphanumericData)layer).getRecordset();
230
                        logger.debug("rs.start()");
231
                        rs.start();
232
                        String[] nomFields = new String[rs.getFieldCount()];
233
                        for (int i = 0; i < rs.getFieldCount(); i++) {
234
                                nomFields[i] = rs.getFieldName(i).trim();
235
                        }
236
                        rs.stop();
237
                } catch (ReadDriverException e) {
238
                        e.printStackTrace();
239
                }
240
        }
241

    
242
        public void setLayer(FLayer lyr, Legend r) {
243
        if (lyr instanceof FLyrVect)
244
        {
245
            FLyrVect lyrVect = (FLyrVect) lyr;
246
//            if (lyrVect.getSpatialIndex() == null)//azabala
247
            if(lyrVect.getISpatialIndex() == null)
248
            {
249
                getJCheckBoxSpatialIndex().setSelected(false);
250
            }
251
            else
252
            {
253
                getJCheckBoxSpatialIndex().setSelected(true);
254
            }
255
        }
256
                if (layer.getMinScale() != -1)
257
                    getJTextField1().setText(nf.format(layer.getMinScale()));
258
                if (layer.getMaxScale() != -1)
259
                    getJTextField2().setText(nf.format(layer.getMaxScale()));
260
                if (layer.getMinScale() == -1 && layer.getMaxScale() == -1) {
261
                        getJRadioButton().setSelected(true);
262
                        jLabel1.setEnabled(false);
263
                        jTextField1.setEnabled(false);
264
                        jLabel2.setEnabled(false);
265
                        jLabel3.setEnabled(false);
266
                        jTextField2.setEnabled(false);
267
                        jLabel4.setEnabled(false);
268
                } else {
269
                        getJRadioButton1().setSelected(true);
270
                        jLabel1.setEnabled(true);
271
                        jTextField1.setEnabled(true);
272
                        jLabel2.setEnabled(true);
273
                        jLabel3.setEnabled(true);
274
                        jTextField2.setEnabled(true);
275
                        jLabel4.setEnabled(true);
276
                }
277
                fillFieldNames();
278
                //getJComboBox().getModel().setSelectedItem(renderer.getFieldName());
279
                layer = lyr;
280
                txtLayerName.setText(layer.getName());
281
                showLayerInfo();
282
                /*
283
                try {
284
                        getJTextArea().setText(PluginServices.getText(this,"Extent") + "\n\t" + PluginServices.getText(this,"Superior") + ":\t" + layer.getFullExtent().getMaxY() + "\n\t" + PluginServices.getText(this,"Inferior") + ":\t" + layer.getFullExtent().getMinY() + "\n\t" + PluginServices.getText(this,"Izquierda") + ":\t" + layer.getFullExtent().getMinX() + "\n\t" + PluginServices.getText(this,"Derecha") + ":\t" + layer.getFullExtent().getMaxX() + "\n\n" + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName());
285
                } catch (DriverException e) {
286
                        // TODO Auto-generated catch block
287
                        e.printStackTrace();
288
                }
289
                */
290

    
291
        // Me parece que es aqu? donde hay que montar el jComboBox ...
292
                if (PluginServices.getMainFrame() != null)
293
                if  (PluginServices.getMDIManager().getActiveWindow() instanceof com.iver.cit.gvsig.project.documents.view.gui.BaseView ){
294
                    com.iver.cit.gvsig.project.documents.view.gui.BaseView theView = (com.iver.cit.gvsig.project.documents.view.gui.BaseView)PluginServices.getMDIManager().getActiveWindow();
295
                    view = theView.getModel();
296
            try {
297
                if (layer instanceof AlphanumericData) {
298
                    AlphanumericData ad = (AlphanumericData) layer;
299
                    DataSource ds;
300
                    ds = ad.getRecordset();
301
                    String[] names = new String[ds.getFieldCount()];
302
                    for (int i = 0; i < ds.getFieldCount(); i++) {
303
                        names[i] = ds.getFieldName(i);
304
                    }
305
                    //jComboBox = new javax.swing.JComboBox(names);
306
                    DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(names);
307
                    jComboBox.setModel(defaultModel);
308
                    if (view.getSelectedField() != null) {
309
                        jComboBox.setSelectedItem(view.getSelectedField());
310
                    }
311
                }else{
312
                    jComboBox = new javax.swing.JComboBox();
313
                }
314
            } catch (ReadDriverException e) {
315
                NotificationManager.addError("No se pudo obtener la tabla", e);
316
            }
317
            //
318

    
319
            // y aqu? el jTextField ...
320
            if (view.getSelectedField() != null) {
321
                getJTextField().setText(view.getExtLink());
322
            }
323
            //
324

    
325
            // y aqu? el jComboBox1 ...
326
            //jComboBox1 = new javax.swing.JComboBox();
327
            getJComboBox1().addItem(PluginServices.getText(this,
328
                    "Enlazar_a_ficheros_de_imagen"));
329
            getJComboBox1().addItem(PluginServices.getText(this,
330
            "Enlazar_a_fichero_de_texto"));
331
            if (view.getSelectedField() != null) {
332
                getJComboBox1().setSelectedIndex(view.getTypeLink());
333
            }
334
            //
335
        }
336
                // Si es de valor ?nico, rellenamos la tabla
337
                // y seleccionamos el campo que estamos usando
338
                //m_symbolTable.removeAllItems();
339
                if (r instanceof VectorialUniqueValueLegend)
340
                {
341
                        //renderer = (VectorialUniqueValueLegend) r;
342
                        //m_cboFields.getModel().setSelectedItem(m_Renderer.getFieldName());
343
                        //m_symbolTable.fillTableFromSymbolList(m_Renderer.getSymbols(),
344
                                        //m_Renderer.getValues(), m_Renderer.getDescriptions());
345
                }
346
                /*else
347
                {
348
                        try {
349
                                // Si la capa viene con otro tipo de leyenda, creamos
350
                                // una nueva del tipo que maneja este panel
351
                                renderer = new VectorialUniqueValueLegend(layer.getShapeType());
352
                        } catch (com.iver.cit.gvsig.fmap.DriverException e) {
353
                                // TODO Auto-generated catch block
354
                                e.printStackTrace();
355
                        }
356
                }*/
357
        }
358

    
359
        /*public void setLayerName(String layerName)
360
        {
361
                this.layerName = layerName;
362
        }*/
363

    
364
        /**
365
         * This method initializes jPanel
366
         *
367
         * @return javax.swing.JPanel
368
         */
369
        private JPanel getJPanel() {
370
                if (jPanel == null) {
371
                        jLabel = new JLabel();
372
                        jPanel = new JPanel();
373
                        jPanel.setLayout(null);
374
                        jLabel.setText(PluginServices.getText(this,"Nombre") + ":");
375
                        jLabel.setComponentOrientation(java.awt.ComponentOrientation.UNKNOWN);
376
                        jLabel.setBounds(0, 3, 78, 15);
377
                        jPanel.setComponentOrientation(java.awt.ComponentOrientation.UNKNOWN);
378
                        jPanel.setLocation(5, 6);
379
                        jPanel.setSize(357, 20);
380
                        jPanel.add(jLabel, null);
381
                        jPanel.add(getTxtLayerName(), null);
382
                }
383
                return jPanel;
384
        }
385
        /**
386
         * This method initializes jPanel1
387
         *
388
         * @return javax.swing.JPanel
389
         */
390
        private JPanel getJPanel1() {
391
                if (jPanel1 == null) {
392
                        jPanel1 = new JPanel();
393
                        jPanel1.setLayout(null);
394
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"rango_de_escalas"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
395
                        jPanel1.setBounds(5, 61, 432, 137);
396
                        jPanel1.add(getJPanel4(), null);
397
                        jPanel1.add(getJPanel5(), null);
398
                }
399
                return jPanel1;
400
        }
401
        /**
402
         * This method initializes jPanel2
403
         *
404
         * @return javax.swing.JPanel
405
         */
406
        private JPanel getJPanel2() {
407
                if (jPanel2 == null) {
408
                        jPanel2 = new JPanel();
409
                        jPanel2.setLayout(null);
410
                        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"propiedades"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
411
                        jPanel2.setBounds(5, 196, 303, 155);
412
                        jPanel2.add(getJScrollPane(), null);
413
                }
414
                return jPanel2;
415
        }
416
        /**
417
         * This method initializes jPanel4
418
         *
419
         * @return javax.swing.JPanel
420
         */
421
        private JPanel getJPanel4() {
422
                if (jPanel4 == null) {
423
                        jPanel4 = new JPanel();
424
                        jPanel4.setLayout(null);
425
                        jPanel4.setBounds(6, 21, 398, 46);
426
                        jPanel4.add(getJRadioButton(), null);
427
                        jPanel4.add(getJRadioButton1(), null);
428
                        buttonGroup = new ButtonGroup();
429
                        buttonGroup.add(getJRadioButton());
430
                        buttonGroup.add(getJRadioButton1());
431
                }
432
                return jPanel4;
433
        }
434
        /**
435
         * This method initializes jPanel5
436
         *
437
         * @return javax.swing.JPanel
438
         */
439
        private JPanel getJPanel5() {
440
                if (jPanel5 == null) {
441
                        jLabel4 = new JLabel();
442
                        jLabel3 = new JLabel();
443
                        jLabel2 = new JLabel();
444
                        jLabel1 = new JLabel();
445
                        jPanel5 = new JPanel();
446
                        jPanel5.setLayout(null);
447
                        jLabel1.setText(PluginServices.getText(this,"este_por_debajo_de_"));
448
                        jLabel1.setBounds(6, 6, 138, 20);
449
                        jLabel1.setEnabled(false);
450
                        jLabel2.setText("(" + PluginServices.getText(this,"escala_minima") + ")");
451
                        jLabel2.setBounds(302, 6, 111, 20);
452
                        jLabel2.setEnabled(false);
453
                        jPanel5.setBounds(15, 69, 414, 53);
454
                        jLabel3.setBounds(6, 31, 138, 20);
455
                        jLabel3.setText(PluginServices.getText(this,"este_por_encima_de"));
456
                        jLabel3.setEnabled(false);
457
                        jLabel4.setBounds(302, 31, 111, 20);
458
                        jLabel4.setText("(" + PluginServices.getText(this,"escala_maxima") + ")");
459
                        jLabel4.setEnabled(false);
460
                        jPanel5.add(jLabel1, null);
461
                        jPanel5.add(getJTextField1(), null);
462
                        jPanel5.add(jLabel2, null);
463
                        jPanel5.add(jLabel3, null);
464
                        jPanel5.add(getJTextField2(), null);
465
                        jPanel5.add(jLabel4, null);
466
                }
467
                return jPanel5;
468
        }
469
        /**
470
         * This method initializes jTextField
471
         *
472
         * @return javax.swing.JTextField
473
         */
474
        private JTextField getTxtLayerName() {
475
                if (txtLayerName == null) {
476
                        //System.out.println("getJTestField(): layer = " + layer);
477
                        //layerName = layer.getName();
478
                        txtLayerName = new JTextField();
479
                        //jTextField.setText(layerName);
480
                        txtLayerName.setEditable(true);
481
                        txtLayerName.setBounds(80, 0, 229, 20);
482
                }
483
                return txtLayerName;
484
        }
485
        /**
486
         * This method initializes jTextField1
487
         *
488
         * @return javax.swing.JTextField
489
         */
490
        public JTextField getJTextField1() {
491
                if (jTextField1 == null) {
492
                        jTextField1 = new JTextField();
493
                        jTextField1.setBounds(147, 6, 152, 20);
494
                        jTextField1.setEnabled(false);
495
                }
496
                return jTextField1;
497
        }
498
        /**
499
         * This method initializes jTextArea
500
         *
501
         * @return javax.swing.JTextArea
502
         */
503
        private JTextArea getJTextArea() {
504
                if (jTextArea == null) {
505
                        jTextArea = new JTextArea();
506
                        jTextArea.setEditable(false);
507
                        jTextArea.setBackground(java.awt.SystemColor.control);
508
                        //jTextArea.setText("Extent\n\tSuperior\n\tInferior\n\tIzquierda\n\tDerecha\n\nOrigen de datos\n\n... y movidas ...");
509
                }
510
                return jTextArea;
511
        }
512

    
513
        /*public void setLayer(FLayer layer) {
514
                this.layer = layer;
515
        }*/
516
        /**
517
         * This method initializes jScrollPane
518
         *
519
         * @return javax.swing.JScrollPane
520
         */
521
        private JScrollPane getJScrollPane() {
522
                if (jScrollPane == null) {
523
                        jScrollPane = new JScrollPane();
524
                        jScrollPane.setViewportView(getJTextArea());
525
                        jScrollPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
526
                        jScrollPane.setPreferredSize(new java.awt.Dimension(100,100));
527
                        jScrollPane.setBounds(6, 21, 283, 120);
528
                }
529
                return jScrollPane;
530
        }
531
        /**
532
         * This method initializes jRadioButton
533
         *
534
         * @return javax.swing.JRadioButton
535
         */
536
        public JRadioButton getJRadioButton() {
537
                if (jRadioButton == null) {
538
                        jRadioButton = new JRadioButton();
539
                        jRadioButton.setText(PluginServices.getText(this,"Mostrar_siempre"));
540
                        jRadioButton.setBounds(0, 0, 301, 23);
541
                        jRadioButton.setSelected(true);
542
                        jRadioButton.addActionListener(new java.awt.event.ActionListener() {
543
                                public void actionPerformed(java.awt.event.ActionEvent e) {
544
                                        //jPanel5.setEnabled(false);
545
                                        jLabel1.setEnabled(false);
546
                                        jTextField1.setEnabled(false);
547
                                        jLabel2.setEnabled(false);
548
                                        jLabel3.setEnabled(false);
549
                                        jTextField2.setEnabled(false);
550
                                        jLabel4.setEnabled(false);
551
                                }
552
                        });
553
                }
554
                return jRadioButton;
555
        }
556
        /**
557
         * This method initializes jRadioButton1
558
         *
559
         * @return javax.swing.JRadioButton
560
         */
561
        public JRadioButton getJRadioButton1() {
562
                if (jRadioButton1 == null) {
563
                        jRadioButton1 = new JRadioButton();
564
                        jRadioButton1.setText(PluginServices.getText(this,"No_mostrar_la_capa_cuando_la_escala"));
565
                        jRadioButton1.setBounds(0, 23, 301, 23);
566
                        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
567
                                public void actionPerformed(java.awt.event.ActionEvent e) {
568
                                        //jPanel5.setEnabled(true);
569
                                        jLabel1.setEnabled(true);
570
                                        jTextField1.setEnabled(true);
571
                                        jLabel2.setEnabled(true);
572
                                        jLabel3.setEnabled(true);
573
                                        jTextField2.setEnabled(true);
574
                                        jLabel4.setEnabled(true);
575
                                }
576
                        });
577
                }
578
                return jRadioButton1;
579
        }
580
        /**
581
         * This method initializes jTextField2
582
         *
583
         * @return javax.swing.JTextField
584
         */
585
        public JTextField getJTextField2() {
586
                if (jTextField2 == null) {
587
                        jTextField2 = new JTextField();
588
                        jTextField2.setBounds(147, 31, 152, 20);
589
                        jTextField2.setEnabled(false);
590
                }
591
                return jTextField2;
592
        }
593
        public String getLayerName(){
594
                return txtLayerName.getText().toString();
595
        }
596
    /**
597
     * This method initializes jPanel3
598
     *
599
     * @return javax.swing.JPanel
600
     */
601
    private JPanel getJPanel3() {
602
            if (jPanel3 == null) {
603
                    jPanel3 = new JPanel();
604
                    jPanel3.setLayout(null);
605
                    jPanel3.setBounds(315, 195, 313, 154);
606
                    jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED), PluginServices.getText(this, "Hiperenlace"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
607
                    jPanel3.add(getJPanel6(), null);
608
            }
609
            return jPanel3;
610
    }
611
    /**
612
     * This method initializes jPanel6
613
     *
614
     * @return javax.swing.JPanel
615
     */
616
    private JPanel getJPanel6() {
617
            if (jPanel6 == null) {
618
                    jPanel6 = new JPanel();
619
                    jPanel6.setLayout(new BorderLayout());
620
                    jPanel6.setBounds(7, 22, 298, 119);
621
                    jPanel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
622
                    jPanel6.add(getJPanel7(), java.awt.BorderLayout.NORTH);
623
                    jPanel6.add(getJPanel8(), java.awt.BorderLayout.CENTER);
624
            }
625
            return jPanel6;
626
    }
627
    /**
628
     * This method initializes jPanel7
629
     *
630
     * @return javax.swing.JPanel
631
     */
632
    private JPanel getJPanel7() {
633
            if (jPanel7 == null) {
634
                    jLabel6 = new JLabel();
635
                    jLabel6.setText(PluginServices.getText(this,"extension"));
636
                    jLabel5 = new JLabel();
637
                    jLabel5.setText(PluginServices.getText(this, "Campo") + "   ");
638
                    jPanel7 = new JPanel();
639
                    jPanel7.add(jLabel5, null);
640
                    jPanel7.add(getJComboBox(), null);
641
                    jPanel7.add(jLabel6, null);
642
                    jPanel7.add(getJTextField(), null);
643
            }
644
            return jPanel7;
645
    }
646
    /**
647
     * This method initializes jPanel8
648
     *
649
     * @return javax.swing.JPanel
650
     */
651
    private JPanel getJPanel8() {
652
            if (jPanel8 == null) {
653
                    jLabel7 = new JLabel();
654
                    jLabel7.setText(PluginServices.getText(this, "Accion_Predefinida") + "  ");
655
                    jPanel8 = new JPanel();
656
                    jPanel8.add(jLabel7, null);
657
                    jPanel8.add(getJComboBox1(), null);
658
            }
659
            return jPanel8;
660
    }
661
    /**
662
     * This method initializes jComboBox
663
     *
664
     * @return javax.swing.JComboBox
665
     */
666
    private JComboBox getJComboBox() {
667
            if (jComboBox == null) {
668
            jComboBox = new JComboBox();
669
            }
670
            return jComboBox;
671
    }
672
    /**
673
     * This method initializes jTextField
674
     *
675
     * @return javax.swing.JTextField
676
     */
677
    private JTextField getJTextField() {
678
            if (jTextField == null) {
679
                    jTextField = new JTextField();
680
            jTextField.setPreferredSize(new java.awt.Dimension(40,20));
681
            }
682
            return jTextField;
683
    }
684
    /**
685
     * This method initializes jComboBox1
686
     *
687
     * @return javax.swing.JComboBox
688
     */
689
    private JComboBox getJComboBox1() {
690
            if (jComboBox1 == null) {
691
                    jComboBox1 = new JComboBox();
692
            }
693
            return jComboBox1;
694
    }
695
    /**
696
     * @return Returns the view.
697
     */
698
    public IProjectView getView() {
699
        return view;
700
    }
701
    /**
702
     * This method initializes jCheckBox
703
     *
704
     * @return javax.swing.JCheckBox
705
     */
706
    private JCheckBox getJCheckBoxSpatialIndex() {
707
            if (jCheckBoxSpatialIndex == null) {
708
                    jCheckBoxSpatialIndex = new JCheckBox();
709
                    jCheckBoxSpatialIndex.setBounds(2, 33, 242, 23);
710
                    jCheckBoxSpatialIndex.setText(PluginServices.getText(this,"Usar_indice_espacial"));
711
            }
712
            return jCheckBoxSpatialIndex;
713
    }
714

    
715
    public int getLinkType()
716
    {
717
        return getJComboBox1().getSelectedIndex();
718
    }
719
    public String getSelectedLinkField()
720
    {
721
        return (String) getJComboBox().getSelectedItem();
722
    }
723

    
724
    public String getExtensionLink()
725
    {
726
        return getJTextField().getText();
727
    }
728

    
729
    public boolean isSpatialIndexSelected()
730
    {
731
        return getJCheckBoxSpatialIndex().isSelected();
732
    }
733

    
734
    private void showLayerInfo() {
735
                try {
736
                        String info = ((FLyrDefault)layer).getInfoString();
737
                        if (info == null) {
738
                                info = PluginServices.getText(this,"Extent") + "\n\t" +
739
                                PluginServices.getText(this,"Superior") + ":\t" + layer.getFullExtent().getMaxY() + "\n\t" +
740
                                PluginServices.getText(this,"Inferior") + ":\t" + layer.getFullExtent().getMinY() + "\n\t" +
741
                                PluginServices.getText(this,"Izquierda") + ":\t" + layer.getFullExtent().getMinX() + "\n\t" +
742
                                PluginServices.getText(this,"Derecha") + ":\t" + layer.getFullExtent().getMaxX() + "\n\n";
743

    
744
                                if (layer instanceof FLyrVect) {
745
                                        ReadableVectorial rv=((FLyrVect)layer).getSource();
746
                                        if (rv instanceof VectorialEditableAdapter) {
747
                                                rv=((VectorialEditableAdapter) ((FLyrVect)layer).getSource()).getOriginalAdapter();
748
                                        }
749

    
750
                                        info = info + PluginServices.getText(this,"Origen_de_datos") + ": ";
751
                                        if (rv instanceof VectorialFileAdapter) {
752
                                                info = info + "\n" + rv.getDriver().getName() + "\n" +
753
                                                PluginServices.getText(this,"fichero") +": " + ((VectorialFileAdapter)rv).getFile();
754

    
755
                                        } else if (rv instanceof VectorialDBAdapter) {
756
                                                DBLayerDefinition dbdef = ((VectorialDBAdapter) rv).getLyrDef();
757
                                                info = info + "\n" + rv.getDriver().getName() + "\n";
758

    
759
                                                try {
760
                                                        info = info +
761
                                                        PluginServices.getText(this,"url") +": " + dbdef.getConnection().getMetaData().getURL() + "\n";
762
                                                } catch (Exception e) {
763
                                                        //TODO: Que hacer aqui?
764
                                                        e.printStackTrace();
765
                                                }
766

    
767
                                                info = info +
768
                                                PluginServices.getText(this,"Tabla") +": " + dbdef.getTableName() + "\n";
769
                                        } else if (rv instanceof VectorialAdapter){
770
                                                info = info + "\n" + rv.getDriver().getName() + "\n";
771
                                        }
772

    
773

    
774

    
775
                                } else {
776
                                        info = info + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName();
777
                                }
778

    
779
                        }
780
                        getJTextArea().setText(info);
781

    
782
                } catch (ReadDriverException e) {
783
                        e.printStackTrace();
784
                } catch (ExpansionFileReadException e) {
785
                        e.printStackTrace();
786
                }
787

    
788
    }
789
}  //  @jve:decl-index=0:visual-constraint="10,10"
790