Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / project / ViewProperties.java @ 1277

History | View | Annotate | Download (19.1 KB)

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

    
43

    
44
import java.awt.Color;
45

    
46
import javax.swing.JButton;
47
import javax.swing.JColorChooser;
48
import javax.swing.JLabel;
49
import javax.swing.JPanel;
50

    
51
import com.iver.andami.PluginServices;
52
import com.iver.andami.ui.mdiManager.View;
53
import com.iver.andami.ui.mdiManager.ViewInfo;
54
import com.iver.cit.gvsig.gui.Dialogs.CSSelectionDialog;
55
import com.iver.cit.gvsig.gui.Panels.ProjChooserPanel;
56
import com.iver.cit.gvsig.gui.layout.Attributes;
57
import com.iver.cit.gvsig.project.ProjectView;
58
/**
59
 * Dialogo donde se muestran las propiedades de una vista
60
 *
61
 * @author Fernando Gonz?lez Cort?s
62
 */
63
public class ViewProperties extends JPanel implements View{
64
    /*private String[] units = new String[] {
65
            PluginServices.getText(this, "metros"),
66
            PluginServices.getText(this, "kilometros"),
67
        };
68
    */
69
    private javax.swing.JPanel jContentPane = null;
70
    private javax.swing.JLabel jLabel = null;
71
    private javax.swing.JTextField txtName = null;
72
    private javax.swing.JLabel jLabel1 = null;
73
    private javax.swing.JTextField txtDate = null;
74
    private javax.swing.JLabel jLabel2 = null;
75
    private javax.swing.JTextField txtOwner = null;
76
    private javax.swing.JLabel jLabel4 = null;
77
    private javax.swing.JComboBox cmbMapUnits = null;
78
    private javax.swing.JLabel jLabel5 = null;
79
    private javax.swing.JComboBox cmbDistanceUnits = null;
80
    private javax.swing.JLabel jLabel6 = null;
81
    private javax.swing.JTextArea txtComments = null;
82
    private javax.swing.JLabel jLabel7 = null;
83
    private javax.swing.JLabel lblColor = null;
84
    private javax.swing.JButton btnColor = null;
85
    private javax.swing.JButton btnOk = null;
86
    private javax.swing.JButton btnCancel = null;
87
    private ProjectView view=null;
88
    private javax.swing.JScrollPane jScrollPane = null;
89
    private javax.swing.JPanel jPanel = null;
90
    private javax.swing.JPanel jPanel1 = null;
91
    private javax.swing.JPanel jPanel2 = null;
92
    private javax.swing.JPanel jPanel3 = null;
93
    private javax.swing.JLabel jLabel3 = null;
94
    private ViewInfo m_viewinfo = null;
95
        private JLabel jLblProj = null;
96
        private JLabel jLblProjName = null;
97
        private JButton jBtnChangeProj = null;
98
        private JPanel jPanelProj = null;
99
    /**
100
     * This is the default constructor
101
     *
102
     * @param f Frame padre del dialogo
103
     * @param v Vista que se representa
104
     */
105
    public ViewProperties(ProjectView v) {
106
        view = v;
107
        initialize();
108
    }
109

    
110
    /**
111
     * This method initializes this
112
     */
113
    private void initialize() {
114
        jLblProjName = new JLabel();
115
        jLblProj = new JLabel();
116
        this.setSize(365, 343);
117
                java.awt.FlowLayout layFlowLayout3 = new java.awt.FlowLayout();
118
                layFlowLayout3.setHgap(0);
119
                setLayout(layFlowLayout3);
120
                jLblProj.setText(view.getProjection().getAbrev());
121
                jLblProj.setPreferredSize(new java.awt.Dimension(180,20));
122
                jLblProjName.setText("Proyecci?n actual:");
123
                jLblProjName.setPreferredSize(new java.awt.Dimension(95,15));
124
                this.setPreferredSize(new java.awt.Dimension(365,343));
125
                add(getJPanel(), null);
126
                add(getJPanel1(), null);
127
                add(getJPanel2(), null);
128
                add(getJPanel3(), null);
129
                this.add(getJPanelProj(), null);
130
                this.add(getJLabel6(), null);
131
                add(getJScrollPane(), null);
132
                this.add(getJLabel7(), null);
133
                this.add(getLblColor(), null);
134
                this.add(getBtnColor(), null);
135
                add(getJLabel3(), null);
136
                this.add(getBtnOk(), null);
137
                this.add(getBtnCancel(), null);
138
        txtName.setText(view.getName());
139
        txtDate.setText(view.getCreationDate());
140
        txtOwner.setText(view.getOwner());
141

    
142
        cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort().getMapUnits());
143
        cmbDistanceUnits.setSelectedIndex(view.getMapContext().getViewPort().getDistanceUnits());
144

    
145
        txtComments.setText(view.getComment());
146

    
147
        lblColor.setBackground(view.getMapContext().getViewPort().getBackColor());
148
    }
