Statistics
| Revision:

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

History | View | Annotate | Download (22.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.Color;
45
import java.awt.Component;
46
import java.awt.Dimension;
47
import java.awt.GridLayout;
48
import java.awt.event.ActionListener;
49
import java.util.ArrayList;
50

    
51
import javax.swing.JColorChooser;
52
import javax.swing.JOptionPane;
53
import javax.swing.JPanel;
54

    
55
import org.cresques.cts.IProjection;
56
import org.gvsig.gui.beans.AcceptCancelPanel;
57
import org.gvsig.gui.beans.swing.JButton;
58

    
59
import com.iver.andami.PluginServices;
60
import com.iver.andami.ui.mdiManager.SingletonWindow;
61
import com.iver.andami.ui.mdiManager.WindowInfo;
62
import com.iver.cit.gvsig.ProjectExtension;
63
import com.iver.cit.gvsig.fmap.MapContext;
64
import com.iver.cit.gvsig.gui.JComboBoxUnits;
65
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel;
66
import com.iver.cit.gvsig.project.Project;
67
import com.iver.cit.gvsig.project.documents.ProjectDocument;
68
import com.iver.cit.gvsig.project.documents.layout.Attributes;
69
import com.iver.cit.gvsig.project.documents.view.ProjectView;
70
import com.iver.cit.gvsig.project.documents.view.ProjectViewFactory;
71

    
72
import javax.swing.JLabel;
73
import javax.swing.JComboBox;
74
/**
75
 * Dialogo donde se muestran las propiedades de una vista
76
 *
77
 * @author Fernando Gonz?lez Cort?s
78
 */
79
public class ViewProperties extends JPanel implements SingletonWindow{
80
        /*private String[] units = new String[] {
81
         PluginServices.getText(this, "metros"),
82
         PluginServices.getText(this, "kilometros"),
83
         };
84
         */
85
        private static String[] unitsNames = null;
86
        private javax.swing.JLabel jLabel = null;
87
        private javax.swing.JTextField txtName = null;
88
        private javax.swing.JLabel jLabel1 = null;
89
        private javax.swing.JTextField txtDate = null;
90
        private javax.swing.JLabel jLabel2 = null;
91
        private javax.swing.JTextField txtOwner = null;
92
        private javax.swing.JLabel jLabel4 = null;
93
        private javax.swing.JComboBox cmbMapUnits = null;
94
        private javax.swing.JLabel jLabel5 = null;
95
        private javax.swing.JComboBox cmbDistanceUnits = null;
96
        private javax.swing.JLabel jLabel6 = null;
97
        private javax.swing.JTextArea txtComments = null;
98
        private javax.swing.JLabel jLabel7 = null;
99
        private javax.swing.JLabel lblColor = null;
100

    
101
        private Color backColor = null;
102

    
103
        private JButton btnColor = null;
104
        private ProjectView view=null;
105
        private javax.swing.JScrollPane jScrollPane = null;
106
        private javax.swing.JPanel jPanel = null;
107
        private javax.swing.JPanel jPanel1 = null;
108
        private javax.swing.JPanel jPanel2 = null;
109
        private javax.swing.JPanel jPanel3 = null;
110

    
111
        private javax.swing.JLabel jLabel3 = null;
112
        private javax.swing.JLabel jLabelSep1 = null;
113
        private WindowInfo m_viewinfo = null;
114
        //private JLabel jLblProj = null;
115
        //private JLabel jLblProjName = null;
116
        //private JButton jBtnChangeProj = null;
117
        protected CRSSelectPanel jPanelProj = null;
118
        private AcceptCancelPanel okCancelPanel = null;
119
        private boolean isAcceppted=false;
120
        private JLabel jLabel8 = null;
121
        private JComboBox cmbDistanceArea = null;
122
        /**
123
         * This is the default constructor
124
         *
125
         * @param f Frame padre del dialogo
126
         * @param v Vista que se representa
127
         */
128
        public ViewProperties(ProjectView v) {
129
                view = v;
130
                initialize();
131
        }
132

    
133
        /**
134
         * This method initializes this
135
         */
136
        private void initialize() {
137
                this.setSize(386, 436);
138
                java.awt.FlowLayout layFlowLayout3 = new java.awt.FlowLayout();
139
                layFlowLayout3.setHgap(0);
140
                setLayout(layFlowLayout3);
141
                /*      jLblProjName = new JLabel();
142
                 jLblProj = new JLabel();
143
                 jLblProj.setText(view.getProjection().getAbrev());
144
                 jLblProj.setPreferredSize(new java.awt.Dimension(180,20));
145
                 jLblProjName.setText("Proyecci?n actual:");
146
                 jLblProjName.setPreferredSize(new java.awt.Dimension(95,15));*/
147
                this.setPreferredSize(new java.awt.Dimension(365,463));
148
                add(getJPanel(), null);
149
                add(getJPanel1(), null);
150
                add(getJPanel2(), null);
151
                add(getJPanel3(), null);
152
                add(getJLabelSep1(), null);
153
                this.add(getJPanelProj(), null);
154
                this.add(getJLabel6(), null);
155
                add(getJScrollPane(), null);
156

    
157

    
158
                this.add(getJLabel7(), null);
159
                this.add(getLblColor(), null);
160
                this.add(getBtnColor(), null);
161

    
162

    
163
                add(getJLabel3(), null);
164
                this.add(getOkCancelPanel(), null);
165
                txtName.setText(view.getName());
166
                txtDate.setText(view.getCreationDate());
167
                txtOwner.setText(view.getOwner());
168

    
169
                cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort().getMapUnits());
170
                cmbDistanceUnits.setSelectedIndex(view.getMapContext().getViewPort().getDistanceUnits());
171
                cmbDistanceArea.setSelectedIndex(view.getMapContext().getViewPort().getDistanceArea());
172
                txtComments.setText(view.getComment());
173

    
174
                lblColor.setBackground(view.getMapContext().getViewPort().getBackColor());
175
        }
176

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

    
188
                return jLabel;
189
        }
