Statistics
| Revision:

svn-gvsig-desktop / tags / v10_RC2c / applications / appgvSIG / src / com / iver / cit / gvsig / gui / project / ViewProperties.java @ 8745

History | View | Annotate | Download (17 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
import java.awt.Dimension;
46
import java.awt.event.ActionListener;
47

    
48
import javax.swing.JColorChooser;
49
import javax.swing.JPanel;
50

    
51
import org.gvsig.gui.beans.AcceptCancelPanel;
52
import org.gvsig.gui.beans.swing.JButton;
53

    
54
import com.iver.andami.PluginServices;
55
import com.iver.andami.ui.mdiManager.SingletonWindow;
56
import com.iver.andami.ui.mdiManager.WindowInfo;
57
import com.iver.cit.gvsig.gui.layout.Attributes;
58
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel;
59
import com.iver.cit.gvsig.project.ProjectView;
60
/**
61
 * Dialogo donde se muestran las propiedades de una vista
62
 *
63
 * @author Fernando Gonz?lez Cort?s
64
 */
65
public class ViewProperties extends JPanel implements SingletonWindow{
66
        /*private String[] units = new String[] {
67
         PluginServices.getText(this, "metros"),
68
         PluginServices.getText(this, "kilometros"),
69
         };
70
         */
71
        private javax.swing.JLabel jLabel = null;
72
        private javax.swing.JTextField txtName = null;
73
        private javax.swing.JLabel jLabel1 = null;
74
        private javax.swing.JTextField txtDate = null;
75
        private javax.swing.JLabel jLabel2 = null;
76
        private javax.swing.JTextField txtOwner = null;
77
        private javax.swing.JLabel jLabel4 = null;
78
        private javax.swing.JComboBox cmbMapUnits = null;
79
        private javax.swing.JLabel jLabel5 = null;
80
        private javax.swing.JComboBox cmbDistanceUnits = null;
81
        private javax.swing.JLabel jLabel6 = null;
82
        private javax.swing.JTextArea txtComments = null;
83
        private javax.swing.JLabel jLabel7 = null;
84
        private javax.swing.JLabel lblColor = null;
85

    
86
        private Color backColor = null;
87

    
88
        private JButton btnColor = null;
89
        private ProjectView view=null;
90
        private javax.swing.JScrollPane jScrollPane = null;
91
        private javax.swing.JPanel jPanel = null;
92
        private javax.swing.JPanel jPanel1 = null;
93
        private javax.swing.JPanel jPanel2 = null;
94
        private javax.swing.JPanel jPanel3 = null;
95
        
96
        private javax.swing.JLabel jLabel3 = null;
97
        private javax.swing.JLabel jLabelSep1 = null;
98
        private WindowInfo m_viewinfo = null;
99
        //private JLabel jLblProj = null;
100
        //private JLabel jLblProjName = null;
101
        //private JButton jBtnChangeProj = null;
102
        private CRSSelectPanel jPanelProj = null;
103
        private AcceptCancelPanel okCancelPanel = null;
104
        /**
105
         * This is the default constructor
106
         *
107
         * @param f Frame padre del dialogo
108
         * @param v Vista que se representa
109
         */
110
        public ViewProperties(ProjectView v) {
111
                view = v;
112
                initialize();
113
        }
114

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

    
151
                cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort().getMapUnits());
152
                cmbDistanceUnits.setSelectedIndex(view.getMapContext().getViewPort().getDistanceUnits());
153

    
154
                txtComments.setText(view.getComment());
155

    
156
                lblColor.setBackground(view.getMapContext().getViewPort().getBackColor());
157
        }
158

    
159
        /**
160
         * This method initializes jLabel
161
         *
162
         * @return javax.swing.JLabel
163
         */
164
        private javax.swing.JLabel getJLabel() {
165
                if (jLabel == null) {
166
                        jLabel = new javax.swing.JLabel();
167
                        jLabel.setText(PluginServices.getText(this, "nombre") + ":");
168
                }
169

    
170
                return jLabel;
171
        }
172

    
173
        private javax.swing.JLabel getJLabelSep1() {
174
                if (jLabelSep1 == null) {
175
                        jLabelSep1 = new javax.swing.JLabel();
176
                        jLabelSep1.setPreferredSize(new java.awt.Dimension(200, 10));
177
                }
178
                return jLabelSep1;
179
        }