149

    
150
    /**
151
     * This method initializes jLabel
152
     *
153
     * @return javax.swing.JLabel
154
     */
155
    private javax.swing.JLabel getJLabel() {
156
        if (jLabel == null) {
157
            jLabel = new javax.swing.JLabel();
158
            jLabel.setText(PluginServices.getText(this, "nombre") + ":");
159
        }
160

    
161
        return jLabel;
162
    }
163

    
164
    /**
165
     * This method initializes txtName
166
     *
167
     * @return javax.swing.JTextField
168
     */
169
    private javax.swing.JTextField getTxtName() {
170
        if (txtName == null) {
171
            txtName = new javax.swing.JTextField();
172
            txtName.setPreferredSize(new java.awt.Dimension(220, 20));
173
        }
174

    
175
        return txtName;
176
    }
177

    
178
    /**
179
     * This method initializes jLabel1
180
     *
181
     * @return javax.swing.JLabel
182
     */
183
    private javax.swing.JLabel getJLabel1() {
184
        if (jLabel1 == null) {
185
            jLabel1 = new javax.swing.JLabel();
186
            jLabel1.setText(PluginServices.getText(this, "creation_date") + ":");
187
        }
188

    
189
        return jLabel1;
190
    }
191

    
192
    /**
193
     * This method initializes txtDate
194
     *
195
     * @return javax.swing.JTextField
196
     */
197
    private javax.swing.JTextField getTxtDate() {
198
        if (txtDate == null) {
199
            txtDate = new javax.swing.JTextField();
200
            txtDate.setPreferredSize(new java.awt.Dimension(220, 20));
201
            txtDate.setEditable(false);
202
            txtDate.setBackground(java.awt.Color.white);
203
        }
204

    
205
        return txtDate;
206
    }
207

    
208
    /**
209
     * This method initializes jLabel2
210
     *
211
     * @return javax.swing.JLabel
212
     */
213
    private javax.swing.JLabel getJLabel2() {
214
        if (jLabel2 == null) {
215
            jLabel2 = new javax.swing.JLabel();
216
            jLabel2.setText(PluginServices.getText(this, "owner") + ":");
217
        }
218

    
219
        return jLabel2;
220
    }
221

    
222
    /**
223
     * This method initializes txtOwner
224
     *
225
     * @return javax.swing.JTextField
226
     */
227
    private javax.swing.JTextField getTxtOwner() {
228
        if (txtOwner == null) {
229
            txtOwner = new javax.swing.JTextField();
230
            txtOwner.setPreferredSize(new java.awt.Dimension(220, 20));
231
        }
232

    
233
        return txtOwner;
234
    }
235

    
236
    /**
237
     * This method initializes jLabel4
238
     *
239
     * @return javax.swing.JLabel
240
     */
241
    private javax.swing.JLabel getJLabel4() {
242
        if (jLabel4 == null) {
243
            jLabel4 = new javax.swing.JLabel();
244
            jLabel4.setText(PluginServices.getText(this, "map_units") + ":");
245
        }
246

    
247
        return jLabel4;
248
    }
249

    
250
    /**
251
     * This method initializes cmbMapUnits
252
     *
253
     * @return javax.swing.JComboBox
254
     */
255
    private javax.swing.JComboBox getCmbMapUnits() {
256
        if (cmbMapUnits == null) {
257
            cmbMapUnits = new javax.swing.JComboBox(Attributes.NAMES);
258
            cmbMapUnits.setPreferredSize(new java.awt.Dimension(160, 20));
259
                       cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort().getMapUnits());
260
            cmbMapUnits.addActionListener(new java.awt.event.ActionListener() { 
261
                    public void actionPerformed(java.awt.event.ActionEvent e) {    
262
                            view.getMapContext().getViewPort().setMapUnits(cmbMapUnits.getSelectedIndex());
263
                    }
264
            });
265
        }