190

    
191
        private javax.swing.JLabel getJLabelSep1() {
192
                if (jLabelSep1 == null) {
193
                        jLabelSep1 = new javax.swing.JLabel();
194
                        jLabelSep1.setPreferredSize(new java.awt.Dimension(200, 10));
195
                }
196
                return jLabelSep1;
197
        }
198

    
199
        /**
200
         * This method initializes txtName
201
         *
202
         * @return javax.swing.JTextField
203
         */
204
        private javax.swing.JTextField getTxtName() {
205
                if (txtName == null) {
206
                        txtName = new javax.swing.JTextField();
207
                        txtName.setPreferredSize(new java.awt.Dimension(200, 20));
208
                }
209

    
210
                return txtName;
211
        }
212

    
213
        /**
214
         * This method initializes jLabel1
215
         *
216
         * @return javax.swing.JLabel
217
         */
218
        private javax.swing.JLabel getJLabel1() {
219
                if (jLabel1 == null) {
220
                        jLabel1 = new javax.swing.JLabel();
221
                        jLabel1.setText(PluginServices.getText(this, "creation_date") + ":");
222
                }
223

    
224
                return jLabel1;
225
        }
226

    
227
        /**
228
         * This method initializes txtDate
229
         *
230
         * @return javax.swing.JTextField
231
         */
232
        private javax.swing.JTextField getTxtDate() {
233
                if (txtDate == null) {
234
                        txtDate = new javax.swing.JTextField();
235
                        txtDate.setPreferredSize(new java.awt.Dimension(200, 20));
236
                        txtDate.setEditable(false);
237
                        txtDate.setBackground(java.awt.Color.white);
238
                }
239

    
240
                return txtDate;
241
        }
242

    
243
        /**
244
         * This method initializes jLabel2
245
         *
246
         * @return javax.swing.JLabel
247
         */
248
        private javax.swing.JLabel getJLabel2() {
249
                if (jLabel2 == null) {
250
                        jLabel2 = new javax.swing.JLabel();
251
                        jLabel2.setText(PluginServices.getText(this, "owner") + ":");
252
                }
253

    
254
                return jLabel2;
255
        }