180
        
181
        /**
182
         * This method initializes txtName
183
         *
184
         * @return javax.swing.JTextField
185
         */
186
        private javax.swing.JTextField getTxtName() {
187
                if (txtName == null) {
188
                        txtName = new javax.swing.JTextField();
189
                        txtName.setPreferredSize(new java.awt.Dimension(200, 20));
190
                }
191

    
192
                return txtName;
193
        }
194

    
195
        /**
196
         * This method initializes jLabel1
197
         *
198
         * @return javax.swing.JLabel
199
         */
200
        private javax.swing.JLabel getJLabel1() {
201
                if (jLabel1 == null) {
202
                        jLabel1 = new javax.swing.JLabel();
203
                        jLabel1.setText(PluginServices.getText(this, "creation_date") + ":");
204
                }
205

    
206
                return jLabel1;
207
        }
208

    
209
        /**
210
         * This method initializes txtDate
211
         *
212
         * @return javax.swing.JTextField
213
         */
214
        private javax.swing.JTextField getTxtDate() {
215
                if (txtDate == null) {
216
                        txtDate = new javax.swing.JTextField();
217
                        txtDate.setPreferredSize(new java.awt.Dimension(200, 20));
218
                        txtDate.setEditable(false);
219
                        txtDate.setBackground(java.awt.Color.white);
220
                }
221

    
222
                return txtDate;
223
        }
224

    
225
        /**
226
         * This method initializes jLabel2
227
         *
228
         * @return javax.swing.JLabel
229
         */
230
        private javax.swing.JLabel getJLabel2() {
231
                if (jLabel2 == null) {
232
                        jLabel2 = new javax.swing.JLabel();
233
                        jLabel2.setText(PluginServices.getText(this, "owner") + ":");
234
                }
235

    
236
                return jLabel2;
237
        }
238

    
239
        /**
240
         * This method initializes txtOwner
241
         *
242
         * @return javax.swing.JTextField
243
         */
244
        private javax.swing.JTextField getTxtOwner() {
245
                if (txtOwner == null) {
246
                        txtOwner = new javax.swing.JTextField();
247
                        txtOwner.setPreferredSize(new java.awt.Dimension(200, 20));
248
                }
249

    
250
                return txtOwner;
251
        }
252

    
253
        /**
254
         * This method initializes jLabel4
255
         *
256
         * @return javax.swing.JLabel
257
         */
258
        private javax.swing.JLabel getJLabel4() {
259
                if (jLabel4 == null) {
260
                        jLabel4 = new javax.swing.JLabel();
261
                        jLabel4.setText(PluginServices.getText(this, "map_units") + ":");
262
                }
263

    
264
                return jLabel4;
265
        }
266

    
267
        /**
268
         * This method initializes cmbMapUnits
269
         *
270
         * @return javax.swing.JComboBox
271
         */
272
        private javax.swing.JComboBox getCmbMapUnits() {
273
                if (cmbMapUnits == null) {
274
                        cmbMapUnits = new javax.swing.JComboBox(Attributes.NAMES);
275
                        cmbMapUnits.setPreferredSize(new java.awt.Dimension(200, 20));
276
                        cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort().getMapUnits());
277
                        cmbMapUnits.addActionListener(new java.awt.event.ActionListener() {
278
                                public void actionPerformed(java.awt.event.ActionEvent e) {
279
                                        view.getMapContext().getViewPort().setMapUnits(cmbMapUnits.getSelectedIndex());
280
                                }
281
                        });
282
                }
283

    
284
                return cmbMapUnits;
285
        }
286

    
287
        /**
288
         * This method initializes jLabel5
289
         *
290
         * @return javax.swing.JLabel
291
         */
292
        private javax.swing.JLabel getJLabel5() {
293
                if (jLabel5 == null) {
294
                        jLabel5 = new javax.swing.JLabel();
295
                        jLabel5.setText(PluginServices.getText(this, "distance_units") + ":");
296
                }
297

    
298
                return jLabel5;
299
        }
300

    
301
        /**
302
         * This method initializes cmbDistanceUnits
303
         *
304
         * @return javax.swing.JComboBox
305
         */
