Added untitledAutoSave, autoSave to preferences

This commit is contained in:
joelmoniz
2014-06-04 20:19:42 +05:30
parent c02d3585f6
commit 95755e9404
2 changed files with 16 additions and 17 deletions

View File

@@ -1079,8 +1079,11 @@ public class DebugEditor extends JavaEditor implements ActionListener {
@Override
public void prepareRun() {
super.prepareRun();
if (!ExperimentalMode.autoSaveEnabled)
return;
try {
if (sketch.isUntitled()) {
if (sketch.isUntitled() && ExperimentalMode.untitledAutoSaveEnabled) {
if (handleSave(true))
statusTimedNotice("Saved. Running...", 5);
else
@@ -1118,20 +1121,6 @@ public class DebugEditor extends JavaEditor implements ActionListener {
* @param secs
*/
public void statusTimedNotice(final String msg, final int secs) {
// EventQueue.invokeLater(new Runnable() {
//
// @Override
// public void run() {
// statusNotice(msg);
// try {
// Thread.sleep(secs * 1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// statusEmpty();
//
// }
// });
SwingWorker s = new SwingWorker<Void, Void>() {
@Override

View File

@@ -127,13 +127,15 @@ public class ExperimentalMode extends JavaMode {
}
volatile public static boolean errorCheckEnabled = true, warningsEnabled = true,
codeCompletionsEnabled = true, debugOutputEnabled = false, errorLogsEnabled = false;
codeCompletionsEnabled = true, debugOutputEnabled = false, errorLogsEnabled = false,
untitledAutoSaveEnabled = false, autoSaveEnabled = true;
public static int autoSaveInterval = 3; //in minutes
public static final String prefErrorCheck = "pdex.errorCheckEnabled",
prefWarnings = "pdex.warningsEnabled",
prefCodeCompletionEnabled = "pdex.ccEnabled",
prefDebugOP = "pdex.dbgOutput", prefErrorLogs = "pdex.writeErrorLogs", prefAutoSaveInterval = "pdex.autoSaveInterval";
prefDebugOP = "pdex.dbgOutput", prefErrorLogs = "pdex.writeErrorLogs", prefAutoSaveInterval = "pdex.autoSaveInterval",
prefUntitledAutoSave = "pdex.autoSave.untitledAutoSaveEnabled", prefAutoSave = "pdex.autoSaveEnabled";
public void loadPreferences(){
log("Load PDEX prefs");
@@ -144,6 +146,8 @@ public class ExperimentalMode extends JavaMode {
DEBUG = Preferences.getBoolean(prefDebugOP);
errorLogsEnabled = Preferences.getBoolean(prefErrorLogs);
autoSaveInterval = Preferences.getInteger(prefAutoSaveInterval);
untitledAutoSaveEnabled = Preferences.getBoolean(prefUntitledAutoSave);
autoSaveEnabled = Preferences.getBoolean(prefAutoSave);
}
public void savePreferences(){
@@ -154,6 +158,8 @@ public class ExperimentalMode extends JavaMode {
Preferences.setBoolean(prefDebugOP, DEBUG);
Preferences.setBoolean(prefErrorLogs,errorLogsEnabled);
Preferences.setInteger(prefAutoSaveInterval,autoSaveInterval);
Preferences.setBoolean(prefUntitledAutoSave,untitledAutoSaveEnabled);
Preferences.setBoolean(prefAutoSave,autoSaveEnabled);
}
public void ensurePrefsExist(){
@@ -169,6 +175,10 @@ public class ExperimentalMode extends JavaMode {
Preferences.setBoolean(prefErrorLogs,errorLogsEnabled);
if(Preferences.get(prefAutoSaveInterval) == null)
Preferences.setInteger(prefAutoSaveInterval,autoSaveInterval);
if(Preferences.get(prefUntitledAutoSave) == null)
Preferences.setBoolean(prefUntitledAutoSave,untitledAutoSaveEnabled);
if(Preferences.get(prefAutoSave) == null)
Preferences.setBoolean(prefAutoSave,autoSaveEnabled);
}