Revision 38875 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/gui/ViewProperties.java

View differences:

ViewProperties.java
21 21
 */
22 22
package org.gvsig.app.project.documents.view.gui;
23 23

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

  
35 37
import javax.swing.BorderFactory;
36 38
import javax.swing.JButton;
39
import javax.swing.JCheckBox;
37 40
import javax.swing.JColorChooser;
38 41
import javax.swing.JComboBox;
39 42
import javax.swing.JComponent;
......
48 51
import org.gvsig.andami.ui.mdiManager.WindowInfo;
49 52
import org.gvsig.app.gui.JComboBoxUnits;
50 53
import org.gvsig.app.gui.panels.CRSSelectPanel;
54
import org.gvsig.app.gui.preferencespage.ViewPage;
51 55
import org.gvsig.app.project.Project;
52 56
import org.gvsig.app.project.ProjectManager;
57
import org.gvsig.app.project.ProjectPreferences;
53 58
import org.gvsig.app.project.documents.Document;
54 59
import org.gvsig.app.project.documents.view.DefaultViewDocument;
55 60
import org.gvsig.app.project.documents.view.ViewManager;
56 61
import org.gvsig.fmap.mapcontext.MapContext;
57 62
import org.gvsig.gui.beans.AcceptCancelPanel;
58 63
import org.gvsig.i18n.Messages;
64
import org.gvsig.utils.XMLEntity;
59 65

  
60 66
/**
61 67
 * Dialogo donde se muestran las propiedades de una vista
......
84 90
    private javax.swing.JLabel jLabelColor = null;
85 91
    private javax.swing.JLabel jLabelComments = null;
86 92
    private javax.swing.JLabel lblColor = null;
93
    
94
    private JCheckBox setAsDefCrsChk = null;
95
    private ViewProperties self = null;
87 96

  
88 97
    private Color backColor = null;
89 98

  
......
106 115
    public ViewProperties(DefaultViewDocument v) {
107 116
        view = v;
108 117
        initialize();
118
        self = this;
109 119
    }
110 120

  
111 121
    /**
......
133 143
        JPanel colorPanel = new JPanel(gl);
134 144
        colorPanel.add(getJLabelColor());
135 145
        JPanel secondHalfPanel = new JPanel(gl);
146
        
136 147
        secondHalfPanel.add(getLblColor(secondHalfPanel.getBackground()));
148
        
137 149
        secondHalfPanel.add(getBtnColor());
138 150
        colorPanel.add(secondHalfPanel);
139 151
        
......
143 155
        add(colorPanel, c);
144 156
        c.gridwidth = 1;
145 157

  
146
        /*
147 158
        c.anchor = GridBagConstraints.WEST;
148 159
        c.weightx = 0.0d;
149 160
        c.gridx = 0;
150
        c.gridy++;
151
        add(getJLabelColor(), c);
152

  
153
        c.fill = GridBagConstraints.HORIZONTAL;
154
        c.weightx = 1.0d;
155
        c.gridx = 1;
156
        add(getJPanelColor(), c);
157
        */
158

  
159
        c.anchor = GridBagConstraints.WEST;
160
        c.weightx = 0.0d;
161
        c.gridx = 0;
162 161
        c.gridwidth = GridBagConstraints.REMAINDER;
163 162
        c.gridy++;
164 163
        c.weightx = 1.0d;
165 164
        c.fill = GridBagConstraints.HORIZONTAL;
166 165
        add(getJPanelProj(), c);
166
        
167
        // ============ set current as app default CRS
168
        c.anchor = GridBagConstraints.CENTER;
169
        c.gridy++;
170
        JPanel auxp = new JPanel(new BorderLayout());
171
        auxp.add(getSetAsDefaultCrsCheckbox(), BorderLayout.CENTER);
172
        add(auxp, c);
173
        // =============================
174
        
175
        // some extra space
176
        addRow(c, new JLabel(" "), new JLabel(" "));
167 177

  
168 178
        c.anchor = GridBagConstraints.WEST;
169 179
        c.weightx = 0.0d;
......
189 199

  
190 200

  
191 201

  
202
    /**
203
     * @return
204
     */
205
    private JCheckBox getSetAsDefaultCrsCheckbox() {
206
        
207
        if (setAsDefCrsChk == null) {
208
            setAsDefCrsChk = new JCheckBox(Messages.getText(
209
                "_Set_this_CRS_as_app_default"));
210
           
211
            setAsDefCrsChk.addMouseListener(new MouseListener() {
212
                public void mouseReleased(MouseEvent e) { }
213
                public void mousePressed(MouseEvent e) { }
214
                public void mouseExited(MouseEvent e) { }
215
                public void mouseEntered(MouseEvent e) { }
216
                public void mouseClicked(MouseEvent e) {
217
                    JCheckBox src = (JCheckBox) e.getSource();
218
                    if (src.isSelected()) {
219
                        IProjection view_proj = self.view.getProjection();
220
                        String view_abbrev = view_proj.getAbrev();
221
                        self.setAppDefaultCRS(view_abbrev);
222
                        updateSetAsDefaultCRSChk();
223
                    }                        
224
                }
225
            });
226
            updateSetAsDefaultCRSChk();
227
        }
228
        return setAsDefCrsChk;
229
    }
230
    
231

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

  
192 260
    private void addRow(GridBagConstraints c, JComponent label, JComponent text) {
193 261
        c.anchor = GridBagConstraints.WEST;
194 262
        c.weightx = 0.0d;
......
434 502
    private javax.swing.JLabel getLblColor(Color surround_color) {
435 503
        if (lblColor == null) {
436 504
            lblColor = new javax.swing.JLabel("");
437
            // lblColor.setPreferredSize(new java.awt.Dimension(30, 16));
505
            // lblColor.setMaximumSize(new java.awt.Dimension(30, 20));
438 506
            Color theColor = view.getMapContext().getViewPort().getBackColor();
439 507
            backColor = theColor;
440 508
            if (theColor == null) {
......
539 607
                            getCmbMapUnits().setEnabled(true);
540 608
                        }
541 609
                        view.setProjection(jPanelProj.getCurProj());
610
                        self.updateSetAsDefaultCRSChk();
542 611
                    }
543 612
                }
544 613
            });
......
667 736
    public Object getWindowProfile() {
668 737
        return WindowInfo.PROPERTIES_PROFILE;
669 738
    }
739
    
670 740

  
741

  
742

  
671 743
}

Also available in: Unified diff