306
        private javax.swing.JComboBox getCmbDistanceUnits() {
307
                if (cmbDistanceUnits == null) {
308
                        cmbDistanceUnits = new javax.swing.JComboBox(Attributes.NAMES);
309
                        cmbDistanceUnits.setPreferredSize(new java.awt.Dimension(200, 20));
310
                        cmbDistanceUnits.setEditable(false);
311
                        cmbDistanceUnits.setSelectedIndex(view.getMapContext().getViewPort().getDistanceUnits());
312
                        cmbDistanceUnits.addActionListener(new java.awt.event.ActionListener() {
313
                                public void actionPerformed(java.awt.event.ActionEvent e) {
314
                                        view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
315
                                }
316
                        });
317
                }
318

    
319
                return cmbDistanceUnits;
320
        }
321

    
322
        /**
323
         * This method initializes jLabel6
324
         *
325
         * @return javax.swing.JLabel
326
         */
327
        private javax.swing.JLabel getJLabel6() {
328
                if (jLabel6 == null) {
329
                        jLabel6 = new javax.swing.JLabel();
330
                        jLabel6.setText(PluginServices.getText(this, "comentarios") + ":");
331
                        jLabel6.setPreferredSize(new java.awt.Dimension(340,35));
332
                        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
333
                        jLabel6.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
334
                }
335

    
336
                return jLabel6;
337
        }
338

    
339
        /**
340
         * This method initializes txtComments
341
         *
342
         * @return javax.swing.JTextArea
343
         */
344
        private javax.swing.JTextArea getTxtComments() {
345
                if (txtComments == null) {
346
                        txtComments = new javax.swing.JTextArea();
347
                        txtComments.setRows(1);
348
                        txtComments.setColumns(28);
349
                }
350

    
351
                return txtComments;
352
        }
353

    
354
        /**
355
         * This method initializes jLabel7
356
         *
357
         * @return javax.swing.JLabel
358
         */
359
        private javax.swing.JLabel getJLabel7() {
360
                if (jLabel7 == null) {
361
                        jLabel7 = new javax.swing.JLabel();
362
                        jLabel7.setText(PluginServices.getText(this, "background_color") +
363
                        ":");
364
                        jLabel7.setPreferredSize(new java.awt.Dimension(190,16));
365
                }
366

    
367
                return jLabel7;
368
        }
369

    
370
        /**
371
         * This method initializes lblColor
372
         *
373
         * @return javax.swing.JLabel
374
         */
375
        private javax.swing.JLabel getLblColor() {
376
                if (lblColor == null) {
377
                        lblColor = new javax.swing.JLabel();
378
                        lblColor.setText("");
379
                        lblColor.setPreferredSize(new java.awt.Dimension(30, 16));
380
                        Color theColor = view.getMapContext().getViewPort().getBackColor();
381
                        if (theColor == null) theColor = Color.WHITE;
382
                        lblColor.setBackground(theColor);
383
                        lblColor.setOpaque(true);
384
                }
385

    
386
                return lblColor;
387
        }
388

    
389
        /**
390
         * This method initializes btnColor
391
         *
392
         * @return javax.swing.JButton
393
         */
394
        private JButton getBtnColor() {
395
                if (btnColor == null) {
396
                        btnColor = new JButton();
397
                        
398
                        btnColor.setText("...");
399

    
400
                        btnColor.addActionListener(new java.awt.event.ActionListener() {
401
                                public void actionPerformed(java.awt.event.ActionEvent e) {
402
                                        Color ret = JColorChooser.showDialog(ViewProperties.this,
403
                                                        PluginServices.getText(this, "background_color"),
404
                                                        lblColor.getBackground());
405

    
406
                                        if (ret != null) {
407
                                                lblColor.setBackground(ret);
408
                                                backColor = ret;
409
                                        }
410
                                        else
411
                                                lblColor.setBackground(Color.WHITE);
412
                                }
413
                        });
414
                }
415

    
416
                return btnColor;
417
        }
418

    
419
        /**
420
         * This method initializes jScrollPane
421
         *
422
         * @return javax.swing.JScrollPane
423
         */
