Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / project / ViewProperties.java @ 1231

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

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

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

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

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

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

    
160
        return jLabel;
161
    }
162

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

    
174
        return txtName;
175
    }
176

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

    
188
        return jLabel1;
189
    }
190

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

    
204
        return txtDate;
205
    }
206

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

    
218
        return jLabel2;
219
    }
220

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

    
232
        return txtOwner;
233
    }
234

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

    
246
        return jLabel4;
247
    }
248

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

    
266
        return cmbMapUnits;
267
    }
268

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

    
280
        return jLabel5;
281
    }
282

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

    
301
        return cmbDistanceUnits;
302
    }
303

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

    
318
        return jLabel6;
319
    }
320

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

    
333
        return txtComments;
334
    }
335

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

    
349
        return jLabel7;
350
    }
351

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

    
366
        return lblColor;
367
    }
368

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

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

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

    
393
        return btnColor;
394
    }
395

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

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

    
422
        return btnOk;
423
    }
424

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

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

    
443
        return btnCancel;
444
    }
445

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

    
458
        return jScrollPane;
459
    }
460

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

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

    
480
        return jPanel;
481
    }
482

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

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

    
502
        return jPanel1;
503
    }
504

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

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

    
523
        return jPanel2;
524
    }
525

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

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

    
543
        return jPanel3;
544
    }
545

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

    
558
        return jLabel3;
559
    }
560

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

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

    
618

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