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 / GeneralViewPropertiesPage.java @ 47790

History | View | Annotate | Download (24.6 KB)

1

    
2

    
3
package org.gvsig.app.project.documents.view.gui;
4

    
5
import java.awt.BorderLayout;
6
import java.awt.Color;
7
import java.awt.Component;
8
import java.awt.Dimension;
9
import java.awt.GridBagConstraints;
10
import java.awt.GridBagLayout;
11
import java.awt.GridLayout;
12
import java.awt.Insets;
13
import java.util.List;
14
import javax.swing.BorderFactory;
15
import javax.swing.JButton;
16
import javax.swing.JCheckBox;
17
import javax.swing.JComboBox;
18
import javax.swing.JComponent;
19
import javax.swing.JLabel;
20
import javax.swing.JOptionPane;
21
import javax.swing.JPanel;
22
import org.cresques.cts.IProjection;
23
import org.gvsig.andami.PluginServices;
24
import org.gvsig.app.ApplicationLocator;
25
import org.gvsig.app.gui.JComboBoxUnits;
26
import org.gvsig.app.gui.panels.CRSSelectPanel;
27
import org.gvsig.app.project.Project;
28
import org.gvsig.app.project.ProjectManager;
29
import org.gvsig.app.project.ProjectPreferences;
30
import org.gvsig.app.project.documents.Document;
31
import org.gvsig.app.project.documents.view.ViewDocument;
32
import org.gvsig.app.project.documents.view.ViewManager;
33
import org.gvsig.fmap.crs.CRSFactory;
34
import org.gvsig.fmap.mapcontext.MapContext;
35
import org.gvsig.i18n.Messages;
36
import org.gvsig.propertypage.PropertiesPage;
37
import org.gvsig.tools.ToolsLocator;
38
import org.gvsig.tools.i18n.I18nManager;
39
import org.gvsig.tools.swing.api.ToolsSwingLocator;
40
import org.gvsig.tools.swing.api.ToolsSwingManager;
41
import org.gvsig.tools.swing.api.pickercontroller.ColorPickerController;
42

    
43
/**
44
 * @author gvSIG team
45
 *
46
 */