424
        private javax.swing.JScrollPane getJScrollPane() {
425
                if (jScrollPane == null) {
426
                        jScrollPane = new javax.swing.JScrollPane();
427
                        jScrollPane.setViewportView(getTxtComments());
428
                        jScrollPane.setPreferredSize(new java.awt.Dimension(340, 70));
429
                }
430

    
431
                return jScrollPane;
432
        }
433

    
434
        /**
435
         * This method initializes jPanel
436
         *
437
         * @return javax.swing.JPanel
438
         */
439
        private javax.swing.JPanel getJPanel() {
440
                if (jPanel == null) {
441
                        jPanel = new javax.swing.JPanel();
442

    
443
                        java.awt.FlowLayout layFlowLayout4 = new java.awt.FlowLayout();
444
                        layFlowLayout4.setAlignment(java.awt.FlowLayout.LEFT);
445
                        layFlowLayout4.setVgap(9);
446
                        jPanel.setLayout(layFlowLayout4);
447
                        jPanel.add(getJLabel(), null);
448
                        jPanel.add(getJLabel1(), null);
449
                        jPanel.add(getJLabel2(), null);
450
                        jPanel.setPreferredSize(new java.awt.Dimension(140, 80));
451
                }
452

    
453
                return jPanel;
454
        }
455

    
456
        /**
457
         * This method initializes jPanel1
458
         *
459
         * @return javax.swing.JPanel
460
         */
461
        private javax.swing.JPanel getJPanel1() {
462
                if (jPanel1 == null) {
463
                        jPanel1 = new javax.swing.JPanel();
464

    
465
                        java.awt.FlowLayout layFlowLayout2 = new java.awt.FlowLayout();
466
                        layFlowLayout2.setHgap(5);
467
                        layFlowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
468
                        jPanel1.setLayout(layFlowLayout2);
469
                        jPanel1.add(getTxtName(), null);
470
                        jPanel1.add(getTxtDate(), null);
471
                        jPanel1.add(getTxtOwner(), null);
472
                        jPanel1.setPreferredSize(new java.awt.Dimension(210, 80));
473
                }
474

    
475
                return jPanel1;
476
        }
477

    
478
        /**
479
         * This method initializes jPanel2
480
         *
481
         * @return javax.swing.JPanel
482
         */
483
        private javax.swing.JPanel getJPanel2() {
484
                if (jPanel2 == null) {
485
                        jPanel2 = new javax.swing.JPanel();
486

    
487
                        java.awt.FlowLayout layFlowLayout5 = new java.awt.FlowLayout();
488
                        layFlowLayout5.setAlignment(java.awt.FlowLayout.LEFT);
489
                        layFlowLayout5.setVgap(9);
490
                        jPanel2.setLayout(layFlowLayout5);
491
                        jPanel2.add(getJLabel4(), null);
492
                        jPanel2.add(getJLabel5(), null);
493
                        jPanel2.setPreferredSize(new java.awt.Dimension(140, 50));
494
                }
495

    
496
                return jPanel2;
497
        }
498

    
499
        /**
500
         * This method initializes jPanel3
501
         *
502
         * @return javax.swing.JPanel
503
         */
504
        private javax.swing.JPanel getJPanel3() {
505
                if (jPanel3 == null) {
506
                        jPanel3 = new javax.swing.JPanel();
507

    
508
                        java.awt.FlowLayout layFlowLayout6 = new java.awt.FlowLayout();
509
                        layFlowLayout6.setAlignment(java.awt.FlowLayout.LEFT);
510
                        jPanel3.setLayout(layFlowLayout6);
511
                        jPanel3.add(getCmbMapUnits(), null);
512
                        jPanel3.add(getCmbDistanceUnits(), null);
513
                        jPanel3.setPreferredSize(new java.awt.Dimension(210, 50));
514
                }
515

    
516
                return jPanel3;
517
        }
518
        
519

    
520
        /**
521
         * This method initializes jLabel3
522
         *
523
         * @return javax.swing.JLabel
524
         */
525
        private javax.swing.JLabel getJLabel3() {
526
                if (jLabel3 == null) {
527
                        jLabel3 = new javax.swing.JLabel();
528
                        jLabel3.setText("");
529
                        jLabel3.setPreferredSize(new java.awt.Dimension(30, 0));
530
                }
531

    
532
                return jLabel3;
533
        }
