Statistics
| Revision:

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

History | View | Annotate | Download (17.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.project.documents.view.gui;
42

    
43

    
44
import java.awt.BorderLayout;
45
import java.awt.Color;
46
import java.awt.Dimension;
47
import java.awt.event.ActionListener;
48

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

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

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

    
87
        private Color backColor = null;
88

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

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

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

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

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

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

    
171
                return jLabel;
172
        }
173

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

    
193
                return txtName;
194
        }
195

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

    
207
                return jLabel1;
208
        }
209

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

    
223
                return txtDate;
224
        }
225

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

    
237
                return jLabel2;
238
        }
239

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

    
251
                return txtOwner;
252
        }
253

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

    
265
                return jLabel4;
266
        }
267

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

    
285
                return cmbMapUnits;
286
        }
287

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

    
299
                return jLabel5;
300
        }
301

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

    
320
                return cmbDistanceUnits;
321
        }
322

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

    
337
                return jLabel6;
338
        }
339

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

    
352
                return txtComments;
353
        }
354

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

    
368
                return jLabel7;
369
        }
370

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

    
387
                return lblColor;
388
        }
389

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

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

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

    
417
                return btnColor;
418
        }
419

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

    
432
                return jScrollPane;
433
        }
434

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

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

    
454
                return jPanel;
455
        }
456

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

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

    
476
                return jPanel1;
477
        }
478

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

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

    
497
                return jPanel2;
498
        }
499

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

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

    
517
                return jPanel3;
518
        }
519
        
520

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

    
533
                return jLabel3;
534
        }
535

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

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

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

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

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

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

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

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