Ver código fonte

load last autoSave after crash

Jessey Widhalm 7 anos atrás
pai
commit
8da821120b
2 arquivos alterados com 22 adições e 1 exclusões
  1. 1 1
      src/ui/controller/Control.java
  2. 21 0
      src/ui/view/GUI.java

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

@@ -53,7 +53,7 @@ public class Control {
 		this.consoleController = new ConsoleController(MODEL);
 		autoPath = System.getProperty("user.home") + "/HolonGUI/Autosave/";
 		File dest = new File(autoPath);
-		deleteDirectory(dest);
+		//deleteDirectory(dest);
 		dest.mkdirs();
 		try {
 			autoSave();

+ 21 - 0
src/ui/view/GUI.java

@@ -1509,6 +1509,27 @@ public class GUI<E> implements CategoryListener {
 		tableHolonElementScrollPane.setBorder(null);
 
 		frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
+		
+		String autoPath = System.getProperty("user.home") + "/HolonGUI/Autosave/";
+		File dest = new File(autoPath);
+		if(dest.listFiles().length>1){
+			int dialogButton = JOptionPane.YES_NO_OPTION;
+			int dialogResult = JOptionPane.showConfirmDialog (null, "Old autosave file was found, should it be loaded?", "Warning",dialogButton);
+			if(dialogResult == JOptionPane.YES_OPTION){
+				model.setAutoSaveNr(dest.listFiles().length-1);
+				mntmRedo.doClick();
+			}else{
+				controller.deleteDirectory(dest);
+				dest.mkdirs();
+				try {
+					controller.autoSave();
+				} catch (IOException e1) {
+					// TODO Auto-generated catch block
+					e1.printStackTrace();
+				}
+			}
+			
+		}
 	}
 
 	/**