diff --git a/pdex/src/processing/mode/experimental/AutoSaveUtil.java b/pdex/src/processing/mode/experimental/AutoSaveUtil.java new file mode 100644 index 000000000..6e36c3595 --- /dev/null +++ b/pdex/src/processing/mode/experimental/AutoSaveUtil.java @@ -0,0 +1,50 @@ +package processing.mode.experimental; + +import java.util.Timer; +import java.util.TimerTask; + +public class AutoSaveUtil { + + private DebugEditor editor; + + private Timer timer; + + private int saveTime; + + /** + * + * @param dedit + * @param timeOut - in minutes + */ + public AutoSaveUtil(DebugEditor dedit, int timeOut){ + editor = dedit; + if (timeOut < 5) { + saveTime = -1; + throw new IllegalArgumentException(""); + } + else{ + saveTime = timeOut * 60 * 1000; + } + } + + public void init(){ + if(saveTime < 1000) return; + saveTime = 1000; + timer = new Timer(); + timer.schedule(new SaveTask(), saveTime, saveTime); + } + + private class SaveTask extends TimerTask{ + + @Override + public void run() { + ExperimentalMode.log("Saved " + editor.getSketch().getMainFilePath()); + } + + } + + public static void main(String[] args) { + + } + +} diff --git a/pdex/src/processing/mode/experimental/DebugEditor.java b/pdex/src/processing/mode/experimental/DebugEditor.java index 953a4bffc..dcbfa4d47 100755 --- a/pdex/src/processing/mode/experimental/DebugEditor.java +++ b/pdex/src/processing/mode/experimental/DebugEditor.java @@ -177,6 +177,8 @@ public class DebugEditor extends JavaEditor implements ActionListener { */ protected JCheckBoxMenuItem completionsEnabled; + protected AutoSaveUtil autosaver; + public DebugEditor(Base base, String path, EditorState state, Mode mode) { super(base, path, state, mode); @@ -244,6 +246,8 @@ public class DebugEditor extends JavaEditor implements ActionListener { addXQModeUI(); debugToolbarEnabled = new AtomicBoolean(false); log("Sketch Path: " + path); + autosaver = new AutoSaveUtil(this, 5); + autosaver.init(); } private void addXQModeUI(){