瀏覽代碼

autoSave fix

Jessey Widhalm 8 年之前
父節點
當前提交
898bbfbb7d
共有 2 個文件被更改,包括 10 次插入1 次删除
  1. 1 1
      src/ui/controller/Control.java
  2. 9 0
      src/ui/view/MyCanvas.java

+ 1 - 1
src/ui/controller/Control.java

@@ -246,7 +246,7 @@ public class Control {
 		simulationManager.setCanvas(can);
 	}
 
-	private void autoSave() throws IOException {
+	public void autoSave() throws IOException {
 		autoSaveController.increaseAutoSaveNr();
 		storeController.writeCanvasFile(autoPath + autoSaveController.getAutoSaveNr());
 		if (autoSaveController.allowed()) {

+ 9 - 0
src/ui/view/MyCanvas.java

@@ -15,6 +15,7 @@ import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
 import java.awt.geom.Line2D;
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Timer;
 import java.util.TimerTask;
@@ -402,6 +403,14 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			model.getSelectedCpsObjects().clear();
 			controller.addSelectedObject(tempCps);
 		}
+		if(dragged == true){
+			try {
+				controller.autoSave();
+			} catch (IOException e1) {
+				// TODO Auto-generated catch block
+				e1.printStackTrace();
+			}
+		}
 		dragged = false;
 
 		// Rightclick List