@@ -206,34 +206,35 @@ public String getSearchPath() { |
206 | 206 | // Merged from ExperimentalMode |
207 | 207 |
|
208 | 208 |
|
209 | | - static public volatile boolean errorCheckEnabled = true; |
210 | | - static public volatile boolean warningsEnabled = true; |
211 | | - static public volatile boolean codeCompletionsEnabled = true; |
212 | | - static public volatile boolean errorLogsEnabled = false; |
213 | | - static public volatile boolean autoSaveEnabled = true; |
214 | | - static public volatile boolean autoSavePromptEnabled = true; |
215 | | - static public volatile boolean defaultAutoSaveEnabled = true; |
216 | | - static public volatile boolean ccTriggerEnabled = false; |
217 | | - static public volatile boolean importSuggestEnabled = true; |
218 | | - static public volatile boolean inspectModeHotkeyEnabled = true; |
| 209 | + static volatile boolean errorCheckEnabled = true; |
| 210 | + static volatile boolean warningsEnabled = true; |
| 211 | + static volatile boolean errorLogsEnabled = false; |
| 212 | + |
| 213 | + static volatile boolean autoSaveEnabled = true; |
| 214 | + static volatile boolean autoSavePromptEnabled = true; |
| 215 | + static volatile boolean defaultAutoSaveEnabled = true; |
| 216 | + |
| 217 | + static volatile boolean codeCompletionsEnabled = true; |
| 218 | + static volatile boolean ccTriggerEnabled = false; |
| 219 | + static volatile boolean importSuggestEnabled = true; |
| 220 | + static volatile boolean inspectModeHotkeyEnabled = true; |
219 | 221 |
|
220 | 222 | static public int autoSaveInterval = 3; //in minutes |
221 | 223 |
|
222 | 224 | static public final String prefErrorCheck = "pdex.errorCheckEnabled"; |
223 | 225 | static public final String prefWarnings = "pdex.warningsEnabled"; |
224 | 226 | static public final String prefErrorLogs = "pdex.writeErrorLogs"; |
225 | | - static public final String prefAutoSaveInterval = "pdex.autoSaveInterval"; |
| 227 | + |
226 | 228 | static public final String prefAutoSave = "pdex.autoSave.autoSaveEnabled"; |
| 229 | + static public final String prefAutoSaveInterval = "pdex.autoSaveInterval"; |
227 | 230 | static public final String prefAutoSavePrompt = "pdex.autoSave.promptDisplay"; |
228 | 231 | static public final String prefDefaultAutoSave = "pdex.autoSave.autoSaveByDefault"; |
229 | | - static public final String suggestionsFileName = "suggestions.txt"; |
230 | 232 |
|
231 | 233 | static public final String COMPLETION_PREF = "pdex.completion"; |
232 | 234 | static public final String COMPLETION_TRIGGER_PREF = "pdex.completion.trigger"; |
233 | 235 | static public final String SUGGEST_IMPORTS_PREF = "pdex.suggest.imports"; |
234 | 236 | static public final String INSPECT_MODE_HOTKEY_PREF = "pdex.inspectMode.hotkey"; |
235 | 237 |
|
236 | | - |
237 | 238 | /** |
238 | 239 | * Stores the white list/black list of allowed/blacklisted imports. |
239 | 240 | * These are defined in suggestions.txt in java mode folder. |
@@ -243,48 +244,54 @@ public String getSearchPath() { |
243 | 244 |
|
244 | 245 | static boolean checkSuggestion(String mapName, String impName) { |
245 | 246 | return suggestionsMap.containsKey(mapName) && |
246 | | - JavaMode.suggestionsMap.get(mapName).contains(impName); |
| 247 | + suggestionsMap.get(mapName).contains(impName); |
247 | 248 | } |
248 | 249 |
|
249 | 250 |
|
250 | 251 | public void loadPreferences() { |
251 | 252 | Messages.log("Load PDEX prefs"); |
252 | | - ensurePrefsExist(); |
| 253 | + |
253 | 254 | errorCheckEnabled = Preferences.getBoolean(prefErrorCheck); |
254 | 255 | warningsEnabled = Preferences.getBoolean(prefWarnings); |
255 | | - codeCompletionsEnabled = Preferences.getBoolean(COMPLETION_PREF); |
256 | 256 | errorLogsEnabled = Preferences.getBoolean(prefErrorLogs); |
257 | | - autoSaveInterval = Preferences.getInteger(prefAutoSaveInterval); |
| 257 | + |
258 | 258 | autoSaveEnabled = Preferences.getBoolean(prefAutoSave); |
| 259 | + autoSaveInterval = Preferences.getInteger(prefAutoSaveInterval); |
259 | 260 | autoSavePromptEnabled = Preferences.getBoolean(prefAutoSavePrompt); |
260 | 261 | defaultAutoSaveEnabled = Preferences.getBoolean(prefDefaultAutoSave); |
| 262 | + |
| 263 | + codeCompletionsEnabled = Preferences.getBoolean(COMPLETION_PREF); |
261 | 264 | ccTriggerEnabled = Preferences.getBoolean(COMPLETION_TRIGGER_PREF); |
262 | 265 | importSuggestEnabled = Preferences.getBoolean(SUGGEST_IMPORTS_PREF); |
263 | 266 | inspectModeHotkeyEnabled = Preferences.getBoolean(INSPECT_MODE_HOTKEY_PREF); |
| 267 | + |
264 | 268 | loadSuggestionsMap(); |
265 | 269 | } |
266 | 270 |
|
267 | 271 |
|
268 | 272 | public void savePreferences() { |
269 | 273 | Messages.log("Saving PDEX prefs"); |
| 274 | + |
270 | 275 | Preferences.setBoolean(prefErrorCheck, errorCheckEnabled); |
271 | 276 | Preferences.setBoolean(prefWarnings, warningsEnabled); |
272 | | - Preferences.setBoolean(COMPLETION_PREF, codeCompletionsEnabled); |
273 | 277 | Preferences.setBoolean(prefErrorLogs, errorLogsEnabled); |
274 | | - Preferences.setInteger(prefAutoSaveInterval, autoSaveInterval); |
| 278 | + |
275 | 279 | Preferences.setBoolean(prefAutoSave, autoSaveEnabled); |
| 280 | + Preferences.setInteger(prefAutoSaveInterval, autoSaveInterval); |
276 | 281 | Preferences.setBoolean(prefAutoSavePrompt, autoSavePromptEnabled); |
277 | 282 | Preferences.setBoolean(prefDefaultAutoSave, defaultAutoSaveEnabled); |
| 283 | + |
| 284 | + Preferences.setBoolean(COMPLETION_PREF, codeCompletionsEnabled); |
278 | 285 | Preferences.setBoolean(COMPLETION_TRIGGER_PREF, ccTriggerEnabled); |
279 | 286 | Preferences.setBoolean(SUGGEST_IMPORTS_PREF, importSuggestEnabled); |
280 | 287 | Preferences.setBoolean(INSPECT_MODE_HOTKEY_PREF, inspectModeHotkeyEnabled); |
281 | 288 | } |
282 | 289 |
|
283 | 290 |
|
284 | 291 | private void loadSuggestionsMap() { |
285 | | - File suggestionsListFile = new File(getFolder(), suggestionsFileName); |
286 | | - if (suggestionsListFile.exists()) { |
287 | | - String[] lines = PApplet.loadStrings(suggestionsListFile); |
| 292 | + File suggestionsFile = new File(getFolder(), "suggestions.txt"); |
| 293 | + if (suggestionsFile.exists()) { |
| 294 | + String[] lines = PApplet.loadStrings(suggestionsFile); |
288 | 295 | if (lines != null) { |
289 | 296 | for (String line : lines) { |
290 | 297 | if (!line.trim().startsWith("#")) { |
@@ -307,34 +314,7 @@ private void loadSuggestionsMap() { |
307 | 314 | } |
308 | 315 | } |
309 | 316 | } else { |
310 | | - Messages.loge("Suggestions file not found at " + suggestionsListFile); |
| 317 | + Messages.loge("Suggestions file not found at " + suggestionsFile); |
311 | 318 | } |
312 | 319 | } |
313 | | - |
314 | | - |
315 | | - public void ensurePrefsExist() { |
316 | | - //TODO: Need to do a better job of managing prefs. Think lists. |
317 | | - if (Preferences.get(prefErrorCheck) == null) |
318 | | - Preferences.setBoolean(prefErrorCheck, errorCheckEnabled); |
319 | | - if (Preferences.get(prefWarnings) == null) |
320 | | - Preferences.setBoolean(prefWarnings, warningsEnabled); |
321 | | - if (Preferences.get(COMPLETION_PREF) == null) |
322 | | - Preferences.setBoolean(COMPLETION_PREF, codeCompletionsEnabled); |
323 | | - if (Preferences.get(prefErrorLogs) == null) |
324 | | - Preferences.setBoolean(prefErrorLogs, errorLogsEnabled); |
325 | | - if (Preferences.get(prefAutoSaveInterval) == null) |
326 | | - Preferences.setInteger(prefAutoSaveInterval, autoSaveInterval); |
327 | | - if (Preferences.get(prefAutoSave) == null) |
328 | | - Preferences.setBoolean(prefAutoSave, autoSaveEnabled); |
329 | | - if (Preferences.get(prefAutoSavePrompt) == null) |
330 | | - Preferences.setBoolean(prefAutoSavePrompt, autoSavePromptEnabled); |
331 | | - if (Preferences.get(prefDefaultAutoSave) == null) |
332 | | - Preferences.setBoolean(prefDefaultAutoSave, defaultAutoSaveEnabled); |
333 | | - if (Preferences.get(COMPLETION_TRIGGER_PREF) == null) |
334 | | - Preferences.setBoolean(COMPLETION_TRIGGER_PREF, ccTriggerEnabled); |
335 | | - if (Preferences.get(SUGGEST_IMPORTS_PREF) == null) |
336 | | - Preferences.setBoolean(SUGGEST_IMPORTS_PREF, importSuggestEnabled); |
337 | | - if (Preferences.get(INSPECT_MODE_HOTKEY_PREF) == null) |
338 | | - Preferences.setBoolean(INSPECT_MODE_HOTKEY_PREF, inspectModeHotkeyEnabled); |
339 | | - } |
340 | 320 | } |