47
public class GeneralViewPropertiesPage extends JPanel implements PropertiesPage {
48

    
49
    /**
50
     *
51
     */
52
    private static final long serialVersionUID = 1356416393907133043L;
53

    
54
    private JPanel propertiesPanel;
55

    
56
    private javax.swing.JLabel jLabelName = null;
57
    private javax.swing.JTextField txtName = null;
58
    private javax.swing.JLabel jLabelDate = null;
59
    private javax.swing.JTextField txtDate = null;
60
    private javax.swing.JLabel jLabelOwner = null;
61
    private javax.swing.JTextField txtOwner = null;
62
    private javax.swing.JLabel jLabelMapUnits = null;
63
    private javax.swing.JComboBox cmbMapUnits = null;
64
    private javax.swing.JLabel jLabelDistanceUnits = null;
65
    private javax.swing.JComboBox cmbDistanceUnits = null;
66
    private javax.swing.JLabel jLabelAreaUnits = null;
67
    private javax.swing.JTextArea txtComments = null;
68
    private javax.swing.JLabel jLabelColor = null;
69
    private javax.swing.JLabel jLabelSelectionColor = null;
70
    private javax.swing.JLabel jLabelComments = null;
71
    private javax.swing.JTextField txtColor = null;
72
    private javax.swing.JTextField txtSelectionColor = null;
73

    
74
    private JCheckBox setAsDefCrsChk = null;
75

    
76
    private Color backColor = null;
77

    
78
    private JButton btnColor = null;
79
    private JButton btnSelectionColor = null;
80
    private ViewDocument view = null;
81
    private javax.swing.JScrollPane jScrollPane = null;
82
    protected CRSSelectPanel jPanelProj = null;
83
    private boolean isAcceppted = false;
84
    private JComboBox cmbDistanceArea = null;
85
    private ColorPickerController colorPicker;
86
    private ColorPickerController selectionColorPicker;
87

    
88
    /**
89
     * @param view
90
     */
91
    public GeneralViewPropertiesPage(ViewDocument view) {
92
        super(new BorderLayout());
93
        this.view = view;
94
        initComponents();
95
    }
96

    
97
    @Override
98
    public void setData(Object data) {
99

    
100
    }
101
            
102
    @Override
103
    public boolean whenAccept() {
104
        isAcceppted = true;
105
        return whenApply();
106
    }
107

    
108
    @Override
109
    public boolean whenApply() {
110
        String name = txtName.getText();
111
        if (name == null || name.length() == 0) {
112
            return false;
113
        }
114
        Project project =
115
            ProjectManager.getInstance().getCurrentProject();
116
        List<Document> views =
117
            project.getDocuments(ViewManager.TYPENAME);
118
        for (Document theView : views) {
119
            if (view.equals(theView)) {
120
                continue;
121
            }
122
            if (theView.getName().equals(name)) {
123
                JOptionPane.showMessageDialog(
124
                    (Component) PluginServices.getMainFrame(),
125
                    Messages.getText("elemento_ya_existe"));
126
                return false;
127
            }
128
        }
129

    
130
        //FIXME: Parche provisional para permitir guardar otras propiedades de la vista en edici?n
131
        if (!view.isLocked()) {
132
            view.setName(name);
133
            view.setCreationDate(txtDate.getText());
134
            view.setOwner(txtOwner.getText());
135
            view.setComment(txtComments.getText());
136
            view.getMapContext().getViewPort()
137
                .setMapUnits(cmbMapUnits.getSelectedIndex());
138
            view.getMapContext().getViewPort()
139
                .setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
140
            view.getMapContext().getViewPort()
141
                .setDistanceArea(cmbDistanceArea.getSelectedIndex());
142
            view.setBackColor(backColor);
143
            view.getMapContext().setSelectionColor(txtSelectionColor.getBackground());
144

    
145
            // Select the projection
146
            if (jPanelProj.isOkPressed()) {
147
                if (!jPanelProj.getCurProj().isProjected()) {
148
                    getCmbMapUnits()
149
                        .setSelectedItem(Messages.getText("Grados"));
150
                    getCmbMapUnits().setEnabled(false);
151
                } else {
152
                    if (getCmbMapUnits().getSelectedItem().equals(
153
                        Messages.getText("Grados"))) {
154
                        getCmbMapUnits().setSelectedIndex(1);
155
                    }
156
                    getCmbMapUnits().setEnabled(true);
157
                }
158
                view.setProjection(jPanelProj.getCurProj());
159
                if (getSetAsDefaultCrsCheckbox().isSelected()) {
160
                    setAppDefaultCRS(jPanelProj.getCurProj().getAbrev());
161
                }
162
                //Las siguientes l?neas est?n duplicadas a prop?sito 
163
                view.getMapContext().getViewPort()
164
                    .setMapUnits(cmbMapUnits.getSelectedIndex());
165
            }
166
        }
167

    
168
        return true;
169
    }
170

    
171
    @Override
172
    public boolean whenCancel() {
173
        isAcceppted = false;
174
        return true;
175
    }
176

    
177
    @Override
178
    public String getTitle() {
179
        I18nManager i18nManager = ToolsLocator.getI18nManager();
180
        return i18nManager.getTranslation("General");
181
    }
182

    
183
    @Override
184
    public int getPriority() {
185
        return 1000;
186
    }
187

    
188
    @Override
189
    public JComponent asJComponent() {
190
        return this;
191
    }
192

    
193
    private void initComponents() {
194
        
195
        ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
196
        this.add(getCenterPanel(), BorderLayout.NORTH);
197

    
198
        this.selectionColorPicker = toolsSwingManager.createColorPickerController(txtSelectionColor, btnSelectionColor);
199
        Color theColor = view.getMapContext().getSelectionColor();
200
        if (theColor == null) {
201
            theColor = MapContext.DEFAULT_SELECTION_COLOR;
202
        }
203
        selectionColorPicker.set(theColor);
204
        
205
        this.colorPicker = toolsSwingManager.createColorPickerController(txtColor, btnColor);
206
        theColor = view.getMapContext().getViewPort().getBackColor();
207
        backColor = theColor;
208
        if (theColor == null) {
209
            theColor = Color.WHITE;
210
        }
211
        colorPicker.set(theColor);
212

    
213

    
214
    }
215

    
216
    private Component getCenterPanel() {
217
        if (propertiesPanel == null) {
218
            propertiesPanel = new JPanel(new GridBagLayout());
219

    
220
            propertiesPanel.setLayout(new GridBagLayout());
221
            propertiesPanel.setBorder(BorderFactory.createEmptyBorder(4, 5, 4, 5));
222

    
223
            GridBagConstraints c = new GridBagConstraints();
224
            c.insets = new Insets(2, 5, 2, 5);
225
            c.gridy = -1;
226

    
227
            addRow(propertiesPanel, c, getJLabelName(), getTxtName());
228
            addRow(propertiesPanel, c, getJLabelDate(), getTxtDate());
229
            addRow(propertiesPanel, c, getJLabelOwner(), getTxtOwner());
230
            addRow(propertiesPanel, c, getJLabelMapUnits(), getCmbMapUnits());
231
            addRow(propertiesPanel, c, getJLabelDistanceUnits(), getCmbDistanceUnits());
232
            addRow(propertiesPanel, c, getJLabelAreaUnits(), getCmbDistanceArea());
233

    
234
            // some extra space
235
            addRow(propertiesPanel, c, new JLabel(" "), new JLabel(" "));
236

    
237
            {
238
                GridLayout gl = new GridLayout(1, 2);
239
                JPanel selectionColorPanel = new JPanel(gl);
240
                selectionColorPanel.add(getJLabelSelectionColor());
241
                JPanel secondHalfPanel = new JPanel(new GridBagLayout());
242

    
243
                GridBagConstraints c2 = new GridBagConstraints();
244

    
245
                c2.fill = GridBagConstraints.BOTH;
246
                c2.weightx = 1.0;   //request any extra hor space
247
                c2.gridx = 0;
248
                c2.gridwidth = 1;
249
                c2.gridy = 0;
250
                c2.insets = new Insets(0,1,0,1);
251

    
252
                secondHalfPanel.add(getTxtSelectionColor(), c2);
253

    
254
                c2.fill = GridBagConstraints.NONE;
255
                c2.weightx = 0.0;
256
                c2.gridx = 1;
257
                secondHalfPanel.add(getBtnSelectionColor(), c2);
258

    
259
                selectionColorPanel.add(secondHalfPanel);
260

    
261
                c.gridx = 0;
262
                c.gridwidth = 2;
263
                c.gridy++;
264
                propertiesPanel.add(selectionColorPanel, c);
265
                c.gridwidth = 1;
266
            }
267
            {
268
                GridLayout gl = new GridLayout(1, 2);
269
                JPanel colorPanel = new JPanel(gl);
270
                colorPanel.add(getJLabelColor());
271
                JPanel secondHalfPanel = new JPanel(new GridBagLayout());
272

    
273
                GridBagConstraints c2 = new GridBagConstraints();
274

    
275
                c2.fill = GridBagConstraints.BOTH;
276
                c2.weightx = 1.0;   //request any extra hor space
277
                c2.gridx = 0;
278
                c2.gridwidth = 1;
279
                c2.gridy = 0;
280
                c2.insets = new Insets(0, 1, 0, 1);
281

    
282
                secondHalfPanel.add(getTxtColor(), c2);
283

    
284
                c2.fill = GridBagConstraints.NONE;
285
                c2.weightx = 0.0;
286
                c2.gridx = 1;
287
                secondHalfPanel.add(getBtnColor(), c2);
288

    
289
                colorPanel.add(secondHalfPanel);
290

    
291
                c.gridx = 0;
292
                c.gridwidth = 2;
293
                c.gridy++;
294
                propertiesPanel.add(colorPanel, c);
295
                c.gridwidth = 1;
296
            }
297
            
298
            c.anchor = GridBagConstraints.WEST;
299
            c.weightx = 0.0d;
300
            c.gridx = 0;
301
            c.gridwidth = GridBagConstraints.REMAINDER;
302
            c.gridy++;
303
            c.weightx = 1.0d;
304
            c.fill = GridBagConstraints.HORIZONTAL;
305
            propertiesPanel.add(getJPanelProj(), c);
306

    
307
            // ============ set current as app default CRS
308
            c.anchor = GridBagConstraints.CENTER;
309
            c.gridy++;
310
            JPanel auxp = new JPanel(new BorderLayout());
311
            auxp.add(getSetAsDefaultCrsCheckbox(), BorderLayout.CENTER);
312
            propertiesPanel.add(auxp, c);
313
            // =============================
314

    
315
            // some extra space
316
            addRow(propertiesPanel, c, new JLabel(" "), new JLabel(" "));
317

    
318
            c.anchor = GridBagConstraints.WEST;
319
            c.weightx = 0.0d;
320
            c.gridx = 0;
321
            c.gridy++;
322
            propertiesPanel.add(getJLabelComments(), c);
323

    
324
            c.fill = GridBagConstraints.BOTH;
325
            c.weightx = 1.0d;
326
            c.gridy++;
327
            c.gridwidth = 2;
328
            propertiesPanel.add(getJScrollPaneComments(), c);
329
        }
330
        return propertiesPanel;
331
    }
332

    
333

    
334
    /**
335
     * @return
336
     */
337
    private JCheckBox getSetAsDefaultCrsCheckbox() {
338

    
339
        if (setAsDefCrsChk == null) {
340
            setAsDefCrsChk = new JCheckBox(Messages.getText(
341
                "_Set_this_CRS_as_app_default"));
342
            updateSetAsDefaultCRSChk();
343
        }
344
        return setAsDefCrsChk;
345
    }
346

    
347

    
348
    private String getAppDefaultCRS() {
349
        ProjectPreferences pp = new ProjectPreferences();
350
        IProjection curr_def = pp.getDefaultProjection();
351
        return curr_def.getAbrev();
352
    }
353

    
354
    private void setAppDefaultCRS(String abbrev) {
355
        IProjection proj = CRSFactory.getCRS(abbrev);
356
        ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences();
357
        projectPreferences.setDefaultProjection(proj);
358
    }
359

    
360
    private void updateSetAsDefaultCRSChk() {
361

    
362
        IProjection view_proj = this.getJPanelProj().getCurProj();
363
        String view_abbrev = view_proj.getAbrev();
364

    
365
        String curr_app_crs_def = getAppDefaultCRS();
366
        if (view_abbrev.compareToIgnoreCase(curr_app_crs_def) == 0) {
367
            // same as curr default
368
            this.getSetAsDefaultCrsCheckbox().setSelected(true);
369
            this.getSetAsDefaultCrsCheckbox().setEnabled(false);
370
        } else {
371
            this.getSetAsDefaultCrsCheckbox().setEnabled(true);
372
            this.getSetAsDefaultCrsCheckbox().setSelected(false);
373
        }
374
    }
375

    
376
    private void addRow(JComponent panel, GridBagConstraints c, JComponent label, JComponent text) {
377
        c.anchor = GridBagConstraints.WEST;
378
        c.weightx = 0.0d;
379
        c.gridx = 0;
380
        c.gridy++;
381
        panel.add(label, c);
382

    
383
        c.fill = GridBagConstraints.HORIZONTAL;
384
        c.weightx = 1.0d;
385
        c.gridx = 1;
386
        panel.add(text, c);
387
    }
388

    
389

    
390

    
391
    /**
392
     * This method initializes jLabel
393
     *
394
     * @return javax.swing.JLabel
395
     */
396
    private javax.swing.JLabel getJLabelName() {
397
        if (jLabelName == null) {
398
            jLabelName =
399
                new javax.swing.JLabel(Messages.getText("nombre") + ":");
400
        }
401

    
402
        return jLabelName;
403
    }
404

    
405
    /**
406
     * This method initializes txtName
407
     *
408
     * @return javax.swing.JTextField
409
     */
410
    private javax.swing.JTextField getTxtName() {
411
        if (txtName == null) {
412
            txtName = new javax.swing.JTextField(view.getName());
413
        }
414

    
415
        return txtName;
416
    }
417

    
418
    /**
419
     * This method initializes jLabel1
420
     *
421
     * @return javax.swing.JLabel
422
     */
423
    private javax.swing.JLabel getJLabelDate() {
424
        if (jLabelDate == null) {
425
            jLabelDate =
426
                new javax.swing.JLabel(Messages.getText("creation_date") + ":");
427
        }
428

    
429
        return jLabelDate;
430
    }
431

    
432
    /**
433
     * This method initializes txtDate
434
     *
435
     * @return javax.swing.JTextField
436
     */
437
    private javax.swing.JTextField getTxtDate() {
438
        if (txtDate == null) {
439
            txtDate = new javax.swing.JTextField(view.getCreationDate());
440
            txtDate.setEditable(false);
441
            txtDate.setBackground(java.awt.Color.white);
442
        }
443

    
444
        return txtDate;
445
    }
446

    
447
    /**
448
     * This method initializes jLabel2
449
     *
450
     * @return javax.swing.JLabel
451
     */
452
    private javax.swing.JLabel getJLabelOwner() {
453
        if (jLabelOwner == null) {
454
            jLabelOwner =
455
                new javax.swing.JLabel(Messages.getText("owner") + ":");
456
        }
457

    
458
        return jLabelOwner;
459
    }
460

    
461
    /**
462
     * This method initializes txtOwner
463
     *
464
     * @return javax.swing.JTextField
465
     */
466
    private javax.swing.JTextField getTxtOwner() {
467
        if (txtOwner == null) {
468
            txtOwner = new javax.swing.JTextField(view.getOwner());
469
        }
470

    
471
        return txtOwner;
472
    }
473

    
474
    /**
475
     * This method initializes jLabel4
476
     *
477
     * @return javax.swing.JLabel
478
     */
479
    private javax.swing.JLabel getJLabelMapUnits() {
480
        if (jLabelMapUnits == null) {
481
            jLabelMapUnits =
482
                new javax.swing.JLabel(Messages.getText("map_units") + ":");
483
        }
484

    
485
        return jLabelMapUnits;
486
    }
487

    
488
    /**
489
     * This method initializes cmbMapUnits
490
     *
491
     * @return javax.swing.JComboBox
492
     */
493
    private javax.swing.JComboBox getCmbMapUnits() {
494
        if (cmbMapUnits == null
495
            || MapContext.getDistanceNames().length > cmbMapUnits
496
                .getItemCount()) {
497
            cmbMapUnits = new JComboBoxUnits(false);
498

    
499
            IProjection proj = view.getProjection();
500
            if (!proj.isProjected()) {
501
                cmbMapUnits.setSelectedItem(Messages.getText("Grados")); // deegree
502
                cmbMapUnits.setEnabled(false);
503
            } else {
504
                if (!(cmbMapUnits.getItemCount() == MapContext
505
                    .getDistanceNames().length)) {
506
                    cmbMapUnits.removeItem(Messages.getText("Grados")); // deegree
507
                    view.getMapContext().getViewPort().setMapUnits(1);
508
                }
509
                cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort()
510
                    .getMapUnits());
511
                cmbMapUnits.setEnabled(true);
512
            }
513
        }
514

    
515
        return cmbMapUnits;
516
    }
