Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / FThemePropertiesDialog.java @ 1174

History | View | Annotate | Download (12.9 KB)

1
/*
2
 * Created on 31-may-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig.gui;
48

    
49
import javax.swing.JLabel;
50
import javax.swing.JPanel;
51
import javax.swing.JTextField;
52

    
53
import com.hardcode.gdbms.engine.data.DataSource;
54
import com.hardcode.gdbms.engine.data.DriverException;
55
import com.iver.andami.PluginServices;
56
import com.iver.andami.messages.NotificationManager;
57
import com.iver.andami.ui.mdiManager.View;
58
import com.iver.andami.ui.mdiManager.ViewInfo;
59
import com.iver.cit.gvsig.fmap.layers.FLayer;
60
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
61
import com.iver.cit.gvsig.project.castor.ProjectView;
62
/**
63
 * Di?logo de propiedades del tema.
64
 *
65
 * @author Vicente Caballero Navarro
66
 */
67
public class FThemePropertiesDialog extends JPanel implements View {
68
        private javax.swing.JPanel jContentPane = null;
69
        private javax.swing.JTabbedPane jTabbedPane = null;
70
        private javax.swing.JPanel phiperenlace = null;
71
        private javax.swing.JPanel phnorte = null;
72
        private javax.swing.JPanel phsur = null;
73
        private javax.swing.JLabel jLabel = null;
74
        private javax.swing.JComboBox jComboBox = null;
75
        private javax.swing.JLabel jLabel1 = null;
76
        private javax.swing.JComboBox jComboBox1 = null;
77
        private javax.swing.JPanel pbotones = null;
78
        private javax.swing.JButton baceptar = null;
79
        private javax.swing.JButton bcancelar = null;
80
        private javax.swing.JPanel pvisualizacion = null;
81
        private FLayer m_layer;
82
        private javax.swing.JPanel pvnorte = null;
83
        private javax.swing.JPanel pvsur = null;
84
        private javax.swing.JLabel jLabel2 = null;
85
        private javax.swing.JLabel jLabel3 = null;
86
        private javax.swing.JTextField tminEscala = null;
87
        private javax.swing.JTextField jTextField1 = null;
88
        private ProjectView view;
89

    
90
        private JLabel jLabel4 = null;
91
        private JTextField jTextField2 = null;
92
        private JPanel pvCenter = null;
93
        private JLabel jLabel5 = null;
94
        private JLabel jLabel6 = null;
95
        /**
96
         * This is the default constructor
97
         *
98
         * @param layer DOCUMENT ME!
99
         * @param view DOCUMENT ME!
100
         */
101
        public FThemePropertiesDialog(FLayer layer, ProjectView view) {
102
                super();
103
                this.view = view;
104
                m_layer = layer;
105
                initialize();
106
        }
107

    
108
        /**
109
         * This method initializes this
110
         */
111
        private void initialize() {
112
                this.setSize(367, 184);
113
                this.add(getJContentPane());
114
        }
115

    
116
        /**
117
         * This method initializes jContentPane
118
         *
119
         * @return javax.swing.JPanel
120
         */
121
        private javax.swing.JPanel getJContentPane() {
122
                if (jContentPane == null) {
123
                        jContentPane = new javax.swing.JPanel();
124
                        jContentPane.setLayout(new java.awt.BorderLayout());
125
                        jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
126
                        jContentPane.add(getPbotones(), java.awt.BorderLayout.SOUTH);
127
                }
128

    
129
                return jContentPane;
130
        }
131

    
132
        /**
133
         * This method initializes jTabbedPane
134
         *
135
         * @return javax.swing.JTabbedPane
136
         */
137
        private javax.swing.JTabbedPane getJTabbedPane() {
138
                if (jTabbedPane == null) {
139
                        jTabbedPane = new javax.swing.JTabbedPane();
140
                        jTabbedPane.setPreferredSize(new java.awt.Dimension(320,140));
141
                        jTabbedPane.addTab(PluginServices.getText(this, "Hiperenlace"),
142
                                null, getPhiperenlace(), null);
143
                        jTabbedPane.addTab(PluginServices.getText(this, "Visualizacion"),
144
                                null, getPvisualizacion(), null);
145
                }
146

    
147
                return jTabbedPane;
148
        }
149

    
150
        /**
151
         * This method initializes phiperenlace
152
         *
153
         * @return javax.swing.JPanel
154
         */
155
        private javax.swing.JPanel getPhiperenlace() {
156
                if (phiperenlace == null) {
157
                        phiperenlace = new javax.swing.JPanel();
158
                        phiperenlace.setLayout(new java.awt.BorderLayout());
159
                        phiperenlace.setPreferredSize(new java.awt.Dimension(300,150));
160
                        phiperenlace.add(getPhnorte(), java.awt.BorderLayout.NORTH);
161
                        phiperenlace.add(getPhsur(), java.awt.BorderLayout.CENTER);
162
                        phiperenlace.setVisible(true);
163
                }
164

    
165
                return phiperenlace;
166
        }
167

    
168
        /**
169
         * This method initializes phnorte
170
         *
171
         * @return javax.swing.JPanel
172
         */
173
        private javax.swing.JPanel getPhnorte() {
174
                if (phnorte == null) {
175
                        jLabel4 = new JLabel();
176
                        phnorte = new javax.swing.JPanel();
177
                        jLabel4.setText(PluginServices.getText(this,"extension"));
178
                        phnorte.add(getJLabel(), null);
179
                        phnorte.add(getJComboBox(), null);
180
                        phnorte.add(jLabel4, null);
181
                        phnorte.add(getJTextField2(), null);
182
                }
183

    
184
                return phnorte;
185
        }
186

    
187
        /**
188
         * This method initializes phsur
189
         *
190
         * @return javax.swing.JPanel
191
         */
192
        private javax.swing.JPanel getPhsur() {
193
                if (phsur == null) {
194
                        phsur = new javax.swing.JPanel();
195
                        phsur.add(getJLabel1(), null);
196
                        phsur.add(getJComboBox1(), null);
197
                }
198

    
199
                return phsur;
200
        }
201

    
202
        /**
203
         * This method initializes jLabel
204
         *
205
         * @return javax.swing.JLabel
206
         */
207
        private javax.swing.JLabel getJLabel() {
208
                if (jLabel == null) {
209
                        jLabel = new javax.swing.JLabel();
210
                        jLabel.setText(PluginServices.getText(this, "Campo") + "   ");
211
                }
212

    
213
                return jLabel;
214
        }
215

    
216
        /**
217
         * This method initializes jComboBox
218
         *
219
         * @return javax.swing.JComboBox
220
         */
221
        private javax.swing.JComboBox getJComboBox() {
222
                if (jComboBox == null) {
223
                        try {
224
                                if (m_layer instanceof AlphanumericData) {
225
                                        AlphanumericData layer = (AlphanumericData) m_layer;
226
                                        DataSource ds;
227
                                        ds = layer.getRecordset();
228

    
229
                                        String[] names = new String[ds.getFieldCount()];
230

    
231
                                        for (int i = 0; i < ds.getFieldCount(); i++) {
232
                                                names[i] = ds.getFieldName(i);
233
                                        }
234

    
235
                                        jComboBox = new javax.swing.JComboBox(names);
236

    
237
                                        if (view.getSelectedField() != null) {
238
                                                jComboBox.setSelectedItem(view.getSelectedField());
239
                                        }
240
                                }
241
                        } catch (DriverException e) {
242
                                NotificationManager.addError("No se pudo obtener la tabla", e);
243
                        } catch (com.iver.cit.gvsig.fmap.DriverException e) {
244
                                NotificationManager.addError("Error accediendo a los datos", e);
245
                        }
246
                }
247

    
248
                return jComboBox;
249
        }
250

    
251
        /**
252
         * This method initializes jLabel1
253
         *
254
         * @return javax.swing.JLabel
255
         */
256
        private javax.swing.JLabel getJLabel1() {
257
                if (jLabel1 == null) {
258
                        jLabel1 = new javax.swing.JLabel();
259
                        jLabel1.setText(PluginServices.getText(this, "Accion_Predefinida") +
260
                                "  ");
261
                }
262

    
263
                return jLabel1;
264
        }
265

    
266
        /**
267
         * This method initializes jComboBox1
268
         *
269
         * @return javax.swing.JComboBox
270
         */
271
        private javax.swing.JComboBox getJComboBox1() {
272
                if (jComboBox1 == null) {
273
                        jComboBox1 = new javax.swing.JComboBox();
274
                        jComboBox1.addItem(PluginServices.getText(this,
275
                                        "Enlazar_a_ficheros_de_imagen"));
276
                        jComboBox1.addItem(PluginServices.getText(this,
277
                        "Enlazar_a_fichero_de_texto"));
278
                        if (view.getSelectedField() != null) {
279
                                jComboBox1.setSelectedIndex(view.getTypeLink());
280
                        }
281
                }
282

    
283
                return jComboBox1;
284
        }
285

    
286
        /**
287
         * This method initializes pbotones
288
         *
289
         * @return javax.swing.JPanel
290
         */
291
        private javax.swing.JPanel getPbotones() {
292
                if (pbotones == null) {
293
                        pbotones = new javax.swing.JPanel();
294
                        pbotones.add(getBaceptar(), null);
295
                        pbotones.add(getBcancelar(), null);
296
                }
297

    
298
                return pbotones;
299
        }
300

    
301
        /**
302
         * This method initializes baceptar
303
         *
304
         * @return javax.swing.JButton
305
         */
306
        private javax.swing.JButton getBaceptar() {
307
                if (baceptar == null) {
308
                        baceptar = new javax.swing.JButton();
309
                        baceptar.setText(PluginServices.getText(this, "Aceptar"));
310
                        baceptar.addActionListener(new java.awt.event.ActionListener() {
311
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
312
                                                view.setTypeLink(jComboBox1.getSelectedIndex());
313
                                                view.setSelectedField((jComboBox.getSelectedItem()).toString()
314
                                                                                           .trim());
315
                                                view.setExtLink(getJTextField2().getText());
316
                                                
317
                                                        m_layer.setMinEscala(Double.parseDouble(getTminEscala().getText()));
318
                                                        m_layer.setMaxEscala(Double.parseDouble(getTmaxEscala().getText()));
319
                                                PluginServices.getMDIManager().closeView(FThemePropertiesDialog.this);
320
                                        }
321
                                });
322
                }
323

    
324
                return baceptar;
325
        }