266

    
267
        return cmbMapUnits;
268
    }
269

    
270
    /**
271
     * This method initializes jLabel5
272
     *
273
     * @return javax.swing.JLabel
274
     */
275
    private javax.swing.JLabel getJLabel5() {
276
        if (jLabel5 == null) {
277
            jLabel5 = new javax.swing.JLabel();
278
            jLabel5.setText(PluginServices.getText(this, "distance_units") + ":");
279
        }
280

    
281
        return jLabel5;
282
    }
283

    
284
    /**
285
     * This method initializes cmbDistanceUnits
286
     *
287
     * @return javax.swing.JComboBox
288
     */
289
    private javax.swing.JComboBox getCmbDistanceUnits() {
290
        if (cmbDistanceUnits == null) {
291
            cmbDistanceUnits = new javax.swing.JComboBox(Attributes.NAMES);
292
            cmbDistanceUnits.setPreferredSize(new java.awt.Dimension(160, 20));
293
            cmbDistanceUnits.setEditable(false);
294
            cmbDistanceUnits.setSelectedIndex(view.getMapContext().getViewPort().getDistanceUnits());
295
            cmbDistanceUnits.addActionListener(new java.awt.event.ActionListener() { 
296
                    public void actionPerformed(java.awt.event.ActionEvent e) {    
297
                            view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
298
                    }
299
            });
300
        }
301

    
302
        return cmbDistanceUnits;
303
    }
304

    
305
    /**
306
     * This method initializes jLabel6
307
     *
308
     * @return javax.swing.JLabel
309
     */
310
    private javax.swing.JLabel getJLabel6() {
311
        if (jLabel6 == null) {
312
            jLabel6 = new javax.swing.JLabel();
313
            jLabel6.setText(PluginServices.getText(this, "comentarios") + ":");
314
            jLabel6.setPreferredSize(new java.awt.Dimension(330,15));
315
            jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
316
            jLabel6.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
317
        }
318

    
319
        return jLabel6;
320
    }
321

    
322
    /**
323
     * This method initializes txtComments
324
     *
325
     * @return javax.swing.JTextArea
326
     */
327
    private javax.swing.JTextArea getTxtComments() {
328
        if (txtComments == null) {
329
            txtComments = new javax.swing.JTextArea();
330
            txtComments.setRows(1);
331
            txtComments.setColumns(28);
332
        }
333

    
334
        return txtComments;
335
    }
336

    
337
    /**
338
     * This method initializes jLabel7
339
     *
340
     * @return javax.swing.JLabel
341
     */
342
    private javax.swing.JLabel getJLabel7() {
343
        if (jLabel7 == null) {
344
            jLabel7 = new javax.swing.JLabel();
345
            jLabel7.setText(PluginServices.getText(this, "background_color") +
346
                ":");
347
            jLabel7.setPreferredSize(new java.awt.Dimension(240,16));
348
        }
349

    
350
        return jLabel7;
351
    }
352

    
353
    /**
354
     * This method initializes lblColor
355
     *
356
     * @return javax.swing.JLabel
357
     */
358
    private javax.swing.JLabel getLblColor() {
359
        if (lblColor == null) {
360
            lblColor = new javax.swing.JLabel();
361
            lblColor.setText("");
362
            lblColor.setPreferredSize(new java.awt.Dimension(30, 16));
363
            lblColor.setBackground(view.getMapContext().getViewPort().getBackColor());
364
            lblColor.setOpaque(true);
365
        }
366

    
367
        return lblColor;
368
    }
369

    
370
    /**
371
     * This method initializes btnColor
372
     *
373
     * @return javax.swing.JButton
374
     */
375
    private javax.swing.JButton getBtnColor() {
376
        if (btnColor == null) {
377
            btnColor = new javax.swing.JButton();
378
            btnColor.setPreferredSize(new java.awt.Dimension(34, 16));
379
            btnColor.setText("...");
380

    
381
            btnColor.addActionListener(new java.awt.event.ActionListener() {
382
                    public void actionPerformed(java.awt.event.ActionEvent e) {
383
                        Color ret = JColorChooser.showDialog(ViewProperties.this,
384
                                PluginServices.getText(this, "background_color"),
385
                                lblColor.getBackground());
386

    
387
                        if (ret != null) {
388
                            lblColor.setBackground(ret);
389
                        }
390
                    }
391
                });
392
        }
393

    
394
        return btnColor;
395
    }
