root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / gui / preferencespage / LayoutPage.java @ 31496
History | View | Annotate | Download (8.03 KB)
1 | 14821 | jmvivo | /* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|---|---|
2 | 7805 | jaume | *
|
3 | * Copyright (C) 2005 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 | 14821 | jmvivo | * Av. Blasco Ib��ez, 50
|
24 | 7805 | jaume | * 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 | |||
42 | /* CVS MESSAGES:
|
||
43 | *
|
||
44 | * $Id$
|
||
45 | * $Log$
|
||
46 | 9392 | caballero | * Revision 1.7 2006-12-20 14:41:12 caballero
|
47 | * Remodelado Layout
|
||
48 | *
|
||
49 | * Revision 1.6 2006/11/08 10:57:55 jaume
|
||
50 | 8590 | jaume | * remove unecessary imports
|
51 | *
|
||
52 | * Revision 1.5 2006/10/18 07:57:47 jaume
|
||
53 | 7869 | jaume | * *** empty log message ***
|
54 | *
|
||
55 | 8142 | jaume | * Revision 1.4 2006/10/04 09:06:35 jaume
|
56 | * *** empty log message ***
|
||
57 | *
|
||
58 | 7869 | jaume | * Revision 1.3 2006/10/04 07:23:53 jaume
|
59 | 7855 | jaume | * refactored ambiguous methods and field names and added some more features for preference pages
|
60 | *
|
||
61 | * Revision 1.2 2006/10/03 11:12:41 jaume
|
||
62 | 7811 | jaume | * initialize values
|
63 | *
|
||
64 | * Revision 1.1 2006/10/03 10:33:34 jaume
|
||
65 | 7805 | jaume | * *** empty log message ***
|
66 | *
|
||
67 | *
|
||
68 | */
|
||
69 | 29596 | jpiera | package org.gvsig.app.gui.preferencespage; |
70 | 7805 | jaume | |
71 | import javax.swing.ImageIcon; |
||
72 | import javax.swing.JCheckBox; |
||
73 | import javax.swing.JPanel; |
||
74 | import javax.swing.JTextField; |
||
75 | |||
76 | 29596 | jpiera | import org.gvsig.andami.PluginServices; |
77 | import org.gvsig.andami.preferences.AbstractPreferencePage; |
||
78 | import org.gvsig.andami.preferences.StoreException; |
||
79 | import org.gvsig.app.project.documents.layout.Attributes; |
||
80 | 31496 | jjdelcerro | import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
81 | 29596 | jpiera | import org.gvsig.utils.XMLEntity; |
82 | |||
83 | 7869 | jaume | /**
|
84 | * Layout preference page where the user can establish default values for
|
||
85 | * <ol>
|
||
86 | * <li><b>grid horizontal gap</b></li>
|
||
87 | * <li><b>grid vertical gap</b></li>
|
||
88 | * <li><b>show or hide grid</b></li>
|
||
89 | * <li><b>adjust elements to grid</b></li>
|
||
90 | * <li><b>show or hide rules</b></li>
|
||
91 | * </ol>
|
||
92 | * @author jaume dominguez faus - jaume.dominguez@iver.es
|
||
93 | *
|
||
94 | */
|
||
95 | 7805 | jaume | public class LayoutPage extends AbstractPreferencePage{ |
96 | |||
97 | 7855 | jaume | private static final boolean FACTORY_DEFAULT_LAYOUT_ENABLE_RULES = true; |
98 | private static final boolean FACTORY_DEFAULT_LAYOUT_GRID_SHOW = true; |
||
99 | 9392 | caballero | private static final double FACTORY_DEFAULT_VERTICAL_GAP = 1; |
100 | private static final double FACTORY_DEFAULT_HORIZONTAL_GAP = 1; |
||
101 | 7811 | jaume | private static final boolean FACTORY_DEFAULT_LAYOUT_GRID_ENABLE = false; |
102 | 7855 | jaume | private static final String DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME = "DefaultShowLayoutGrid"; |
103 | private static final String DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME = "DefaultEnableLayoutGrid"; |
||
104 | private static final String DEFAULT_SHOW_LAYOUT_RULES_KEY_NAME = "DefaultShowLayoutRules"; |
||
105 | private static final String DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME = "DefaultGridVerticalGap"; |
||
106 | private static final String DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME = "DefaultGridHorizontalGap"; |
||
107 | 8142 | jaume | static String id = LayoutPage.class.getName();; |
108 | 7805 | jaume | private ImageIcon icon; |
109 | private JCheckBox chkGridEnabled; |
||
110 | 7855 | jaume | private JCheckBox chkShowRules; |
111 | 7805 | jaume | private JCheckBox chkShowGrid; |
112 | private JTextField txtVGap; |
||
113 | private JTextField txtHGap; |
||
114 | |||
115 | 7869 | jaume | /**
|
116 | * Builds preference page where the user can establish default values for
|
||
117 | * <ol>
|
||
118 | * <li><b>grid horizontal gap</b></li>
|
||
119 | * <li><b>grid vertical gap</b></li>
|
||
120 | * <li><b>show or hide grid</b></li>
|
||
121 | * <li><b>adjust elements to grid</b></li>
|
||
122 | * <li><b>show or hide rules</b></li>
|
||
123 | * </ol>
|
||
124 | */
|
||
125 | 7805 | jaume | public LayoutPage() {
|
126 | super();
|
||
127 | 8142 | jaume | |
128 | 14821 | jmvivo | icon = PluginServices.getIconTheme().get("mapa-icono");
|
129 | 23757 | vcaballero | |
130 | 7811 | jaume | // horizontal gap text field
|
131 | 7805 | jaume | addComponent(PluginServices.getText(this, "espaciado_horizontal"), txtHGap = new JTextField(5)); |
132 | 7855 | jaume | |
133 | 7811 | jaume | // vertical gap text field
|
134 | 7805 | jaume | addComponent(PluginServices.getText(this, "espaciado_vertical"), txtVGap = new JTextField(5)); |
135 | 7855 | jaume | |
136 | 7811 | jaume | // show/hide show check
|
137 | 7805 | jaume | addComponent(chkShowGrid = new JCheckBox(PluginServices.getText(this, "visualizar_cuadricula"))); |
138 | 7855 | jaume | |
139 | 7811 | jaume | // enable/disable grid
|
140 | 7805 | jaume | addComponent(chkGridEnabled = new JCheckBox(PluginServices.getText(this, "malla_activada"))); |
141 | |||
142 | 7855 | jaume | // show/hide rules
|
143 | addComponent(chkShowRules = new JCheckBox(PluginServices.getText(this, "activar_regla"))); |
||
144 | |||
145 | 8142 | jaume | |
146 | 7805 | jaume | } |
147 | 7855 | jaume | |
148 | 7805 | jaume | public void storeValues() throws StoreException { |
149 | 7855 | jaume | double hGap, vGap;
|
150 | boolean gridEnabled, showRules, showGrid;
|
||
151 | try {
|
||
152 | hGap = Double.parseDouble(txtHGap.getText());
|
||
153 | vGap = Double.parseDouble(txtVGap.getText());
|
||
154 | gridEnabled = chkGridEnabled.isSelected(); |
||
155 | showGrid = chkShowGrid.isSelected(); |
||
156 | showRules = chkShowRules.isSelected(); |
||
157 | } catch (Exception e) { |
||
158 | throw new StoreException(PluginServices.getText(this, "invalid_value_for_gap")); |
||
159 | } |
||
160 | 31496 | jjdelcerro | LayoutPanel.setDefaultShowGrid(showGrid); |
161 | LayoutPanel.setDefaultAdjustToGrid(gridEnabled); |
||
162 | LayoutPanel.setDefaultShowRulers(showRules); |
||
163 | 7869 | jaume | Attributes.setDefaultGridGap(hGap, vGap);
|
164 | 7855 | jaume | PluginServices ps = PluginServices.getPluginServices(this);
|
165 | XMLEntity xml = ps.getPersistentXML(); |
||
166 | xml.putProperty(DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME, hGap); |
||
167 | xml.putProperty(DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME, vGap); |
||
168 | xml.putProperty(DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME, showGrid); |
||
169 | xml.putProperty(DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME, gridEnabled); |
||
170 | xml.putProperty(DEFAULT_SHOW_LAYOUT_RULES_KEY_NAME, showRules); |
||
171 | 7805 | jaume | } |
172 | |||
173 | public String getID() { |
||
174 | return id;
|
||
175 | } |
||
176 | |||
177 | public String getTitle() { |
||
178 | return PluginServices.getText(this, "Mapa"); |
||
179 | } |
||
180 | |||
181 | public JPanel getPanel() { |
||
182 | return this; |
||
183 | } |
||
184 | |||
185 | public void initializeValues() { |
||
186 | 7811 | jaume | PluginServices ps = PluginServices.getPluginServices(this);
|
187 | XMLEntity xml = ps.getPersistentXML(); |
||
188 | 23757 | vcaballero | double hGap=FACTORY_DEFAULT_HORIZONTAL_GAP;
|
189 | double vGap=FACTORY_DEFAULT_VERTICAL_GAP;
|
||
190 | boolean showGrid=FACTORY_DEFAULT_LAYOUT_GRID_SHOW;
|
||
191 | boolean gridEnabled=FACTORY_DEFAULT_LAYOUT_GRID_ENABLE;
|
||
192 | boolean showRules=FACTORY_DEFAULT_LAYOUT_ENABLE_RULES;
|
||
193 | 7811 | jaume | // horizontal gap
|
194 | if (xml.contains(DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME)) {
|
||
195 | 23757 | vcaballero | hGap=xml.getDoubleProperty(DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME); |
196 | 7811 | jaume | } |
197 | 23757 | vcaballero | txtHGap.setText(String.valueOf(hGap));
|
198 | 7811 | jaume | |
199 | // vertical gap
|
||
200 | if (xml.contains(DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME)) {
|
||
201 | 23757 | vcaballero | vGap=xml.getDoubleProperty(DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME); |
202 | 7811 | jaume | } |
203 | 23757 | vcaballero | txtVGap.setText(String.valueOf(vGap));
|
204 | 7855 | jaume | |
205 | 7811 | jaume | // show/hide grid check
|
206 | 7855 | jaume | if (xml.contains(DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME)) {
|
207 | 23757 | vcaballero | showGrid=xml.getBooleanProperty(DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME); |
208 | 7811 | jaume | } |
209 | 23757 | vcaballero | chkShowGrid.setSelected(showGrid); |
210 | 7855 | jaume | |
211 | 7811 | jaume | // enable/disable grid check
|
212 | 7855 | jaume | if (xml.contains(DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME)) {
|
213 | 23757 | vcaballero | gridEnabled=xml.getBooleanProperty(DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME); |
214 | 7811 | jaume | } |
215 | 23757 | vcaballero | chkGridEnabled.setSelected(gridEnabled); |
216 | 7811 | jaume | |
217 | // enable/disable rules
|
||
218 | 7855 | jaume | if (xml.contains(DEFAULT_SHOW_LAYOUT_RULES_KEY_NAME)) {
|
219 | 23757 | vcaballero | showRules=xml.getBooleanProperty(DEFAULT_SHOW_LAYOUT_RULES_KEY_NAME); |
220 | 7811 | jaume | } |
221 | 23757 | vcaballero | chkShowRules.setSelected(showRules); |
222 | 7811 | jaume | |
223 | 31496 | jjdelcerro | LayoutPanel.setDefaultShowGrid(showGrid); |
224 | LayoutPanel.setDefaultAdjustToGrid(gridEnabled); |
||
225 | LayoutPanel.setDefaultShowRulers(showRules); |
||
226 | 23757 | vcaballero | Attributes.setDefaultGridGap(hGap, vGap);
|
227 | 7805 | jaume | } |
228 | |||
229 | public void initializeDefaults() { |
||
230 | 7855 | jaume | txtHGap.setText(String.valueOf(FACTORY_DEFAULT_HORIZONTAL_GAP));
|
231 | txtVGap.setText(String.valueOf(FACTORY_DEFAULT_VERTICAL_GAP));
|
||
232 | chkShowGrid.setSelected(FACTORY_DEFAULT_LAYOUT_GRID_SHOW); |
||
233 | chkGridEnabled.setSelected(FACTORY_DEFAULT_LAYOUT_GRID_ENABLE); |
||
234 | chkShowRules.setSelected(FACTORY_DEFAULT_LAYOUT_ENABLE_RULES); |
||
235 | 7805 | jaume | } |
236 | |||
237 | public ImageIcon getIcon() { |
||
238 | return icon;
|
||
239 | } |
||
240 | |||
241 | public boolean isValueChanged() { |
||
242 | return super.hasChanged(); |
||
243 | } |
||
244 | |||
245 | public void setChangesApplied() { |
||
246 | setChanged(false);
|
||
247 | } |
||
248 | } |