256

    
257
        /**
258
         * This method initializes txtOwner
259
         *
260
         * @return javax.swing.JTextField
261
         */
262
        private javax.swing.JTextField getTxtOwner() {
263
                if (txtOwner == null) {
264
                        txtOwner = new javax.swing.JTextField();
265
                        txtOwner.setPreferredSize(new java.awt.Dimension(200, 20));
266
                }
267

    
268
                return txtOwner;
269
        }
270

    
271
        /**
272
         * This method initializes jLabel4
273
         *
274
         * @return javax.swing.JLabel
275
         */
276
        private javax.swing.JLabel getJLabel4() {
277
                if (jLabel4 == null) {
278
                        jLabel4 = new javax.swing.JLabel();
279
                        jLabel4.setText(PluginServices.getText(this, "map_units") + ":");
280
                        jLabel4.setName("jLabel4");
281
                }
282

    
283
                return jLabel4;
284
        }
285

    
286
        /**
287
         * This method initializes cmbMapUnits
288
         *
289
         * @return javax.swing.JComboBox
290
         */
291
        private javax.swing.JComboBox getCmbMapUnits() {
292
                if (cmbMapUnits == null|| MapContext.getDistanceNames().length>cmbMapUnits.getItemCount()) {
293
                        boolean includePixels;
294
                        cmbMapUnits = new JComboBoxUnits(includePixels = false);
295

    
296
//                        cmbMapUnits = new javax.swing.JComboBox(getUnitsNames());
297
                        cmbMapUnits.setPreferredSize(new java.awt.Dimension(200, 20));
298
                        IProjection proj=view.getProjection();
299
                        if (!proj.isProjected()) {
300
//                                if (cmbMapUnits.getItemCount()==MapContext.NAMES.length) {
301
//                                        cmbMapUnits.addItem(PluginServices.getText(this, Attributes.DEGREES));
302
//                                }
303
                                cmbMapUnits.setSelectedItem(PluginServices.getText(this,"Grados")); // deegree
304
                                cmbMapUnits.setEnabled(false);
305
                        }else {
306
                                if (!(cmbMapUnits.getItemCount()==MapContext.getDistanceNames().length)) {
307
                                        cmbMapUnits.removeItem(PluginServices.getText(this,"Grados")); // deegree
308
                                        view.getMapContext().getViewPort().setMapUnits(1);
309
                                }
310
                                cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort().getMapUnits());
311
                                cmbMapUnits.setEnabled(true);
312
                        }
313
//                        cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort().getMapUnits());
314

    
315
//
316
//                        cmbMapUnits.addActionListener(new java.awt.event.ActionListener() {
317
//                                public void actionPerformed(java.awt.event.ActionEvent e) {
318
//                                        //view.getMapContext().getViewPort().setMapUnits(cmbMapUnits.getSelectedIndex());
319
//                                }
320
//                        });
321
                }
322

    
323
                return cmbMapUnits;
324
        }
325

    
326
        /**
327
         * This method initializes jLabel5
328
         *
329
         * @return javax.swing.JLabel
330
         */
331
        private javax.swing.JLabel getJLabel5() {
332
                if (jLabel5 == null) {
333
                        jLabel5 = new javax.swing.JLabel();
334
                        jLabel5.setText(PluginServices.getText(this, "distance_units") + ":");
335
                        jLabel5.setName("jLabel5");
336
                }
337

    
338
                return jLabel5;
339
        }
340

    
341
        /**
342
         * This method initializes cmbDistanceUnits
343
         *
344
         * @return javax.swing.JComboBox
345
         */