396

    
397
    /**
398
     * This method initializes btnOk
399
     *
400
     * @return javax.swing.JButton
401
     */
402
    private javax.swing.JButton getBtnOk() {
403
        if (btnOk == null) {
404
            btnOk = new javax.swing.JButton();
405
            btnOk.setPreferredSize(new java.awt.Dimension(100, 30));
406
            btnOk.setText(PluginServices.getText(this, "ok"));
407

    
408
            btnOk.addActionListener(new java.awt.event.ActionListener() {
409
                    public void actionPerformed(java.awt.event.ActionEvent e) {
410
                        view.setName(txtName.getText());
411
                        view.setCreationDate(txtDate.getText());
412
                        view.setOwner(txtOwner.getText());
413
                        view.setComment(txtComments.getText());
414
                        view.getMapContext().getViewPort().setMapUnits(cmbMapUnits.getSelectedIndex());
415
                        view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
416
                        view.setBackColor(lblColor.getBackground());
417
                        
418
                        PluginServices.getMDIManager().closeView(ViewProperties.this);
419
                    }
420
                });
421
        }
422

    
423
        return btnOk;
424
    }
425

    
426
    /**
427
     * This method initializes btnCancel
428
     *
429
     * @return javax.swing.JButton
430
     */
431
    private javax.swing.JButton getBtnCancel() {
432
        if (btnCancel == null) {
433
            btnCancel = new javax.swing.JButton();
434
            btnCancel.setPreferredSize(new java.awt.Dimension(100, 30));
435
            btnCancel.setText(PluginServices.getText(this, "cancel"));
436

    
437
            btnCancel.addActionListener(new java.awt.event.ActionListener() {
438
                    public void actionPerformed(java.awt.event.ActionEvent e) {
439
                            PluginServices.getMDIManager().closeView(ViewProperties.this);
440
                    }
441
                });
442
        }
443

    
444
        return btnCancel;
445
    }
446

    
447
    /**
448
     * This method initializes jScrollPane
449
     *
450
     * @return javax.swing.JScrollPane
451
     */
452
    private javax.swing.JScrollPane getJScrollPane() {
453
        if (jScrollPane == null) {
454
            jScrollPane = new javax.swing.JScrollPane();
455
            jScrollPane.setViewportView(getTxtComments());
456
            jScrollPane.setPreferredSize(new java.awt.Dimension(320, 70));
457
        }
458

    
459
        return jScrollPane;
460
    }
461

    
462
    /**
463
     * This method initializes jPanel
464
     *
465
     * @return javax.swing.JPanel
466
     */
467
    private javax.swing.JPanel getJPanel() {
468
        if (jPanel == null) {
469
            jPanel = new javax.swing.JPanel();
470

    
471
            java.awt.FlowLayout layFlowLayout4 = new java.awt.FlowLayout();
472
            layFlowLayout4.setAlignment(java.awt.FlowLayout.RIGHT);
473
            layFlowLayout4.setVgap(9);
474
            jPanel.setLayout(layFlowLayout4);
475
            jPanel.add(getJLabel(), null);
476
            jPanel.add(getJLabel1(), null);
477
            jPanel.add(getJLabel2(), null);
478
            jPanel.setPreferredSize(new java.awt.Dimension(100, 80));
479
        }
480

    
481
        return jPanel;
482
    }
483

    
484
    /**
485
     * This method initializes jPanel1
486
     *
487
     * @return javax.swing.JPanel
488
     */
489
    private javax.swing.JPanel getJPanel1() {
490
        if (jPanel1 == null) {
491
            jPanel1 = new javax.swing.JPanel();
492

    
493
            java.awt.FlowLayout layFlowLayout2 = new java.awt.FlowLayout();
494
            layFlowLayout2.setHgap(5);
495
            layFlowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
496
            jPanel1.setLayout(layFlowLayout2);
497
            jPanel1.add(getTxtName(), null);
498
            jPanel1.add(getTxtDate(), null);
499
            jPanel1.add(getTxtOwner(), null);
500
            jPanel1.setPreferredSize(new java.awt.Dimension(230, 80));
501
        }
502

    
503
        return jPanel1;
504
    }