517

    
518
    /**
519
     * This method initializes jLabel5
520
     *
521
     * @return javax.swing.JLabel
522
     */
523
    private javax.swing.JLabel getJLabelDistanceUnits() {
524
        if (jLabelDistanceUnits == null) {
525
            jLabelDistanceUnits =
526
                new javax.swing.JLabel(Messages.getText("distance_units") + ":");
527
        }
528

    
529
        return jLabelDistanceUnits;
530
    }
531

    
532
    /**
533
     * This method initializes jLabel6
534
     *
535
     * @return javax.swing.JLabel
536
     */
537
    private javax.swing.JLabel getJLabelAreaUnits() {
538
        if (jLabelAreaUnits == null) {
539
            jLabelAreaUnits =
540
                new javax.swing.JLabel(Messages.getText("unidades_area") + ":");
541
        }
542

    
543
        return jLabelAreaUnits;
544
    }
545

    
546
    /**
547
     * This method initializes cmbDistanceUnits
548
     *
549
     * @return javax.swing.JComboBox
550
     */
551
    private javax.swing.JComboBox getCmbDistanceUnits() {
552
        if (cmbDistanceUnits == null
553
            || MapContext.getDistanceNames().length > cmbDistanceUnits
554
                .getItemCount()) {
555
            cmbDistanceUnits = new JComboBoxUnits(false);
556
            cmbDistanceUnits.setSelectedIndex(view.getMapContext()
557
                .getViewPort().getDistanceUnits());
558
        }
559

    
560
        return cmbDistanceUnits;
561
    }
