mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 10:00:42 +01:00
cleaning up pdex prefs and underbrush
This commit is contained in:
@@ -206,34 +206,35 @@ public class JavaMode extends Mode {
|
||||
// Merged from ExperimentalMode
|
||||
|
||||
|
||||
static public volatile boolean errorCheckEnabled = true;
|
||||
static public volatile boolean warningsEnabled = true;
|
||||
static public volatile boolean codeCompletionsEnabled = true;
|
||||
static public volatile boolean errorLogsEnabled = false;
|
||||
static public volatile boolean autoSaveEnabled = true;
|
||||
static public volatile boolean autoSavePromptEnabled = true;
|
||||
static public volatile boolean defaultAutoSaveEnabled = true;
|
||||
static public volatile boolean ccTriggerEnabled = false;
|
||||
static public volatile boolean importSuggestEnabled = true;
|
||||
static public volatile boolean inspectModeHotkeyEnabled = true;
|
||||
static volatile boolean errorCheckEnabled = true;
|
||||
static volatile boolean warningsEnabled = true;
|
||||
static volatile boolean errorLogsEnabled = false;
|
||||
|
||||
static volatile boolean autoSaveEnabled = true;
|
||||
static volatile boolean autoSavePromptEnabled = true;
|
||||
static volatile boolean defaultAutoSaveEnabled = true;
|
||||
|
||||
static volatile boolean codeCompletionsEnabled = true;
|
||||
static volatile boolean ccTriggerEnabled = false;
|
||||
static volatile boolean importSuggestEnabled = true;
|
||||
static volatile boolean inspectModeHotkeyEnabled = true;
|
||||
|
||||
static public int autoSaveInterval = 3; //in minutes
|
||||
|
||||
static public final String prefErrorCheck = "pdex.errorCheckEnabled";
|
||||
static public final String prefWarnings = "pdex.warningsEnabled";
|
||||
static public final String prefErrorLogs = "pdex.writeErrorLogs";
|
||||
static public final String prefAutoSaveInterval = "pdex.autoSaveInterval";
|
||||
|
||||
static public final String prefAutoSave = "pdex.autoSave.autoSaveEnabled";
|
||||
static public final String prefAutoSaveInterval = "pdex.autoSaveInterval";
|
||||
static public final String prefAutoSavePrompt = "pdex.autoSave.promptDisplay";
|
||||
static public final String prefDefaultAutoSave = "pdex.autoSave.autoSaveByDefault";
|
||||
static public final String suggestionsFileName = "suggestions.txt";
|
||||
|
||||
static public final String COMPLETION_PREF = "pdex.completion";
|
||||
static public final String COMPLETION_TRIGGER_PREF = "pdex.completion.trigger";
|
||||
static public final String SUGGEST_IMPORTS_PREF = "pdex.suggest.imports";
|
||||
static public final String INSPECT_MODE_HOTKEY_PREF = "pdex.inspectMode.hotkey";
|
||||
|
||||
|
||||
/**
|
||||
* Stores the white list/black list of allowed/blacklisted imports.
|
||||
* These are defined in suggestions.txt in java mode folder.
|
||||
@@ -243,38 +244,44 @@ public class JavaMode extends Mode {
|
||||
|
||||
static boolean checkSuggestion(String mapName, String impName) {
|
||||
return suggestionsMap.containsKey(mapName) &&
|
||||
JavaMode.suggestionsMap.get(mapName).contains(impName);
|
||||
suggestionsMap.get(mapName).contains(impName);
|
||||
}
|
||||
|
||||
|
||||
public void loadPreferences() {
|
||||
Messages.log("Load PDEX prefs");
|
||||
ensurePrefsExist();
|
||||
|
||||
errorCheckEnabled = Preferences.getBoolean(prefErrorCheck);
|
||||
warningsEnabled = Preferences.getBoolean(prefWarnings);
|
||||
codeCompletionsEnabled = Preferences.getBoolean(COMPLETION_PREF);
|
||||
errorLogsEnabled = Preferences.getBoolean(prefErrorLogs);
|
||||
autoSaveInterval = Preferences.getInteger(prefAutoSaveInterval);
|
||||
|
||||
autoSaveEnabled = Preferences.getBoolean(prefAutoSave);
|
||||
autoSaveInterval = Preferences.getInteger(prefAutoSaveInterval);
|
||||
autoSavePromptEnabled = Preferences.getBoolean(prefAutoSavePrompt);
|
||||
defaultAutoSaveEnabled = Preferences.getBoolean(prefDefaultAutoSave);
|
||||
|
||||
codeCompletionsEnabled = Preferences.getBoolean(COMPLETION_PREF);
|
||||
ccTriggerEnabled = Preferences.getBoolean(COMPLETION_TRIGGER_PREF);
|
||||
importSuggestEnabled = Preferences.getBoolean(SUGGEST_IMPORTS_PREF);
|
||||
inspectModeHotkeyEnabled = Preferences.getBoolean(INSPECT_MODE_HOTKEY_PREF);
|
||||
|
||||
loadSuggestionsMap();
|
||||
}
|
||||
|
||||
|
||||
public void savePreferences() {
|
||||
Messages.log("Saving PDEX prefs");
|
||||
|
||||
Preferences.setBoolean(prefErrorCheck, errorCheckEnabled);
|
||||
Preferences.setBoolean(prefWarnings, warningsEnabled);
|
||||
Preferences.setBoolean(COMPLETION_PREF, codeCompletionsEnabled);
|
||||
Preferences.setBoolean(prefErrorLogs, errorLogsEnabled);
|
||||
Preferences.setInteger(prefAutoSaveInterval, autoSaveInterval);
|
||||
|
||||
Preferences.setBoolean(prefAutoSave, autoSaveEnabled);
|
||||
Preferences.setInteger(prefAutoSaveInterval, autoSaveInterval);
|
||||
Preferences.setBoolean(prefAutoSavePrompt, autoSavePromptEnabled);
|
||||
Preferences.setBoolean(prefDefaultAutoSave, defaultAutoSaveEnabled);
|
||||
|
||||
Preferences.setBoolean(COMPLETION_PREF, codeCompletionsEnabled);
|
||||
Preferences.setBoolean(COMPLETION_TRIGGER_PREF, ccTriggerEnabled);
|
||||
Preferences.setBoolean(SUGGEST_IMPORTS_PREF, importSuggestEnabled);
|
||||
Preferences.setBoolean(INSPECT_MODE_HOTKEY_PREF, inspectModeHotkeyEnabled);
|
||||
@@ -282,9 +289,9 @@ public class JavaMode extends Mode {
|
||||
|
||||
|
||||
private void loadSuggestionsMap() {
|
||||
File suggestionsListFile = new File(getFolder(), suggestionsFileName);
|
||||
if (suggestionsListFile.exists()) {
|
||||
String[] lines = PApplet.loadStrings(suggestionsListFile);
|
||||
File suggestionsFile = new File(getFolder(), "suggestions.txt");
|
||||
if (suggestionsFile.exists()) {
|
||||
String[] lines = PApplet.loadStrings(suggestionsFile);
|
||||
if (lines != null) {
|
||||
for (String line : lines) {
|
||||
if (!line.trim().startsWith("#")) {
|
||||
@@ -307,34 +314,7 @@ public class JavaMode extends Mode {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Messages.loge("Suggestions file not found at " + suggestionsListFile);
|
||||
Messages.loge("Suggestions file not found at " + suggestionsFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ensurePrefsExist() {
|
||||
//TODO: Need to do a better job of managing prefs. Think lists.
|
||||
if (Preferences.get(prefErrorCheck) == null)
|
||||
Preferences.setBoolean(prefErrorCheck, errorCheckEnabled);
|
||||
if (Preferences.get(prefWarnings) == null)
|
||||
Preferences.setBoolean(prefWarnings, warningsEnabled);
|
||||
if (Preferences.get(COMPLETION_PREF) == null)
|
||||
Preferences.setBoolean(COMPLETION_PREF, codeCompletionsEnabled);
|
||||
if (Preferences.get(prefErrorLogs) == null)
|
||||
Preferences.setBoolean(prefErrorLogs, errorLogsEnabled);
|
||||
if (Preferences.get(prefAutoSaveInterval) == null)
|
||||
Preferences.setInteger(prefAutoSaveInterval, autoSaveInterval);
|
||||
if (Preferences.get(prefAutoSave) == null)
|
||||
Preferences.setBoolean(prefAutoSave, autoSaveEnabled);
|
||||
if (Preferences.get(prefAutoSavePrompt) == null)
|
||||
Preferences.setBoolean(prefAutoSavePrompt, autoSavePromptEnabled);
|
||||
if (Preferences.get(prefDefaultAutoSave) == null)
|
||||
Preferences.setBoolean(prefDefaultAutoSave, defaultAutoSaveEnabled);
|
||||
if (Preferences.get(COMPLETION_TRIGGER_PREF) == null)
|
||||
Preferences.setBoolean(COMPLETION_TRIGGER_PREF, ccTriggerEnabled);
|
||||
if (Preferences.get(SUGGEST_IMPORTS_PREF) == null)
|
||||
Preferences.setBoolean(SUGGEST_IMPORTS_PREF, importSuggestEnabled);
|
||||
if (Preferences.get(INSPECT_MODE_HOTKEY_PREF) == null)
|
||||
Preferences.setBoolean(INSPECT_MODE_HOTKEY_PREF, inspectModeHotkeyEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user