346
        private javax.swing.JComboBox getCmbDistanceUnits() {
347
                if (cmbDistanceUnits == null|| MapContext.getDistanceNames().length>cmbDistanceUnits.getItemCount()){
348
                        boolean includePixels;
349
                        cmbDistanceUnits = new JComboBoxUnits(includePixels = false);
350
//                        cmbDistanceUnits = new javax.swing.JComboBox(getUnitsNames());
351
                        cmbDistanceUnits.setPreferredSize(new java.awt.Dimension(200, 20));
352
//                        cmbDistanceUnits.setEditable(false);
353
//                        cmbDistanceUnits.setSelectedIndex(view.getMapContext().getViewPort().getDistanceUnits());
354
//                        cmbDistanceUnits.addActionListener(new java.awt.event.ActionListener() {
355
//                                public void actionPerformed(java.awt.event.ActionEvent e) {
356
//                                        //view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
357
//                                }
358
//                        });
359
                }
360

    
361
                return cmbDistanceUnits;
362
        }
363

    
364
        /**
365
         * This method initializes jLabel6
366
         *
367
         * @return javax.swing.JLabel
368
         */
369
        private javax.swing.JLabel getJLabel6() {
370
                if (jLabel6 == null) {
371
                        jLabel6 = new javax.swing.JLabel();
372
                        jLabel6.setText(PluginServices.getText(this, "comentarios") + ":");
373
                        jLabel6.setPreferredSize(new java.awt.Dimension(340,35));
374
                        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
375
                        jLabel6.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
376
                }
377

    
378
                return jLabel6;
379
        }
380

    
381
        /**
382
         * This method initializes txtComments
383
         *
384
         * @return javax.swing.JTextArea
385
         */
386
        private javax.swing.JTextArea getTxtComments() {
387
                if (txtComments == null) {
388
                        txtComments = new javax.swing.JTextArea();
389
                        txtComments.setRows(1);
390
                        txtComments.setColumns(28);
391
                }
392

    
393
                return txtComments;
394
        }
395

    
396
        /**
397
         * This method initializes jLabel7
398
         *
399
         * @return javax.swing.JLabel
400
         */
401
        private javax.swing.JLabel getJLabel7() {
402
                if (jLabel7 == null) {
403
                        jLabel7 = new javax.swing.JLabel();
404
                        jLabel7.setText(PluginServices.getText(this, "background_color") +
405
                        ":");
406
                        jLabel7.setPreferredSize(new java.awt.Dimension(190,16));
407
                }
408

    
409
                return jLabel7;
410
        }
411

    
412
        /**
413
         * This method initializes lblColor
414
         *
415
         * @return javax.swing.JLabel
416
         */
417
        private javax.swing.JLabel getLblColor() {
418
                if (lblColor == null) {
419
                        lblColor = new javax.swing.JLabel();
420
                        lblColor.setText("");
421
                        lblColor.setPreferredSize(new java.awt.Dimension(30, 16));
422
                        Color theColor = view.getMapContext().getViewPort().getBackColor();
423
                        backColor=theColor;
424
                        if (theColor == null) theColor = Color.WHITE;
425
                        lblColor.setBackground(theColor);
426
                        lblColor.setOpaque(true);
427
                }
428

    
429
                return lblColor;
430
        }
431

    
432
        /**
433
         * This method initializes btnColor
434
         *
435
         * @return javax.swing.JButton
436
         */
437
        private JButton getBtnColor() {
438
                if (btnColor == null) {
439
                        btnColor = new JButton();
440

    
441
                        btnColor.setText("...");
442

    
443
                        btnColor.addActionListener(new java.awt.event.ActionListener() {
444
                                public void actionPerformed(java.awt.event.ActionEvent e) {
445
                                        Color ret = JColorChooser.showDialog(ViewProperties.this,
446
                                                        PluginServices.getText(this, "background_color"),
447
                                                        lblColor.getBackground());
448

    
449
                                        if (ret != null) {
450
                                                lblColor.setBackground(ret);
451
                                                backColor = ret;
452
                                        }
453
                                        else
454
                                                lblColor.setBackground(Color.WHITE);
455
                                }
456
                        });
457
                }
458

    
459
                return btnColor;
460
        }
461

    
462
        /**
463
         * This method initializes jScrollPane
464
         *
465
         * @return javax.swing.JScrollPane
466
         */