562

    
563
    /**
564
     * This method initializes jLabel6
565
     *
566
     * @return javax.swing.JLabel
567
     */
568
    private javax.swing.JLabel getJLabelComments() {
569
        if (jLabelComments == null) {
570
            jLabelComments =
571
                new javax.swing.JLabel(Messages.getText("comentarios") + ":");
572
            jLabelComments
573
                .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
574
            jLabelComments
575
                .setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
576
        }
577

    
578
        return jLabelComments;
579
    }
580

    
581
    /**
582
     * This method initializes txtComments
583
     *
584
     * @return javax.swing.JTextArea
585
     */
586
    private javax.swing.JTextArea getTxtComments() {
587
        if (txtComments == null) {
588
            txtComments = new javax.swing.JTextArea(view.getComment());
589
            txtComments.setRows(3);
590
            txtComments.setColumns(20);
591
        }
592

    
593
        return txtComments;
594
    }
595

    
596
    /**
597
     * This method initializes jLabel7
598
     *
599
     * @return javax.swing.JLabel
600
     */
601
    private javax.swing.JLabel getJLabelColor() {
602
        if (jLabelColor == null) {
603
            jLabelColor =
604
                new javax.swing.JLabel(Messages.getText("background_color")
605
                    + ":");
606
        }
607

    
608
        return jLabelColor;
609
    }