326

    
327
        /**
328
         * This method initializes bcancelar
329
         *
330
         * @return javax.swing.JButton
331
         */
332
        private javax.swing.JButton getBcancelar() {
333
                if (bcancelar == null) {
334
                        bcancelar = new javax.swing.JButton();
335
                        bcancelar.setText(PluginServices.getText(this, "Cancelar"));
336
                        bcancelar.addActionListener(new java.awt.event.ActionListener() {
337
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
338
                                                //                                        View view =(View)App.instance.getMDIContext().getActiveView();
339
                                                //view.getMapControl().setTool(MapControl.);
340
                                                PluginServices.getMDIManager().closeView(FThemePropertiesDialog.this);
341
                                        }
342
                                });
343
                }
344

    
345
                return bcancelar;
346
        }
347

    
348
        /**
349
         * This method initializes pvisualizacion
350
         *
351
         * @return javax.swing.JPanel
352
         */
353
        private javax.swing.JPanel getPvisualizacion() {
354
                if (pvisualizacion == null) {
355
                        pvisualizacion = new javax.swing.JPanel();
356
                        pvisualizacion.setLayout(new java.awt.BorderLayout());
357
                        pvisualizacion.setPreferredSize(new java.awt.Dimension(300,60));
358
                        pvisualizacion.add(getPvnorte(), java.awt.BorderLayout.NORTH);
359
                        pvisualizacion.add(getPvCenter(), java.awt.BorderLayout.CENTER);
360
                        pvisualizacion.add(getPvsur(), java.awt.BorderLayout.SOUTH);
361
                }
362

    
363
                return pvisualizacion;
364
        }