467
        private javax.swing.JScrollPane getJScrollPane() {
468
                if (jScrollPane == null) {
469
                        jScrollPane = new javax.swing.JScrollPane();
470
                        jScrollPane.setViewportView(getTxtComments());
471
                        jScrollPane.setPreferredSize(new java.awt.Dimension(340, 70));
472
                }
473

    
474
                return jScrollPane;
475
        }
476

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

    
486
                        /*
487
                        java.awt.FlowLayout layFlowLayout4 = new java.awt.FlowLayout();
488
                        layFlowLayout4.setAlignment(java.awt.FlowLayout.LEFT);
489
                        layFlowLayout4.setVgap(9);
490
                        jPanel.setLayout(layFlowLayout4);
491
                        */
492

    
493
            GridLayout layout = new GridLayout(3,1);
494
            layout.setVgap(5);
495
            jPanel.setLayout(layout);
496

    
497

    
498
                        jPanel.add(getJLabel(), null);
499
                        jPanel.add(getJLabel1(), null);
500
                        jPanel.add(getJLabel2(), null);
501
                        jPanel.setPreferredSize(new java.awt.Dimension(140, 80));
502
                }
503

    
504
                return jPanel;
505
        }
506

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

    
516
                        java.awt.FlowLayout layFlowLayout2 = new java.awt.FlowLayout();
517
                        layFlowLayout2.setHgap(5);
518
                        layFlowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
519
                        jPanel1.setLayout(layFlowLayout2);
520
                        jPanel1.add(getTxtName(), null);
521
                        jPanel1.add(getTxtDate(), null);
522
                        jPanel1.add(getTxtOwner(), null);
523
                        jPanel1.setPreferredSize(new java.awt.Dimension(210, 80));
524
                }
525

    
526
                return jPanel1;
527
        }
528

    
529
        /**
530
         * This method initializes jPanel2
531
         *
532
         * @return javax.swing.JPanel
533
         */
534
        private javax.swing.JPanel getJPanel2() {
535
                if (jPanel2 == null) {
536
                        jLabel8 = new JLabel();
537
                        jLabel8.setText(PluginServices.getText(this,"unidades_area"));
538
                        GridLayout gridLayout = new GridLayout();
539
                        gridLayout.setRows(3);
540
                        jPanel2 = new javax.swing.JPanel();
541

    
542
                        jPanel2.setLayout(gridLayout);
543
                        jPanel2.setPreferredSize(new java.awt.Dimension(140,80));
544
                        jPanel2.add(getJLabel4(), null);
545
                        jPanel2.add(getJLabel5(), null);
546
                        jPanel2.add(jLabel8, null);
547
                }
548

    
549
                return jPanel2;
550
        }
551

    
552
        /**
553
         * This method initializes jPanel3
554
         *
555
         * @return javax.swing.JPanel
556
         */
557
        private javax.swing.JPanel getJPanel3() {
558
                if (jPanel3 == null) {
559
                        jPanel3 = new javax.swing.JPanel();
560

    
561
                        java.awt.FlowLayout layFlowLayout6 = new java.awt.FlowLayout();
562
                        layFlowLayout6.setAlignment(java.awt.FlowLayout.LEFT);
563
                        jPanel3.setLayout(layFlowLayout6);
564
                        jPanel3.add(getCmbMapUnits(), null);
565
                        jPanel3.add(getCmbDistanceUnits(), null);
566
                        jPanel3.setPreferredSize(new java.awt.Dimension(210,80));
567
                        jPanel3.add(getCmbDistanceArea(), null);
568
                }
569

    
570
                return jPanel3;
571
        }
572

    
573

    
574
        /**
575
         * This method initializes jLabel3
576
         *
577
         * @return javax.swing.JLabel
578
         */
579
        private javax.swing.JLabel getJLabel3() {
580
                if (jLabel3 == null) {
581
                        jLabel3 = new javax.swing.JLabel();
582
                        jLabel3.setText("");
583
                        jLabel3.setPreferredSize(new java.awt.Dimension(30, 0));
584
                }
585

    
586
                return jLabel3;
587
        }
588

    
589
        /**
590
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
591
         */
