Revision 47790 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

View differences:

GeneralViewPropertiesPage.java
11 11
import java.awt.GridLayout;
12 12
import java.awt.Insets;
13 13
import java.util.List;
14

  
15 14
import javax.swing.BorderFactory;
16 15
import javax.swing.JButton;
17 16
import javax.swing.JCheckBox;
18
import javax.swing.JColorChooser;
19 17
import javax.swing.JComboBox;
20 18
import javax.swing.JComponent;
21 19
import javax.swing.JLabel;
22 20
import javax.swing.JOptionPane;
23 21
import javax.swing.JPanel;
24

  
25 22
import org.cresques.cts.IProjection;
26

  
27 23
import org.gvsig.andami.PluginServices;
28 24
import org.gvsig.app.ApplicationLocator;
29 25
import org.gvsig.app.gui.JComboBoxUnits;
......
40 36
import org.gvsig.propertypage.PropertiesPage;
41 37
import org.gvsig.tools.ToolsLocator;
42 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;
43 42

  
44 43
/**
45 44
 * @author gvSIG team
......
67 66
    private javax.swing.JLabel jLabelAreaUnits = null;
68 67
    private javax.swing.JTextArea txtComments = null;
69 68
    private javax.swing.JLabel jLabelColor = null;
69
    private javax.swing.JLabel jLabelSelectionColor = null;
70 70
    private javax.swing.JLabel jLabelComments = null;
71
    private javax.swing.JPanel lblColor = null;
71
    private javax.swing.JTextField txtColor = null;
72
    private javax.swing.JTextField txtSelectionColor = null;
72 73

  
73 74
    private JCheckBox setAsDefCrsChk = null;
74 75

  
75 76
    private Color backColor = null;
76 77

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

  
84 88
    /**
85 89
     * @param view
......
136 140
            view.getMapContext().getViewPort()
137 141
                .setDistanceArea(cmbDistanceArea.getSelectedIndex());
138 142
            view.setBackColor(backColor);
143
            view.getMapContext().setSelectionColor(txtSelectionColor.getBackground());
139 144

  
140 145
            // Select the projection
141 146
            if (jPanelProj.isOkPressed()) {
......
186 191
    }
187 192

  
188 193
    private void initComponents() {
194
        
195
        ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
189 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

  
190 214
    }
191 215

  
192 216
    private Component getCenterPanel() {
......
210 234
            // some extra space
211 235
            addRow(propertiesPanel, c, new JLabel(" "), new JLabel(" "));
212 236

  
213
            GridLayout gl = new GridLayout(1,2);
214
            JPanel colorPanel = new JPanel(gl);
215
            colorPanel.add(getJLabelColor());
216
            JPanel secondHalfPanel = new JPanel(new GridBagLayout());
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());
217 242

  
218
            GridBagConstraints c2 = new GridBagConstraints();
243
                GridBagConstraints c2 = new GridBagConstraints();
219 244

  
220
            c2.fill = GridBagConstraints.BOTH;
221
            c2.weightx = 1.0;   //request any extra hor space
222
            c2.gridx = 0;
223
            c2.gridwidth = 1;
224
            c2.gridy = 0;
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);
225 251

  
226
            JPanel auxPanel = new JPanel(new GridLayout(1,2));
227
            auxPanel.add(getLblColor(secondHalfPanel.getBackground()));
228
            auxPanel.add(new JLabel(""));
229
            secondHalfPanel.add(auxPanel, c2);
252
                secondHalfPanel.add(getTxtSelectionColor(), c2);
230 253

  
231
            c2.fill = GridBagConstraints.NONE;
232
            c2.weightx = 0.0;
233
            c2.gridx = 1;
234
            secondHalfPanel.add(getBtnColor(), c2);
254
                c2.fill = GridBagConstraints.NONE;
255
                c2.weightx = 0.0;
256
                c2.gridx = 1;
257
                secondHalfPanel.add(getBtnSelectionColor(), c2);
235 258

  
236
            colorPanel.add(secondHalfPanel);
259
                selectionColorPanel.add(secondHalfPanel);
237 260

  
238
            c.gridx = 0;
239
            c.gridwidth = 2;
240
            c.gridy++;
241
            propertiesPanel.add(colorPanel, c);
242
            c.gridwidth = 1;
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());
243 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
            
244 298
            c.anchor = GridBagConstraints.WEST;
245 299
            c.weightx = 0.0d;
246 300
            c.gridx = 0;
......
555 609
    }
556 610

  
557 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
    /**
558 627
     * This method initializes lblColor
559 628
     *
560 629
     * @return javax.swing.JLabel
561 630
     */
562
    private javax.swing.JPanel getLblColor(Color surround_color) {
563
        if (lblColor == null) {
564
            lblColor = new javax.swing.JPanel();
565
            lblColor.setPreferredSize(new java.awt.Dimension(42, 21));
566
            Color theColor = view.getMapContext().getViewPort().getBackColor();
567
            backColor = theColor;
568
            if (theColor == null) {
569
                theColor = Color.WHITE;
570
            }
571
            lblColor.setBackground(theColor);
572
            // lblColor.setBorder(BorderFactory.createLineBorder(surround_color, 3));
573
            lblColor.setOpaque(true);
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));
574 635
        }
575 636

  
576
        return lblColor;
637
        return txtColor;
577 638
    }
578 639

  
579 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
    /**
580 655
     * This method initializes btnColor
581 656
     *
582 657
     * @return javax.swing.JButton
......
587 662
            // ToolsSwingLocator.getUsabilitySwingManager().createJButton();
588 663

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

  
591
            btnColor.addActionListener(new java.awt.event.ActionListener() {
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();
592 678

  
593
                @Override
594
                public void actionPerformed(java.awt.event.ActionEvent e) {
595
                    Color ret =
596
                        JColorChooser.showDialog(GeneralViewPropertiesPage.this,
597
                            Messages.getText("background_color"),
598
                            lblColor.getBackground());
599

  
600
                    if (ret != null) {
601
                        lblColor.setBackground(ret);
602
                        backColor = ret;
603
                    } else {
604
                        lblColor.setBackground(Color.WHITE);
605
                    }
606
                }
607
            });
679
            btnSelectionColor.setText("...");
608 680
        }
609

  
610
        return btnColor;
681
        return btnSelectionColor;
611 682
    }
612 683

  
613 684
    /**
......
706 777
            cmbDistanceArea.setEditable(false);
707 778
            cmbDistanceArea.setSelectedIndex(view.getMapContext().getViewPort()
708 779
                .getDistanceArea());
709
            cmbDistanceArea
710
                .addActionListener(new java.awt.event.ActionListener() {
711

  
712
                    @Override
713
                    public void actionPerformed(java.awt.event.ActionEvent e) {
714
                        // view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
715
                    }
716
                });
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
//                });
717 788
        }
718 789

  
719 790
        return cmbDistanceArea;

Also available in: Unified diff