Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / gui / ViewProperties.java @ 41248

History | View | Annotate | Download (24 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.project.documents.view.gui;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.Color;
28
import java.awt.Component;
29
import java.awt.Dimension;
30
import java.awt.GridBagConstraints;
31
import java.awt.GridBagLayout;
32
import java.awt.GridLayout;
33
import java.awt.Insets;
34
import java.awt.event.ActionListener;
35
import java.util.List;
36

    
37
import javax.swing.BorderFactory;
38
import javax.swing.JButton;
39
import javax.swing.JCheckBox;
40
import javax.swing.JColorChooser;
41
import javax.swing.JComboBox;
42
import javax.swing.JComponent;
43
import javax.swing.JLabel;
44
import javax.swing.JOptionPane;
45
import javax.swing.JPanel;
46

    
47
import org.cresques.cts.IProjection;
48

    
49
import org.gvsig.andami.PluginServices;
50
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
51
import org.gvsig.andami.ui.mdiManager.WindowInfo;
52
import org.gvsig.app.gui.JComboBoxUnits;
53
import org.gvsig.app.gui.panels.CRSSelectPanel;
54
import org.gvsig.app.gui.preferencespage.ViewPage;
55
import org.gvsig.app.project.DefaultProject;
56
import org.gvsig.app.project.Project;
57
import org.gvsig.app.project.ProjectManager;
58
import org.gvsig.app.project.ProjectPreferences;
59
import org.gvsig.app.project.documents.Document;
60
import org.gvsig.app.project.documents.view.ViewDocument;
61
import org.gvsig.app.project.documents.view.ViewManager;
62
import org.gvsig.fmap.crs.CRSFactory;
63
import org.gvsig.fmap.mapcontext.MapContext;
64
import org.gvsig.gui.beans.AcceptCancelPanel;
65
import org.gvsig.i18n.Messages;
66
import org.gvsig.utils.XMLEntity;
67

    
68
/**
69
 * Dialogo donde se muestran las propiedades de una vista
70
 * 
71
 * @author Fernando Gonz?lez Cort?s
72
 * @author gvSIG Team
73
 */
74
public class ViewProperties extends JPanel implements SingletonWindow {
75

    
76
    private static final long serialVersionUID = 5328865370833315385L;
77
    
78
    public static final int FIXED_WIDTH = 300;
79
    
80
    private javax.swing.JLabel jLabelName = null;
81
    private javax.swing.JTextField txtName = null;
82
    private javax.swing.JLabel jLabelDate = null;
83
    private javax.swing.JTextField txtDate = null;
84
    private javax.swing.JLabel jLabelOwner = null;
85
    private javax.swing.JTextField txtOwner = null;
86
    private javax.swing.JLabel jLabelMapUnits = null;
87
    private javax.swing.JComboBox cmbMapUnits = null;
88
    private javax.swing.JLabel jLabelDistanceUnits = null;
89
    private javax.swing.JComboBox cmbDistanceUnits = null;
90
    private javax.swing.JLabel jLabelAreaUnits = null;
91
    private javax.swing.JTextArea txtComments = null;
92
    private javax.swing.JLabel jLabelColor = null;
93
    private javax.swing.JLabel jLabelComments = null;
94
    private javax.swing.JPanel lblColor = null;
95
    
96
    private JCheckBox setAsDefCrsChk = null;
97
    private ViewProperties self = null;
98

    
99
    private Color backColor = null;
100

    
101
    private JButton btnColor = null;
102
    private ViewDocument view = null;
103
    private javax.swing.JScrollPane jScrollPane = null;
104
    protected CRSSelectPanel jPanelProj = null;
105
    private AcceptCancelPanel okCancelPanel = null;
106
    private boolean isAcceppted = false;
107
    private JComboBox cmbDistanceArea = null;
108

    
109
    /**
110
     * This is the default constructor
111
     * 
112
     * @param f
113
     *            Frame padre del dialogo
114
     * @param v
115
     *            Vista que se representa
116
     */
117
    public ViewProperties(ViewDocument v) {
118
        view = v;
119
        initialize();
120
        self = this;
121
    }
122

    
123
    /**
124
     * This method initializes this
125
     */
126
    private void initialize() {
127
        setLayout(new GridBagLayout());
128
        setBorder(BorderFactory.createEmptyBorder(4, 5, 4, 5));
129

    
130
        GridBagConstraints c = new GridBagConstraints();
131
        c.insets = new Insets(2, 5, 2, 5);
132
        c.gridy = -1;
133

    
134
        addRow(c, getJLabelName(), getTxtName());
135
        addRow(c, getJLabelDate(), getTxtDate());
136
        addRow(c, getJLabelOwner(), getTxtOwner());
137
        addRow(c, getJLabelMapUnits(), getCmbMapUnits());
138
        addRow(c, getJLabelDistanceUnits(), getCmbDistanceUnits());
139
        addRow(c, getJLabelAreaUnits(), getCmbDistanceArea());
140

    
141
        // some extra space
142
        addRow(c, new JLabel(" "), new JLabel(" "));
143

    
144
        GridLayout gl = new GridLayout(1,2);
145
        JPanel colorPanel = new JPanel(gl);
146
        colorPanel.add(getJLabelColor());
147
        JPanel secondHalfPanel = new JPanel(new GridBagLayout());
148

    
149
        GridBagConstraints c2 = new GridBagConstraints();
150
        
151
        c2.fill = GridBagConstraints.BOTH;
152
        c2.weightx = 1.0;   //request any extra hor space
153
        c2.gridx = 0;      
154
        c2.gridwidth = 1;  
155
        c2.gridy = 0;      
156
        
157
        JPanel auxPanel = new JPanel(new GridLayout(1,2));
158
        auxPanel.add(getLblColor(secondHalfPanel.getBackground()));
159
        auxPanel.add(new JLabel(""));
160
        secondHalfPanel.add(auxPanel, c2);
161
        
162
        c2.fill = GridBagConstraints.NONE;
163
        c2.weightx = 0.0;  
164
        c2.gridx = 1;      
165
        secondHalfPanel.add(getBtnColor(), c2);
166

    
167
        colorPanel.add(secondHalfPanel);
168
        
169
        c.gridx = 0;
170
        c.gridwidth = 2;
171
        c.gridy++;
172
        add(colorPanel, c);
173
        c.gridwidth = 1;
174

    
175
        c.anchor = GridBagConstraints.WEST;
176
        c.weightx = 0.0d;
177
        c.gridx = 0;
178
        c.gridwidth = GridBagConstraints.REMAINDER;
179
        c.gridy++;
180
        c.weightx = 1.0d;
181
        c.fill = GridBagConstraints.HORIZONTAL;
182
        add(getJPanelProj(), c);
183
        
184
        // ============ set current as app default CRS
185
        c.anchor = GridBagConstraints.CENTER;
186
        c.gridy++;
187
        JPanel auxp = new JPanel(new BorderLayout());
188
        auxp.add(getSetAsDefaultCrsCheckbox(), BorderLayout.CENTER);
189
        add(auxp, c);
190
        // =============================
191
        
192
        // some extra space
193
        addRow(c, new JLabel(" "), new JLabel(" "));
194

    
195
        c.anchor = GridBagConstraints.WEST;
196
        c.weightx = 0.0d;
197
        c.gridx = 0;
198
        c.gridy++;
199
        add(getJLabelComments(), c);
200

    
201
        c.fill = GridBagConstraints.BOTH;
202
        c.weightx = 1.0d;
203
        c.gridy++;
204
        c.gridwidth = 2;
205
        add(getJScrollPaneComments(), c);
206

    
207
        c.anchor = GridBagConstraints.EAST;
208
        c.gridx = 0;
209
        c.gridwidth = 2;
210
        c.gridy++;
211
        c.weightx = 1.0d;
212

    
213
        add(getOkCancelPanel(), c);
214
    }
215

    
216

    
217

    
218

    
219
    /**
220
     * @return
221
     */
222
    private JCheckBox getSetAsDefaultCrsCheckbox() {
223
        
224
        if (setAsDefCrsChk == null) {
225
            setAsDefCrsChk = new JCheckBox(Messages.getText(
226
                "_Set_this_CRS_as_app_default"));
227
            updateSetAsDefaultCRSChk();
228
        }
229
        return setAsDefCrsChk;
230
    }
231
    
232

    
233
    private String getAppDefaultCRS() {
234
        ProjectPreferences pp = new ProjectPreferences();
235
        IProjection curr_def = pp.getDefaultProjection();
236
        return curr_def.getAbrev();
237
    }
238
    
239
    private void setAppDefaultCRS(String abbrev) {
240
        PluginServices ps = PluginServices.getPluginServices(this);
241
        XMLEntity xml = ps.getPersistentXML();
242
        xml.putProperty(ViewPage.DEFAULT_PROJECTION_KEY_NAME, abbrev);
243
        IProjection proj = CRSFactory.getCRS(abbrev);
244
        DefaultProject.setDefaultProjection(proj);
245
    }
246
    
247
    private void updateSetAsDefaultCRSChk() {
248
        
249
        IProjection view_proj = this.jPanelProj.getCurProj();
250
        String view_abbrev = view_proj.getAbrev();
251
        
252
        String curr_app_crs_def = getAppDefaultCRS();
253
        if (view_abbrev.compareToIgnoreCase(curr_app_crs_def) == 0) {
254
            // same as curr default
255
            this.getSetAsDefaultCrsCheckbox().setSelected(true);
256
            this.getSetAsDefaultCrsCheckbox().setEnabled(false);
257
        } else {
258
            this.getSetAsDefaultCrsCheckbox().setEnabled(true);
259
            this.getSetAsDefaultCrsCheckbox().setSelected(false);
260
        }
261
    }
262

    
263
    private void addRow(GridBagConstraints c, JComponent label, JComponent text) {
264
        c.anchor = GridBagConstraints.WEST;
265
        c.weightx = 0.0d;
266
        c.gridx = 0;
267
        c.gridy++;
268
        add(label, c);
269

    
270
        c.fill = GridBagConstraints.HORIZONTAL;
271
        c.weightx = 1.0d;
272
        c.gridx = 1;
273
        add(text, c);
274
    }
275
    
276

    
277

    
278
    /**
279
     * This method initializes jLabel
280
     * 
281
     * @return javax.swing.JLabel
282
     */
283
    private javax.swing.JLabel getJLabelName() {
284
        if (jLabelName == null) {
285
            jLabelName =
286
                new javax.swing.JLabel(Messages.getText("nombre") + ":");
287
        }
288

    
289
        return jLabelName;
290
    }
291

    
292
    /**
293
     * This method initializes txtName
294
     * 
295
     * @return javax.swing.JTextField
296
     */
297
    private javax.swing.JTextField getTxtName() {
298
        if (txtName == null) {
299
            txtName = new javax.swing.JTextField(view.getName());
300
        }
301

    
302
        return txtName;
303
    }
304

    
305
    /**
306
     * This method initializes jLabel1
307
     * 
308
     * @return javax.swing.JLabel
309
     */
310
    private javax.swing.JLabel getJLabelDate() {
311
        if (jLabelDate == null) {
312
            jLabelDate =
313
                new javax.swing.JLabel(Messages.getText("creation_date") + ":");
314
        }
315

    
316
        return jLabelDate;
317
    }
318

    
319
    /**
320
     * This method initializes txtDate
321
     * 
322
     * @return javax.swing.JTextField
323
     */
324
    private javax.swing.JTextField getTxtDate() {
325
        if (txtDate == null) {
326
            txtDate = new javax.swing.JTextField(view.getCreationDate());
327
            txtDate.setEditable(false);
328
            txtDate.setBackground(java.awt.Color.white);
329
        }
330

    
331
        return txtDate;
332
    }
333

    
334
    /**
335
     * This method initializes jLabel2
336
     * 
337
     * @return javax.swing.JLabel
338
     */
339
    private javax.swing.JLabel getJLabelOwner() {
340
        if (jLabelOwner == null) {
341
            jLabelOwner =
342
                new javax.swing.JLabel(Messages.getText("owner") + ":");
343
        }
344

    
345
        return jLabelOwner;
346
    }
347

    
348
    /**
349
     * This method initializes txtOwner
350
     * 
351
     * @return javax.swing.JTextField
352
     */
353
    private javax.swing.JTextField getTxtOwner() {
354
        if (txtOwner == null) {
355
            txtOwner = new javax.swing.JTextField(view.getOwner());
356
        }
357

    
358
        return txtOwner;
359
    }
360

    
361
    /**
362
     * This method initializes jLabel4
363
     * 
364
     * @return javax.swing.JLabel
365
     */
366
    private javax.swing.JLabel getJLabelMapUnits() {
367
        if (jLabelMapUnits == null) {
368
            jLabelMapUnits =
369
                new javax.swing.JLabel(Messages.getText("map_units") + ":");
370
        }
371

    
372
        return jLabelMapUnits;
373
    }
374

    
375
    /**
376
     * This method initializes cmbMapUnits
377
     * 
378
     * @return javax.swing.JComboBox
379
     */
380
    private javax.swing.JComboBox getCmbMapUnits() {
381
        if (cmbMapUnits == null
382
            || MapContext.getDistanceNames().length > cmbMapUnits
383
                .getItemCount()) {
384
            cmbMapUnits = new JComboBoxUnits(false);
385

    
386
            IProjection proj = view.getProjection();
387
            if (!proj.isProjected()) {
388
                cmbMapUnits.setSelectedItem(Messages.getText("Grados")); // deegree
389
                cmbMapUnits.setEnabled(false);
390
            } else {
391
                if (!(cmbMapUnits.getItemCount() == MapContext
392
                    .getDistanceNames().length)) {
393
                    cmbMapUnits.removeItem(Messages.getText("Grados")); // deegree
394
                    view.getMapContext().getViewPort().setMapUnits(1);
395
                }
396
                cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort()
397
                    .getMapUnits());
398
                cmbMapUnits.setEnabled(true);
399
            }
400
        }
401

    
402
        return cmbMapUnits;
403
    }
404

    
405
    /**
406
     * This method initializes jLabel5
407
     * 
408
     * @return javax.swing.JLabel
409
     */
410
    private javax.swing.JLabel getJLabelDistanceUnits() {
411
        if (jLabelDistanceUnits == null) {
412
            jLabelDistanceUnits =
413
                new javax.swing.JLabel(Messages.getText("distance_units") + ":");
414
        }
415

    
416
        return jLabelDistanceUnits;
417
    }
418

    
419
    /**
420
     * This method initializes jLabel6
421
     * 
422
     * @return javax.swing.JLabel
423
     */
424
    private javax.swing.JLabel getJLabelAreaUnits() {
425
        if (jLabelAreaUnits == null) {
426
            jLabelAreaUnits =
427
                new javax.swing.JLabel(Messages.getText("unidades_area") + ":");
428
        }
429

    
430
        return jLabelAreaUnits;
431
    }
432

    
433
    /**
434
     * This method initializes cmbDistanceUnits
435
     * 
436
     * @return javax.swing.JComboBox
437
     */
438
    private javax.swing.JComboBox getCmbDistanceUnits() {
439
        if (cmbDistanceUnits == null
440
            || MapContext.getDistanceNames().length > cmbDistanceUnits
441
                .getItemCount()) {
442
            cmbDistanceUnits = new JComboBoxUnits(false);
443
            cmbDistanceUnits.setSelectedIndex(view.getMapContext()
444
                .getViewPort().getDistanceUnits());
445
        }
446

    
447
        return cmbDistanceUnits;
448
    }
449

    
450
    /**
451
     * This method initializes jLabel6
452
     * 
453
     * @return javax.swing.JLabel
454
     */
455
    private javax.swing.JLabel getJLabelComments() {
456
        if (jLabelComments == null) {
457
            jLabelComments =
458
                new javax.swing.JLabel(Messages.getText("comentarios") + ":");
459
            jLabelComments
460
                .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
461
            jLabelComments
462
                .setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
463
        }
464

    
465
        return jLabelComments;
466
    }
467

    
468
    /**
469
     * This method initializes txtComments
470
     * 
471
     * @return javax.swing.JTextArea
472
     */
473
    private javax.swing.JTextArea getTxtComments() {
474
        if (txtComments == null) {
475
            txtComments = new javax.swing.JTextArea(view.getComment());
476
            txtComments.setRows(3);
477
            txtComments.setColumns(20);
478
        }
479

    
480
        return txtComments;
481
    }
482

    
483
    /**
484
     * This method initializes jLabel7
485
     * 
486
     * @return javax.swing.JLabel
487
     */
488
    private javax.swing.JLabel getJLabelColor() {
489
        if (jLabelColor == null) {
490
            jLabelColor =
491
                new javax.swing.JLabel(Messages.getText("background_color")
492
                    + ":");
493
        }
494

    
495
        return jLabelColor;
496
    }
497

    
498
    /**
499
     * This method initializes lblColor
500
     * 
501
     * @return javax.swing.JLabel
502
     */
503
    private javax.swing.JPanel getLblColor(Color surround_color) {
504
        if (lblColor == null) {
505
            lblColor = new javax.swing.JPanel();
506
            lblColor.setPreferredSize(new java.awt.Dimension(42, 21));
507
            Color theColor = view.getMapContext().getViewPort().getBackColor();
508
            backColor = theColor;
509
            if (theColor == null) {
510
                theColor = Color.WHITE;
511
            }
512
            lblColor.setBackground(theColor);
513
            // lblColor.setBorder(BorderFactory.createLineBorder(surround_color, 3));
514
            lblColor.setOpaque(true);
515
        }
516

    
517
        return lblColor;
518
    }
519

    
520
    /**
521
     * This method initializes btnColor
522
     * 
523
     * @return javax.swing.JButton
524
     */
525
    private JButton getBtnColor() {
526
        if (btnColor == null) {
527
            btnColor = new JButton();
528
            // ToolsSwingLocator.getUsabilitySwingManager().createJButton();
529

    
530
            btnColor.setText("...");
531

    
532
            btnColor.addActionListener(new java.awt.event.ActionListener() {
533

    
534
                public void actionPerformed(java.awt.event.ActionEvent e) {
535
                    Color ret =
536
                        JColorChooser.showDialog(ViewProperties.this,
537
                            Messages.getText("background_color"),
538
                            lblColor.getBackground());
539

    
540
                    if (ret != null) {
541
                        lblColor.setBackground(ret);
542
                        backColor = ret;
543
                    } else {
544
                        lblColor.setBackground(Color.WHITE);
545
                    }
546
                }
547
            });
548
        }
549

    
550
        return btnColor;
551
    }
552

    
553
    /**
554
     * This method initializes jScrollPane
555
     * 
556
     * @return javax.swing.JScrollPane
557
     */
558
    private javax.swing.JScrollPane getJScrollPaneComments() {
559
        if (jScrollPane == null) {
560
            jScrollPane = new javax.swing.JScrollPane();
561
            jScrollPane.setViewportView(getTxtComments());
562
            Dimension dim = getTxtComments().getPreferredSize();
563
            jScrollPane
564
                .setMinimumSize(new Dimension(dim.width, dim.height + 10));
565
        }
566

    
567
        return jScrollPane;
568
    }
569

    
570
    /**
571
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
572
     */
573
    public WindowInfo getWindowInfo() {
574
        WindowInfo m_viewinfo = new WindowInfo();
575
        this.validate();
576
        m_viewinfo.setTitle(Messages.getText("propiedades_vista"));
577
        Dimension dim = getPreferredSize();
578
        m_viewinfo.setWidth(FIXED_WIDTH);
579
        m_viewinfo.setHeight(dim.height
580
            + getOkCancelPanel().getPreferredSize().height);
581
        return m_viewinfo;
582
    }
583

    
584
    /**
585
     * This method initializes jPanel4
586
     * 
587
     * @return javax.swing.JPanel
588
     */
589
    private CRSSelectPanel getJPanelProj() {
590
        if (jPanelProj == null) {
591
            IProjection proj = view.getProjection();
592
            jPanelProj = CRSSelectPanel.getPanel(proj);
593
            jPanelProj.addActionListener(new java.awt.event.ActionListener() {
594

    
595
                public void actionPerformed(java.awt.event.ActionEvent e) {
596
                    if (jPanelProj.isOkPressed()) {
597
                            int numberOfLayers = view.getMapContext().getLayers().getLayersCount();
598
                            if(numberOfLayers > 0) {
599
                                    warningViewProjectionChange();
600
                            }
601
                            
602
                        if (!jPanelProj.getCurProj().isProjected()) {
603
                            getCmbMapUnits().setSelectedItem(
604
                                PluginServices
605
                                    .getText(this, "Grados"));
606
                            getCmbMapUnits().setEnabled(false);
607
                        } else {
608
                            if (getCmbMapUnits().getSelectedItem().equals(
609
                                PluginServices
610
                                    .getText(this, "Grados"))) {
611
                                getCmbMapUnits().setSelectedIndex(1);
612
                            }
613
                            getCmbMapUnits().setEnabled(true);
614
                        }
615
                        self.updateSetAsDefaultCRSChk();
616
                    }
617
                }
618
            });
619
        }
620
        return jPanelProj;
621
    }
622
    
623
    private void warningViewProjectionChange() {
624
            JOptionPane.showMessageDialog(
625
                            (Component)PluginServices.getMainFrame(),
626
                            Messages.getText("view_contain_layers"));
627
    }
628

    
629
    /**
630
     * @see org.gvsig.andami.ui.mdiManager.SingletonWindow#getWindowModel()
631
     */
632
    public Object getWindowModel() {
633
        return view;
634
    }
635

    
636
    /**
637
     * This method initializes okCancelPanel
638
     * 
639
     * @return javax.swing.JPanel
640
     */
641
    private AcceptCancelPanel getOkCancelPanel() {
642
        if (okCancelPanel == null) {
643
            ActionListener okAction, cancelAction;
644
            okAction = new java.awt.event.ActionListener() {
645

    
646
                public void actionPerformed(java.awt.event.ActionEvent e) {
647
                    String name = txtName.getText();
648
                    if (name == null || name.length() == 0) {
649
                        return;
650
                    }
651
                    Project project =
652
                        ProjectManager.getInstance().getCurrentProject();
653
                    List<Document> views =
654
                        project.getDocuments(ViewManager.TYPENAME);
655
                    for (Document theView : views) {
656
                        if (view.equals(theView)) {
657
                            continue;
658
                        }
659
                        if (theView.getName().equals(name)) {
660
                            JOptionPane.showMessageDialog(
661
                                (Component) PluginServices.getMainFrame(),
662
                                Messages.getText("elemento_ya_existe"));
663
                            return;
664
                        }
665
                    }
666

    
667
                    view.setName(name);
668
                    view.setCreationDate(txtDate.getText());
669
                    view.setOwner(txtOwner.getText());
670
                    view.setComment(txtComments.getText());
671
                    view.getMapContext().getViewPort()
672
                        .setMapUnits(cmbMapUnits.getSelectedIndex());
673
                    view.getMapContext().getViewPort()
674
                        .setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
675
                    view.getMapContext().getViewPort()
676
                        .setDistanceArea(cmbDistanceArea.getSelectedIndex());
677
                    view.setBackColor(backColor);
678

    
679
                    // Select the projection
680
                    if (jPanelProj.isOkPressed()) {
681
                        if (!jPanelProj.getCurProj().isProjected()) {
682
                            getCmbMapUnits().setSelectedItem(
683
                                Messages.getText("Grados"));
684
                            getCmbMapUnits().setEnabled(false);
685
                        } else {
686
                            if (getCmbMapUnits().getSelectedItem().equals(
687
                                Messages.getText("Grados"))) {
688
                                getCmbMapUnits().setSelectedIndex(1);
689
                            }
690
                            getCmbMapUnits().setEnabled(true);
691
                        }
692
                        view.setProjection(jPanelProj.getCurProj());
693
                        if (self.getSetAsDefaultCrsCheckbox().isSelected()) {
694
                            self.setAppDefaultCRS(jPanelProj.getCurProj().getAbrev());
695
                        }
696
                    }
697

    
698
                    isAcceppted = true;
699
                    PluginServices.getMDIManager().closeWindow(
700
                        ViewProperties.this);
701
                }
702
            };
703
            cancelAction = new java.awt.event.ActionListener() {
704

    
705
                public void actionPerformed(java.awt.event.ActionEvent e) {
706
                    isAcceppted = false;
707
                    PluginServices.getMDIManager().closeWindow(
708
                        ViewProperties.this);
709
                }
710
            };
711
            okCancelPanel = new AcceptCancelPanel(okAction, cancelAction);
712
        }
713
        return okCancelPanel;
714
    }
715

    
716
    public boolean isAcceppted() {
717
        return isAcceppted;
718
    }
719

    
720
    /**
721
     * This method initializes jComboBox
722
     * 
723
     * @return javax.swing.JComboBox
724
     */
725
    private JComboBox getCmbDistanceArea() {
726
        String[] names = MapContext.getAreaNames();
727
        if (cmbDistanceArea == null
728
            || names.length > cmbDistanceArea.getItemCount()) {
729
            for (int i = 0; i < names.length; i++) {
730
                names[i] =
731
                    Messages.getText(names[i]) + MapContext.getOfLinear(i);
732
            }
733
            cmbDistanceArea = new javax.swing.JComboBox(names);
734
            cmbDistanceArea.setEditable(false);
735
            cmbDistanceArea.setSelectedIndex(view.getMapContext().getViewPort()
736
                .getDistanceArea());
737
            cmbDistanceArea
738
                .addActionListener(new java.awt.event.ActionListener() {
739

    
740
                    public void actionPerformed(java.awt.event.ActionEvent e) {
741
                        // view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
742
                    }
743
                });
744
        }
745

    
746
        return cmbDistanceArea;
747

    
748
    }
749

    
750
    public Object getWindowProfile() {
751
        return WindowInfo.PROPERTIES_PROFILE;
752
    }
753
    
754

    
755

    
756

    
757
}