610

    
611
    /**
612
     * This method initializes jLabel7
613
     *
614
     * @return javax.swing.JLabel
615
     */
616
    private javax.swing.JLabel getJLabelSelectionColor() {
617
        if (jLabelSelectionColor == null) {
618
            jLabelSelectionColor =
619
                new javax.swing.JLabel(Messages.getText("_Selection_color")
620
                    + ":");
621
        }
622

    
623
        return jLabelSelectionColor;
624
    }
625

    
626
    /**
627
     * This method initializes lblColor
628
     *
629
     * @return javax.swing.JLabel
630
     */
631
    private javax.swing.JTextField getTxtColor() {
632
        if (txtColor == null) {
633
            txtColor = new javax.swing.JTextField();
634
//            txtColor.setPreferredSize(new java.awt.Dimension(42, 21));
635
        }
636

    
637
        return txtColor;
638
    }
639

    
640
    /**
641
     * This method initializes lblSelectionColor
642
     *
643
     * @return javax.swing.JLabel
644
     */
645
    private javax.swing.JTextField getTxtSelectionColor() {
646
        if (txtSelectionColor == null) {
647
            txtSelectionColor = new javax.swing.JTextField();
648
//            txtSelectionColor.setPreferredSize(new java.awt.Dimension(42, 21));
649
        }
650

    
651
        return txtSelectionColor;
652
    }
