Revision 7251 branches/v10/libraries/libCorePlugin/src/com/iver/core/preferences/general/FolderingPage.java
FolderingPage.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1.2.1 2006-09-08 11:56:24 jaume
|
|
46 |
* Revision 1.1.2.2 2006-09-13 16:24:14 jaume
|
|
47 | 47 |
* *** empty log message *** |
48 | 48 |
* |
49 |
* Revision 1.1.2.1 2006/09/08 11:56:24 jaume |
|
50 |
* *** empty log message *** |
|
49 | 51 |
* |
52 |
* |
|
50 | 53 |
*/ |
51 | 54 |
package com.iver.core.preferences.general; |
52 | 55 |
|
... | ... | |
79 | 82 |
public class FolderingPage extends AbstractPreferencePage{ |
80 | 83 |
private static Preferences prefs = Preferences.userRoot().node( "gvsig.foldering" ); |
81 | 84 |
|
85 |
private static final String PROJECTS_FOLDER_PROPERTY_NAME = "ProjectsFolder"; |
|
82 | 86 |
private static final String DATA_FOLDER_PROPERTY_NAME = "DataFolder"; |
83 | 87 |
private static final String TEMPLATES_FOLDER_PROPERTY_NAME = "TemplatesFolder"; |
88 |
private JTextField txtProjectsFolder; |
|
84 | 89 |
private JTextField txtDataFolder; |
90 |
private JTextField txtTemplatesFolder; |
|
91 |
private JButton btnSelectProjectsFolder; |
|
85 | 92 |
private JButton btnSelectDataFolder; |
86 |
private JTextField txtTemplatesFolder; |
|
87 | 93 |
private JButton btnSelectTemplatesFolder; |
88 | 94 |
private ImageIcon icon; |
89 | 95 |
private ActionListener btnFileChooserAction; |
96 |
|
|
90 | 97 |
public FolderingPage() { |
91 | 98 |
super(); |
92 |
|
|
99 |
setParentID(GeneralPage.id); |
|
93 | 100 |
icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/folder.png")); |
94 | 101 |
|
95 | 102 |
btnFileChooserAction = new ActionListener() { |
96 | 103 |
public void actionPerformed(ActionEvent e) { |
97 | 104 |
String path; |
98 |
if (e.getSource().equals(btnSelectDataFolder)) { |
|
105 |
if (e.getSource().equals(btnSelectProjectsFolder)) { |
|
106 |
path = txtProjectsFolder.getText(); |
|
107 |
} else if (e.getSource().equals(btnSelectDataFolder)) { |
|
99 | 108 |
path = txtDataFolder.getText(); |
100 | 109 |
} else { |
101 | 110 |
path = txtTemplatesFolder.getText(); |
... | ... | |
127 | 136 |
int result = fc.showOpenDialog(FolderingPage.this); |
128 | 137 |
|
129 | 138 |
if (result == JFileChooser.APPROVE_OPTION && (file = fc.getSelectedFile()) != null) { |
130 |
if (e.getSource().equals(btnSelectDataFolder)) { |
|
131 |
txtDataFolder.setText(file.getAbsolutePath()); |
|
132 |
} else { |
|
139 |
if (e.getSource().equals(btnSelectProjectsFolder)) { |
|
140 |
txtProjectsFolder.setText(file.getAbsolutePath()); |
|
141 |
} else if (e.getSource().equals(btnSelectDataFolder)) { |
|
142 |
txtDataFolder.setText(file.getAbsolutePath()); |
|
143 |
} else { |
|
133 | 144 |
txtTemplatesFolder.setText(file.getAbsolutePath()); |
134 | 145 |
} |
135 | 146 |
} |
136 | 147 |
} |
137 | 148 |
|
138 | 149 |
}; |
150 |
btnSelectProjectsFolder = new JButton(PluginServices.getText(this, "browse")); |
|
151 |
btnSelectProjectsFolder.addActionListener(btnFileChooserAction); |
|
139 | 152 |
btnSelectDataFolder = new JButton(PluginServices.getText(this, "browse")); |
140 | 153 |
btnSelectDataFolder.addActionListener(btnFileChooserAction); |
141 | 154 |
btnSelectTemplatesFolder = new JButton(PluginServices.getText(this, "browse")); |
142 | 155 |
btnSelectTemplatesFolder.addActionListener(btnFileChooserAction); |
143 | 156 |
|
144 | 157 |
|
158 |
JLabel lblProjectsFolder = new JLabel("<html><b>" + |
|
159 |
PluginServices. |
|
160 |
getText(this, "options.foldering.projects_folder") + |
|
161 |
"</b></html>"); |
|
162 |
addComponent(lblProjectsFolder); |
|
163 |
addComponent(txtProjectsFolder = new JTextField(40), btnSelectProjectsFolder); |
|
164 |
addComponent(new JLabel(" ")); |
|
165 |
|
|
145 | 166 |
JLabel lblDataFolder = new JLabel("<html><b>" + |
146 | 167 |
PluginServices. |
147 |
getText(this, "preferences.foldering.data_folder") +
|
|
168 |
getText(this, "options.foldering.data_folder") +
|
|
148 | 169 |
"</b></html>"); |
149 | 170 |
addComponent(lblDataFolder); |
150 | 171 |
addComponent(txtDataFolder = new JTextField(40), btnSelectDataFolder); |
151 | 172 |
addComponent(new JLabel(" ")); |
173 |
|
|
152 | 174 |
JLabel lblTemplatesFolder = new JLabel("<html><b>" + |
153 | 175 |
PluginServices. |
154 |
getText(this, "preferences.foldering.template_folder") +
|
|
176 |
getText(this, "options.foldering.template_folder") +
|
|
155 | 177 |
"</b></html>"); |
156 | 178 |
addComponent(lblTemplatesFolder); |
157 | 179 |
addComponent(txtTemplatesFolder = new JTextField(40), btnSelectTemplatesFolder); |
180 |
addComponent(new JLabel(" ")); |
|
158 | 181 |
|
159 | 182 |
PluginServices ps = PluginServices.getPluginServices(this); |
160 | 183 |
XMLEntity xml = ps.getPersistentXML(); |
161 | 184 |
|
185 |
if (xml.contains(PROJECTS_FOLDER_PROPERTY_NAME)) { |
|
186 |
prefs.put(PROJECTS_FOLDER_PROPERTY_NAME, xml.getStringProperty(PROJECTS_FOLDER_PROPERTY_NAME)); |
|
187 |
} |
|
188 |
|
|
162 | 189 |
if (xml.contains(DATA_FOLDER_PROPERTY_NAME)) { |
163 | 190 |
prefs.put(DATA_FOLDER_PROPERTY_NAME, xml.getStringProperty(DATA_FOLDER_PROPERTY_NAME)); |
164 | 191 |
} |
... | ... | |
171 | 198 |
|
172 | 199 |
public void storeValues() throws StoreException { |
173 | 200 |
File f; |
201 |
String path, propertyName; |
|
174 | 202 |
PluginServices ps = PluginServices.getPluginServices(this); |
175 | 203 |
XMLEntity xml = ps.getPersistentXML(); |
176 | 204 |
|
205 |
// Projects folder |
|
206 |
propertyName = PROJECTS_FOLDER_PROPERTY_NAME; |
|
207 |
path = txtProjectsFolder.getText(); |
|
208 |
|
|
209 |
if (path.equals("")) { |
|
210 |
if (xml.contains(propertyName)) { |
|
211 |
xml.remove(propertyName); |
|
212 |
} |
|
213 |
prefs.remove(propertyName); |
|
214 |
} else { |
|
215 |
f = new File(path); |
|
216 |
if (f.exists()) { |
|
217 |
if (xml.contains(propertyName)) { |
|
218 |
xml.remove(propertyName); |
|
219 |
} |
|
220 |
xml.putProperty(propertyName, f.getAbsolutePath()); |
|
221 |
prefs.put(propertyName, f.getAbsolutePath()); |
|
222 |
} |
|
223 |
} |
|
224 |
|
|
177 | 225 |
// Data folder |
178 |
f = new File(txtDataFolder.getText()); |
|
179 |
if (f.exists()) { |
|
180 |
final String propertyName = DATA_FOLDER_PROPERTY_NAME; |
|
226 |
propertyName = DATA_FOLDER_PROPERTY_NAME; |
|
227 |
path = txtDataFolder.getText(); |
|
228 |
|
|
229 |
if (path.equals("")) { |
|
181 | 230 |
if (xml.contains(propertyName)) { |
182 | 231 |
xml.remove(propertyName); |
183 | 232 |
} |
184 |
xml.putProperty(propertyName, f.getAbsolutePath()); |
|
185 |
prefs.put(DATA_FOLDER_PROPERTY_NAME, f.getAbsolutePath()); |
|
233 |
prefs.remove(propertyName); |
|
234 |
} else { |
|
235 |
f = new File(path); |
|
236 |
if (f.exists()) { |
|
237 |
if (xml.contains(propertyName)) { |
|
238 |
xml.remove(propertyName); |
|
239 |
} |
|
240 |
xml.putProperty(propertyName, f.getAbsolutePath()); |
|
241 |
prefs.put(propertyName, f.getAbsolutePath()); |
|
186 | 242 |
|
243 |
} |
|
187 | 244 |
} |
188 | 245 |
|
189 |
// Data folder |
|
190 |
f = new File(txtTemplatesFolder.getText()); |
|
191 |
if (f.exists()) { |
|
192 |
final String propertyName = TEMPLATES_FOLDER_PROPERTY_NAME; |
|
246 |
// Templates folder |
|
247 |
propertyName = TEMPLATES_FOLDER_PROPERTY_NAME; |
|
248 |
path = txtTemplatesFolder.getText(); |
|
249 |
|
|
250 |
if (path.equals("")) { |
|
193 | 251 |
if (xml.contains(propertyName)) { |
194 | 252 |
xml.remove(propertyName); |
195 | 253 |
} |
196 |
xml.putProperty(propertyName, f.getAbsolutePath()); |
|
197 |
prefs.put(TEMPLATES_FOLDER_PROPERTY_NAME, f.getAbsolutePath()); |
|
254 |
prefs.remove(propertyName); |
|
255 |
} else { |
|
256 |
f = new File(path); |
|
257 |
if (f.exists()) { |
|
258 |
if (xml.contains(propertyName)) { |
|
259 |
xml.remove(propertyName); |
|
260 |
} |
|
261 |
xml.putProperty(propertyName, f.getAbsolutePath()); |
|
262 |
prefs.put(propertyName, f.getAbsolutePath()); |
|
198 | 263 |
|
264 |
} |
|
199 | 265 |
} |
200 | 266 |
|
201 | 267 |
} |
... | ... | |
209 | 275 |
} |
210 | 276 |
|
211 | 277 |
public String getTitle() { |
212 |
return PluginServices.getText(this, "preferences.foldering.title");
|
|
278 |
return PluginServices.getText(this, "options.foldering.title");
|
|
213 | 279 |
} |
214 | 280 |
|
215 | 281 |
public JPanel getPanel() { |
... | ... | |
219 | 285 |
public void initializeValues() { |
220 | 286 |
PluginServices ps = PluginServices.getPluginServices(this); |
221 | 287 |
XMLEntity xml = ps.getPersistentXML(); |
288 |
if (xml.contains(PROJECTS_FOLDER_PROPERTY_NAME)) { |
|
289 |
txtProjectsFolder.setText(xml.getStringProperty(PROJECTS_FOLDER_PROPERTY_NAME)); |
|
290 |
} |
|
222 | 291 |
if (xml.contains(DATA_FOLDER_PROPERTY_NAME)) { |
223 | 292 |
txtDataFolder.setText(xml.getStringProperty(DATA_FOLDER_PROPERTY_NAME)); |
224 | 293 |
} |
... | ... | |
242 | 311 |
} |
243 | 312 |
|
244 | 313 |
} |
314 |
|
Also available in: Unified diff