365

    
366
        /**
367
         * This method initializes pvnorte
368
         *
369
         * @return javax.swing.JPanel
370
         */
371
        private javax.swing.JPanel getPvnorte() {
372
                if (pvnorte == null) {
373
                        jLabel6 = new JLabel();
374
                        jLabel5 = new JLabel();
375
                        pvnorte = new javax.swing.JPanel();
376
                        jLabel5.setText(m_layer.getName());
377
                        jLabel6.setText("Nombre del tema : ");
378
                        pvnorte.add(jLabel6, null);
379
                        pvnorte.add(jLabel5, null);
380
                }
381

    
382
                return pvnorte;
383
        }
384

    
385
        /**
386
         * This method initializes pvsur
387
         *
388
         * @return javax.swing.JPanel
389
         */
390
        private javax.swing.JPanel getPvsur() {
391
                if (pvsur == null) {
392
                        pvsur = new javax.swing.JPanel();
393
                        pvsur.add(getJLabel3(), null);
394
                        pvsur.add(getJTextField1(), null);
395
                }
396

    
397
                return pvsur;
398
        }
399

    
400
        /**
401
         * This method initializes jLabel2
402
         *
403
         * @return javax.swing.JLabel
404
         */
405
        private javax.swing.JLabel getJLabel2() {
406
                if (jLabel2 == null) {
407
                        jLabel2 = new javax.swing.JLabel();
408
                        jLabel2.setText(PluginServices.getText(this, "Escala_Minima") +
409
                                "  ");
410
                }
411

    
412
                return jLabel2;
413
        }