534

    
535
        /**
536
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
537
         */
538
        public WindowInfo getWindowInfo() {
539
                WindowInfo m_viewinfo=new WindowInfo();
540
                m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_vista"));
541
                m_viewinfo.setHeight(370);
542
                return m_viewinfo;
543
        }
544

    
545
        /**
546
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
547
         */
548
        public void viewActivated() {
549
        }
550
        /**
551
         * This method initializes jButton
552
         *
553
         * @return javax.swing.JButton
554
         * /
555
         private JButton getJBtnChangeProj() {
556
         if (jBtnChangeProj == null) {
557
         jBtnChangeProj = new JButton();
558
         jBtnChangeProj.setText("...");
559
         jBtnChangeProj.setPreferredSize(new java.awt.Dimension(34,16));
560
         jBtnChangeProj.addActionListener(new java.awt.event.ActionListener() {
561
         public void actionPerformed(java.awt.event.ActionEvent e) {
562
         CSSelectionDialog csSelect = new CSSelectionDialog();
563
         csSelect.setProjection(view.getProjection());
564

565
         PluginServices.getMDIManager().addView(csSelect);
566

567
         if (csSelect.isOkPressed()) {
568
         view.getMapContext().setProjection(csSelect.getProjection());
569
         jLblProj.setText(view.getProjection().getAbrev());
570
         }
571
         }
572
         });
573
         }
574
         return jBtnChangeProj;
575
         } */
576
        /**
577
         * This method initializes jPanel4
578
         *
579
         * @return javax.swing.JPanel
580
         */
581
        private CRSSelectPanel getJPanelProj() {
582
                if (jPanelProj == null) {
583
                        jPanelProj = CRSSelectPanel.getPanel(view.getProjection());
584
                        jPanelProj.setPreferredSize(new java.awt.Dimension(330,35));
585
                        jPanelProj.addActionListener(new java.awt.event.ActionListener() {
586
                                public void actionPerformed(java.awt.event.ActionEvent e) {
587
                                        if (jPanelProj.isOkPressed()) {
588
                                                view.setProjection(jPanelProj.getCurProj());
589
                                        }
590
                                }
591
                        });
592

    
593
//                        jPanelProj.add(jLblProjName, null);
594
//                        jPanelProj.add(jLblProj, null);
595
//                        jPanelProj.add(getJBtnChangeProj(), null);
596
                }
597
                return jPanelProj;
598
        }
599

    
600
        /**
601
         * @see com.iver.andami.ui.mdiManager.SingletonWindow#getWindowModel()
602
         */
603
        public Object getWindowModel() {
604
                return view;
605
        }
606

    
607
        /**
608
         * This method initializes okCancelPanel
609
         *
610
         * @return javax.swing.JPanel
611
         */
612
        private AcceptCancelPanel getOkCancelPanel() {
613
                if (okCancelPanel == null) {
614
                        ActionListener okAction, cancelAction;
615
                        okAction = new java.awt.event.ActionListener() {
616
                                public void actionPerformed(java.awt.event.ActionEvent e) {
617
                                        view.setName(txtName.getText());
618
                                        view.setCreationDate(txtDate.getText());
619
                                        view.setOwner(txtOwner.getText());
620
                                        view.setComment(txtComments.getText());
621
                                        view.getMapContext().getViewPort().setMapUnits(cmbMapUnits.getSelectedIndex());
622
                                        view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
623
                                        view.setBackColor(backColor);
624

    
625
                                        PluginServices.getMDIManager().closeWindow(ViewProperties.this);
626
                                }
627
                        };
628
                        cancelAction = new java.awt.event.ActionListener() {
629
                                public void actionPerformed(java.awt.event.ActionEvent e) {
630
                                        PluginServices.getMDIManager().closeWindow(ViewProperties.this);
631
                                }
632
                        };
633
                        okCancelPanel = new AcceptCancelPanel(okAction, cancelAction);
634
                        Dimension sz = this.getSize();
635
                        sz.setSize((int)sz.getWidth()-20, (int) sz.getHeight());
636
                        okCancelPanel.setPreferredSize(sz);
637
                }
638
                return okCancelPanel;
639
        }
640
}