Statistics
| Revision:

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

History | View | Annotate | Download (19.8 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.JColorChooser;
47
import javax.swing.JPanel;
48

    
49
import com.iver.andami.PluginServices;
50
import com.iver.andami.ui.mdiManager.SingletonView;
51
import com.iver.andami.ui.mdiManager.ViewInfo;
52
import com.iver.cit.gvsig.gui.layout.Attributes;
53
import com.iver.cit.gvsig.gui.panels.ProjChooserPanel;
54
import com.iver.cit.gvsig.project.ProjectView;
55
/**
56
 * Dialogo donde se muestran las propiedades de una vista
57
 *
58
 * @author Fernando Gonz?lez Cort?s
59
 */
60
public class ViewProperties extends JPanel implements SingletonView{
61
    /*private String[] units = new String[] {
62
            PluginServices.getText(this, "metros"),
63
            PluginServices.getText(this, "kilometros"),
64
        };
65
    */
66
    private javax.swing.JPanel jContentPane = null;
67
    private javax.swing.JLabel jLabel = null;
68
    private javax.swing.JTextField txtName = null;
69
    private javax.swing.JLabel jLabel1 = null;
70
    private javax.swing.JTextField txtDate = null;
71
    private javax.swing.JLabel jLabel2 = null;
72
    private javax.swing.JTextField txtOwner = null;
73
    private javax.swing.JLabel jLabel4 = null;
74
    private javax.swing.JComboBox cmbMapUnits = null;
75
    private javax.swing.JLabel jLabel5 = null;
76
    private javax.swing.JComboBox cmbDistanceUnits = null;
77
    private javax.swing.JLabel jLabel6 = null;
78
    private javax.swing.JTextArea txtComments = null;
79
    private javax.swing.JLabel jLabel7 = null;
80
    private javax.swing.JLabel lblColor = null;
81
    
82
    private Color backColor = null;
83
    
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 ProjChooserPanel 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
        this.setSize(378, 358);
115
                java.awt.FlowLayout layFlowLayout3 = new java.awt.FlowLayout();
116
                layFlowLayout3.setHgap(0);
117
                setLayout(layFlowLayout3);
118
/*      jLblProjName = new JLabel();
119
        jLblProj = new JLabel();
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,463));
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,35));
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
            Color theColor = view.getMapContext().getViewPort().getBackColor();
364
            if (theColor == null) theColor = Color.WHITE;
365
            lblColor.setBackground(theColor);
366
            lblColor.setOpaque(true);
367
        }
368

    
369
        return lblColor;
370
    }
371

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

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

    
389
                        if (ret != null) {
390
                            lblColor.setBackground(ret);
391
                            backColor = ret;
392
                        }
393
                        else
394
                            lblColor.setBackground(Color.WHITE);
395
                    }
396
                });
397
        }
398

    
399
        return btnColor;
400
    }
401

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

    
413
            btnOk.addActionListener(new java.awt.event.ActionListener() {
414
                    public void actionPerformed(java.awt.event.ActionEvent e) {
415
                        view.setName(txtName.getText());
416
                        view.setCreationDate(txtDate.getText());
417
                        view.setOwner(txtOwner.getText());
418
                        view.setComment(txtComments.getText());
419
                        view.getMapContext().getViewPort().setMapUnits(cmbMapUnits.getSelectedIndex());
420
                        view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
421
                        view.setBackColor(backColor);
422
                        
423
                        PluginServices.getMDIManager().closeView(ViewProperties.this);
424
                    }
425
                });
426
        }
427

    
428
        return btnOk;
429
    }
430

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

    
442
            btnCancel.addActionListener(new java.awt.event.ActionListener() {
443
                    public void actionPerformed(java.awt.event.ActionEvent e) {
444
                            PluginServices.getMDIManager().closeView(ViewProperties.this);
445
                    }
446
                });
447
        }
448

    
449
        return btnCancel;
450
    }
451

    
452
    /**
453
     * This method initializes jScrollPane
454
     *
455
     * @return javax.swing.JScrollPane
456
     */
457
    private javax.swing.JScrollPane getJScrollPane() {
458
        if (jScrollPane == null) {
459
            jScrollPane = new javax.swing.JScrollPane();
460
            jScrollPane.setViewportView(getTxtComments());
461
            jScrollPane.setPreferredSize(new java.awt.Dimension(320, 70));
462
        }
463

    
464
        return jScrollPane;
465
    }
466

    
467
    /**
468
     * This method initializes jPanel
469
     *
470
     * @return javax.swing.JPanel
471
     */
472
    private javax.swing.JPanel getJPanel() {
473
        if (jPanel == null) {
474
            jPanel = new javax.swing.JPanel();
475

    
476
            java.awt.FlowLayout layFlowLayout4 = new java.awt.FlowLayout();
477
            layFlowLayout4.setAlignment(java.awt.FlowLayout.RIGHT);
478
            layFlowLayout4.setVgap(9);
479
            jPanel.setLayout(layFlowLayout4);
480
            jPanel.add(getJLabel(), null);
481
            jPanel.add(getJLabel1(), null);
482
            jPanel.add(getJLabel2(), null);
483
            jPanel.setPreferredSize(new java.awt.Dimension(100, 80));
484
        }
485

    
486
        return jPanel;
487
    }
488

    
489
    /**
490
     * This method initializes jPanel1
491
     *
492
     * @return javax.swing.JPanel
493
     */
494
    private javax.swing.JPanel getJPanel1() {
495
        if (jPanel1 == null) {
496
            jPanel1 = new javax.swing.JPanel();
497

    
498
            java.awt.FlowLayout layFlowLayout2 = new java.awt.FlowLayout();
499
            layFlowLayout2.setHgap(5);
500
            layFlowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
501
            jPanel1.setLayout(layFlowLayout2);
502
            jPanel1.add(getTxtName(), null);
503
            jPanel1.add(getTxtDate(), null);
504
            jPanel1.add(getTxtOwner(), null);
505
            jPanel1.setPreferredSize(new java.awt.Dimension(230, 80));
506
        }
507

    
508
        return jPanel1;
509
    }
510

    
511
    /**
512
     * This method initializes jPanel2
513
     *
514
     * @return javax.swing.JPanel
515
     */
516
    private javax.swing.JPanel getJPanel2() {
517
        if (jPanel2 == null) {
518
            jPanel2 = new javax.swing.JPanel();
519

    
520
            java.awt.FlowLayout layFlowLayout5 = new java.awt.FlowLayout();
521
            layFlowLayout5.setAlignment(java.awt.FlowLayout.RIGHT);
522
            layFlowLayout5.setVgap(9);
523
            jPanel2.setLayout(layFlowLayout5);
524
            jPanel2.add(getJLabel4(), null);
525
            jPanel2.add(getJLabel5(), null);
526
            jPanel2.setPreferredSize(new java.awt.Dimension(100, 50));
527
        }
528

    
529
        return jPanel2;
530
    }
531

    
532
    /**
533
     * This method initializes jPanel3
534
     *
535
     * @return javax.swing.JPanel
536
     */
537
    private javax.swing.JPanel getJPanel3() {
538
        if (jPanel3 == null) {
539
            jPanel3 = new javax.swing.JPanel();
540

    
541
            java.awt.FlowLayout layFlowLayout6 = new java.awt.FlowLayout();
542
            layFlowLayout6.setAlignment(java.awt.FlowLayout.LEFT);
543
            jPanel3.setLayout(layFlowLayout6);
544
            jPanel3.add(getCmbMapUnits(), null);
545
            jPanel3.add(getCmbDistanceUnits(), null);
546
            jPanel3.setPreferredSize(new java.awt.Dimension(230, 50));
547
        }
548

    
549
        return jPanel3;
550
    }
551

    
552
    /**
553
     * This method initializes jLabel3
554
     *
555
     * @return javax.swing.JLabel
556
     */
557
    private javax.swing.JLabel getJLabel3() {
558
        if (jLabel3 == null) {
559
            jLabel3 = new javax.swing.JLabel();
560
            jLabel3.setText("");
561
            jLabel3.setPreferredSize(new java.awt.Dimension(30, 0));
562
        }
563

    
564
        return jLabel3;
565
    }
566

    
567
        /**
568
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
569
         */
570
        public ViewInfo getViewInfo() {
571
                ViewInfo m_viewinfo=new ViewInfo();
572
                    m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_vista"));
573
            m_viewinfo.setHeight(370);
574
                return m_viewinfo;
575
        }
576

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

    
625
//                        jPanelProj.add(jLblProjName, null);
626
//                        jPanelProj.add(jLblProj, null);
627
//                        jPanelProj.add(getJBtnChangeProj(), null);
628
                }
629
                return jPanelProj;
630
        }
631

    
632
    /**
633
     * @see com.iver.andami.ui.mdiManager.SingletonView#getViewModel()
634
     */
635
    public Object getViewModel() {
636
        return view;
637
    }
638
  }  //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
639

    
640

    
641
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"
642