414

    
415
        /**
416
         * This method initializes jLabel3
417
         *
418
         * @return javax.swing.JLabel
419
         */
420
        private javax.swing.JLabel getJLabel3() {
421
                if (jLabel3 == null) {
422
                        jLabel3 = new javax.swing.JLabel();
423
                        jLabel3.setText(PluginServices.getText(this, "Escala_Maxima") +
424
                                "  ");
425
                }
426

    
427
                return jLabel3;
428
        }
429

    
430
        /**
431
         * This method initializes tminEscala
432
         *
433
         * @return javax.swing.JTextField
434
         */
435
        private javax.swing.JTextField getTminEscala() {
436
                if (tminEscala == null) {
437
                        tminEscala = new javax.swing.JTextField();
438
                        tminEscala.setPreferredSize(new java.awt.Dimension(150, 20));
439
                }
440

    
441
                return tminEscala;
442
        }
443

    
444
        /**
445
         * This method initializes jTextField1
446
         *
447
         * @return javax.swing.JTextField
448
         */
449
        private javax.swing.JTextField getJTextField1() {
450
                if (jTextField1 == null) {
451
                        jTextField1 = new javax.swing.JTextField();
452
                        jTextField1.setPreferredSize(new java.awt.Dimension(150, 20));
453
                }
454

    
455
                return jTextField1;
456
        }
457

    
458
        /* (non-Javadoc)
459
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
460
         */
461
        public ViewInfo getViewInfo() {
462
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
463
                m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_tema"));
464

    
465
                return m_viewinfo;
466
        }
467

    
468
        /**
469
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
470
         */
471
        public void viewActivated() {
472
        }
473
        /**
474
         * This method initializes jTextField2        
475
         *         
476
         * @return javax.swing.JTextField        
477
         */    
478
        private JTextField getJTextField2() {
479
                if (jTextField2 == null) {
480
                        jTextField2 = new JTextField();
481
                        jTextField2.setPreferredSize(new java.awt.Dimension(40,20));
482
                        if (view.getSelectedField() != null) {
483
                                jTextField2.setText(view.getExtLink());
484
                        }
485
                }
486
                return jTextField2;
487
        }
488
        /**
489
         * This method initializes pvCenter        
490
         *         
491
         * @return javax.swing.JPanel        
492
         */    
493
        private JPanel getPvCenter() {
494
                if (pvCenter == null) {
495
                        pvCenter = new JPanel();
496
                        pvCenter.add(getJLabel2(), null);
497
                        pvCenter.add(getTminEscala(), null);
498
                }
499
                return pvCenter;
500
        }
501
  } //  @jve:visual-info  decl-index=0 visual-constraint="10,10"