653

    
654
    /**
655
     * This method initializes btnColor
656
     *
657
     * @return javax.swing.JButton
658
     */
659
    private JButton getBtnColor() {
660
        if (btnColor == null) {
661
            btnColor = new JButton();
662
            // ToolsSwingLocator.getUsabilitySwingManager().createJButton();
663

    
664
            btnColor.setText("...");
665
        }
666
        return btnColor;
667
    }
668

    
669
    /**
670
     * This method initializes btnSelectionColor
671
     *
672
     * @return javax.swing.JButton
673
     */
674
    private JButton getBtnSelectionColor() {
675
        if (btnSelectionColor == null) {
676
            btnSelectionColor = new JButton();
677
            // ToolsSwingLocator.getUsabilitySwingManager().createJButton();
678

    
679
            btnSelectionColor.setText("...");
680
        }
681
        return btnSelectionColor;
682
    }
683

    
684
    /**
685
     * This method initializes jScrollPane
686
     *
687
     * @return javax.swing.JScrollPane
688
     */
689
    private javax.swing.JScrollPane getJScrollPaneComments() {
690
        if (jScrollPane == null) {
691
            jScrollPane = new javax.swing.JScrollPane();
692
            jScrollPane.setViewportView(getTxtComments());
693
            Dimension dim = getTxtComments().getPreferredSize();
694
            jScrollPane
695
                .setMinimumSize(new Dimension(dim.width, dim.height + 10));
696
        }
697

    
698
        return jScrollPane;
699
    }