592
        public WindowInfo getWindowInfo() {
593
                WindowInfo m_viewinfo=new WindowInfo();
594
                m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_vista"));
595
                m_viewinfo.setHeight(410);
596
                m_viewinfo.setWidth(386);
597
                return m_viewinfo;
598
        }
599

    
600
        /**
601
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
602
         */
603
        public void viewActivated() {
604
        }
605
        /**
606
         * This method initializes jButton
607
         *
608
         * @return javax.swing.JButton
609
         * /
610
         private JButton getJBtnChangeProj() {
611
         if (jBtnChangeProj == null) {
612
         jBtnChangeProj = new JButton();
613
         jBtnChangeProj.setText("...");
614
         jBtnChangeProj.setPreferredSize(new java.awt.Dimension(34,16));
615
         jBtnChangeProj.addActionListener(new java.awt.event.ActionListener() {
616
         public void actionPerformed(java.awt.event.ActionEvent e) {
617
         CSSelectionDialog csSelect = new CSSelectionDialog();
618
         csSelect.setProjection(view.getProjection());
619

620
         PluginServices.getMDIManager().addView(csSelect);
621

622
         if (csSelect.isOkPressed()) {
623
         view.getMapContext().setProjection(csSelect.getProjection());
624
         jLblProj.setText(view.getProjection().getAbrev());
625
         }
626
         }
627
         });
628
         }
629
         return jBtnChangeProj;
630
         } */
631
        /**
632
         * This method initializes jPanel4
633
         *
634
         * @return javax.swing.JPanel
635
         */
636
        private CRSSelectPanel getJPanelProj() {
637
                if (jPanelProj == null) {
638
                        IProjection proj=view.getProjection();
639
                        jPanelProj = CRSSelectPanel.getPanel(proj);
640
                        jPanelProj.setPreferredSize(new java.awt.Dimension(330,35));
641
                        jPanelProj.addActionListener(new java.awt.event.ActionListener() {
642
                                public void actionPerformed(java.awt.event.ActionEvent e) {
643
                                        if (jPanelProj.isOkPressed()) {
644
                                                if (!jPanelProj.getCurProj().isProjected()) {
645
//                                                        if (getCmbMapUnits().getItemCount()==MapContext.NAMES.length) {
646
//                                                                getCmbMapUnits().addItem(PluginServices.getText(this, Attributes.DEGREES));
647
//                                                        }
648
                                                        getCmbMapUnits().setSelectedItem(PluginServices.getText(this, Attributes.DEGREES));
649
                                                        getCmbMapUnits().setEnabled(false);
650
                                                }else {
651
                                                        if (getCmbMapUnits().getSelectedItem().equals(PluginServices.getText(this, Attributes.DEGREES))) {
652
                                                                getCmbMapUnits().setSelectedIndex(1);
653
                                                        }
654
                                                        getCmbMapUnits().setEnabled(true);
655
//                                                        if (!(getCmbMapUnits().getItemCount()==MapContext.NAMES.length)) {
656
//                                                                getCmbMapUnits().removeItem(PluginServices.getText(this, Attributes.DEGREES));
657
//                                                        }
658
                                                }
659
                                                view.setProjection(jPanelProj.getCurProj());
660
                                        }
661
                                }
662
                        });
663

    
664
//                        jPanelProj.add(jLblProjName, null);
665
//                        jPanelProj.add(jLblProj, null);
666
//                        jPanelProj.add(getJBtnChangeProj(), null);
667
                }
668
                return jPanelProj;
669
        }
670

    
671
        /**
672
         * @see com.iver.andami.ui.mdiManager.SingletonWindow#getWindowModel()
673
         */
674
        public Object getWindowModel() {
675
                return view;
676
        }
677

    
678
        /**
679
         * This method initializes okCancelPanel
680
         *
681
         * @return javax.swing.JPanel
682
         */