505

    
506
    /**
507
     * This method initializes jPanel2
508
     *
509
     * @return javax.swing.JPanel
510
     */
511
    private javax.swing.JPanel getJPanel2() {
512
        if (jPanel2 == null) {
513
            jPanel2 = new javax.swing.JPanel();
514

    
515
            java.awt.FlowLayout layFlowLayout5 = new java.awt.FlowLayout();
516
            layFlowLayout5.setAlignment(java.awt.FlowLayout.RIGHT);
517
            layFlowLayout5.setVgap(9);
518
            jPanel2.setLayout(layFlowLayout5);
519
            jPanel2.add(getJLabel4(), null);
520
            jPanel2.add(getJLabel5(), null);
521
            jPanel2.setPreferredSize(new java.awt.Dimension(100, 50));
522
        }
523

    
524
        return jPanel2;
525
    }
526

    
527
    /**
528
     * This method initializes jPanel3
529
     *
530
     * @return javax.swing.JPanel
531
     */
532
    private javax.swing.JPanel getJPanel3() {
533
        if (jPanel3 == null) {
534
            jPanel3 = new javax.swing.JPanel();
535

    
536
            java.awt.FlowLayout layFlowLayout6 = new java.awt.FlowLayout();
537
            layFlowLayout6.setAlignment(java.awt.FlowLayout.LEFT);
538
            jPanel3.setLayout(layFlowLayout6);
539
            jPanel3.add(getCmbMapUnits(), null);
540
            jPanel3.add(getCmbDistanceUnits(), null);
541
            jPanel3.setPreferredSize(new java.awt.Dimension(230, 50));
542
        }
543

    
544
        return jPanel3;
545
    }
546

    
547
    /**
548
     * This method initializes jLabel3
549
     *
550
     * @return javax.swing.JLabel
551
     */
552
    private javax.swing.JLabel getJLabel3() {
553
        if (jLabel3 == null) {
554
            jLabel3 = new javax.swing.JLabel();
555
            jLabel3.setText("");
556
            jLabel3.setPreferredSize(new java.awt.Dimension(30, 0));
557
        }
558

    
559
        return jLabel3;
560
    }
561

    
562
        /**
563
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
564
         */
565
        public ViewInfo getViewInfo() {
566
                ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
567
                    m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_vista"));
568
                return m_viewinfo;
569
        }
570

    
571
        /**
572
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
573
         */
574
        public void viewActivated() {
575
        }
576
        /**
577
         * This method initializes jButton        
578
         *         
579
         * @return javax.swing.JButton        
580
         */    
581
        private JButton getJBtnChangeProj() {
582
                if (jBtnChangeProj == null) {
583
                        jBtnChangeProj = new JButton();
584
                        jBtnChangeProj.setText("...");
585
                        jBtnChangeProj.setPreferredSize(new java.awt.Dimension(34,16));
586
                        jBtnChangeProj.addActionListener(new java.awt.event.ActionListener() { 
587
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
588
                                        CSSelectionDialog csSelect = new CSSelectionDialog();
589
                                        csSelect.setProjection(view.getProjection());
590
                                        
591
                                PluginServices.getMDIManager().addView(csSelect);
592
                                
593
                                if (csSelect.isOkPressed()) {
594
                                        view.getMapContext().setProjection(csSelect.getProjection());
595
                                        jLblProj.setText(view.getProjection().getAbrev());
596
                                }
597
                                }
598
                        });
599
                }
600
                return jBtnChangeProj;
601
        }
602
        /**
603
         * This method initializes jPanel4        
604
         *         
605
         * @return javax.swing.JPanel        
606
         */    
607
        private JPanel getJPanelProj() {
608
                if (jPanelProj == null) {
609
                        jPanelProj = new ProjChooserPanel(view);
610
                        jPanelProj.setPreferredSize(new java.awt.Dimension(330,35));
611
                        jPanelProj.add(jLblProjName, null);
612
                        jPanelProj.add(jLblProj, null);
613
                        jPanelProj.add(getJBtnChangeProj(), null);
614
                }
615
                return jPanelProj;
616
        }
617
  }  //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
618

    
619

    
620
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"
621