700

    
701
    /**
702
     * This method initializes jPanel4
703
     *
704
     * @return javax.swing.JPanel
705
     */
706
    private CRSSelectPanel getJPanelProj() {
707
        if (jPanelProj == null) {
708
            IProjection proj = view.getProjection();
709
            jPanelProj = CRSSelectPanel.getPanel(proj);
710
            jPanelProj.addActionListener(new java.awt.event.ActionListener() {
711

    
712
                @Override
713
                public void actionPerformed(java.awt.event.ActionEvent e) {
714
                    if (jPanelProj.isOkPressed()) {
715
                            int numberOfLayers = view.getMapContext().getLayers().getLayersCount();
716
                            if(numberOfLayers > 0) {
717
                                    warningViewProjectionChange();
718
                            }
719

    
720
                        if (!jPanelProj.getCurProj().isProjected()) {
721
                            getCmbMapUnits().setSelectedItem(
722
                                PluginServices
723
                                    .getText(this, "Grados"));
724
                            getCmbMapUnits().setEnabled(false);
725
                        } else {
726
                            if (getCmbMapUnits().getSelectedItem().equals(
727
                                PluginServices
728
                                    .getText(this, "Grados"))) {
729
                                getCmbMapUnits().setSelectedIndex(1);
730
                            }
731
                            getCmbMapUnits().setEnabled(true);
732
                        }
733
                        updateSetAsDefaultCRSChk();
734
                    }
735
                }
736
            });
737
        }
738
        return jPanelProj;
739
    }
740

    
741
    private void warningViewProjectionChange() {
742
            JOptionPane.showMessageDialog(
743
                            (Component)PluginServices.getMainFrame(),
744
                            Messages.getText("view_contain_layers"));
745
    }
746

    
747
    /**
748
     * @return ViewDocument
749
     * @see org.gvsig.andami.ui.mdiManager.SingletonWindow#getWindowModel()
750
     */
751
    public Object getWindowModel() {
752
        return view;
753
    }
754

    
755

    
756
    /**
757
     * @return boolean
758
     */
759
    public boolean isAcceppted() {
760
        return isAcceppted;
761
    }
762

    
763
    /**
764
     * This method initializes jComboBox
765
     *
766
     * @return javax.swing.JComboBox
767
     */
768
    private JComboBox getCmbDistanceArea() {
769
        String[] names = MapContext.getAreaNames();
770
        if (cmbDistanceArea == null
771
            || names.length > cmbDistanceArea.getItemCount()) {
772
            for (int i = 0; i < names.length; i++) {
773
                names[i] =
774
                    Messages.getText(names[i]) + MapContext.getOfLinear(i);
775
            }
776
            cmbDistanceArea = new javax.swing.JComboBox(names);
777
            cmbDistanceArea.setEditable(false);
778
            cmbDistanceArea.setSelectedIndex(view.getMapContext().getViewPort()
779
                .getDistanceArea());
780
//            cmbDistanceArea
781
//                .addActionListener(new java.awt.event.ActionListener() {
782
//
783
//                    @Override
784
//                    public void actionPerformed(java.awt.event.ActionEvent e) {
785
//                        // view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
786
//                    }
787
//                });
788
        }
789

    
790
        return cmbDistanceArea;
791

    
792
    }
793

    
794

    
795

    
796

    
797
}