683
        private AcceptCancelPanel getOkCancelPanel() {
684
                if (okCancelPanel == null) {
685
                        ActionListener okAction, cancelAction;
686
                        okAction = new java.awt.event.ActionListener() {
687
                                public void actionPerformed(java.awt.event.ActionEvent e) {
688
                                        String name=txtName.getText();
689
                                        if (name == null || name.length() == 0) {
690
                                                return;
691
                                        }
692
                                        Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
693
                                        ArrayList<ProjectDocument> views=project.getDocumentsByType(ProjectViewFactory.registerName);
694

    
695
                                        for (int i=0; i<views.size(); i++){
696
                                                if (view.equals(views.get(i))){
697
                                                        continue;
698
                                                }
699
                                                if (((ProjectDocument)views.get(i)).getName().equals(name)){
700
                                                        JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "elemento_ya_existe"));
701
                                                        return;
702
                                                }
703

    
704
                                        }
705

    
706
                                        view.setName(name);
707
                                        view.setCreationDate(txtDate.getText());
708
                                        view.setOwner(txtOwner.getText());
709
                                        view.setComment(txtComments.getText());
710
                                        view.getMapContext().getViewPort().setMapUnits(cmbMapUnits.getSelectedIndex());
711
                                        view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
712
                                        view.getMapContext().getViewPort().setDistanceArea(cmbDistanceArea.getSelectedIndex());
713
                                        view.setBackColor(backColor);
714
                                        isAcceppted=true;
715
                                        PluginServices.getMDIManager().closeWindow(ViewProperties.this);
716
                                }
717
                        };
718
                        cancelAction = new java.awt.event.ActionListener() {
719

    
720
                                public void actionPerformed(java.awt.event.ActionEvent e) {
721
                                        isAcceppted=false;
722
                                        PluginServices.getMDIManager().closeWindow(ViewProperties.this);
723
                                }
724
                        };
725
                        okCancelPanel = new AcceptCancelPanel(okAction, cancelAction);
726
                        Dimension sz = this.getSize();
727
                        sz.setSize((int)sz.getWidth()-20, (int) sz.getHeight());
728
                        okCancelPanel.setPreferredSize(sz);
729
                }
730
                return okCancelPanel;
731
        }
732

    
733
//        private String[] getUnitsNames() {
734
//                if (unitsNames == null) {
735
//                        unitsNames = new String[MapContext.NAMES.length];
736
//                        int i=0;
737
//                        for (i=0;i<MapContext.NAMES.length;i++) {
738
//                                unitsNames[i]=PluginServices.getText(this, MapContext.NAMES[i]);
739
//                        }
740
//                        //unitsNames[i]=PluginServices.getText(this, Attributes.DEGREES);
741
//                }
742
//                return unitsNames;
743
//        }
744

    
745
        public boolean isAcceppted() {
746
                return isAcceppted;
747
        }
748
        /**
749
         * This method initializes jComboBox
750
         *
751
         * @return javax.swing.JComboBox
752
         */
753
        private JComboBox getCmbDistanceArea() {
754
                String[] names= MapContext.getAreaNames();
755
                if (cmbDistanceArea == null || names.length>cmbDistanceArea.getItemCount()) {
756
                        for (int i = 0; i < names.length; i++) {
757
                                names[i]=PluginServices.getText(this,names[i])+ MapContext.getOfLinear(i);
758
                        }
759
                        cmbDistanceArea = new javax.swing.JComboBox(names);
760
                        cmbDistanceArea.setPreferredSize(new java.awt.Dimension(200, 20));
761
                        cmbDistanceArea.setEditable(false);
762
                        cmbDistanceArea.setSelectedIndex(view.getMapContext().getViewPort().getDistanceArea());
763
                        cmbDistanceArea.addActionListener(new java.awt.event.ActionListener() {
764
                                public void actionPerformed(java.awt.event.ActionEvent e) {
765
                                        //view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
766
                                }
767
                        });
768
                }
769

    
770
                return cmbDistanceArea;
771

    
772
        }
773

    
774
        public Object getWindowProfile() {
775
                // TODO Auto-generated method stub
776
                return WindowInfo.PROPERTIES_PROFILE;
777
        }
778
}  //  @jve:decl-index=0:visual-constraint="10,10"