|
@@ -41,7 +41,7 @@ public class Control {
|
|
|
private final ObjectController objectController;
|
|
|
private final CanvasController canvasController;
|
|
|
private final GlobalController globalController;
|
|
|
- private final SaveController storeController;
|
|
|
+ private final SaveController saveController;
|
|
|
private final LoadController loadController;
|
|
|
private final AutoSaveController autoSaveController;
|
|
|
private SimulationManager simulationManager;
|
|
@@ -49,7 +49,8 @@ public class Control {
|
|
|
private final NodeController nodeController;
|
|
|
private final ClipboardController clipboardController;
|
|
|
private final HolonCanvasController holonCanvasController;
|
|
|
- private String autoPath = "";
|
|
|
+ private String autosaveDir = "";
|
|
|
+ private String categoryDir = "";
|
|
|
|
|
|
/**
|
|
|
* Constructor.
|
|
@@ -65,7 +66,7 @@ public class Control {
|
|
|
this.objectController = new ObjectController(model, multiPurposeController);
|
|
|
this.canvasController = new CanvasController(model, multiPurposeController);
|
|
|
this.globalController = new GlobalController(model);
|
|
|
- this.storeController = new SaveController(model);
|
|
|
+ this.saveController = new SaveController(model);
|
|
|
this.nodeController = new NodeController(model, canvasController, multiPurposeController);
|
|
|
this.loadController = new LoadController(model, categoryController, canvasController, objectController,
|
|
|
nodeController, multiPurposeController);
|
|
@@ -73,14 +74,17 @@ public class Control {
|
|
|
this.autoSaveController = new AutoSaveController(model);
|
|
|
this.consoleController = new ConsoleController(model);
|
|
|
this.statsController = new StatsController(model);
|
|
|
- this.clipboardController = new ClipboardController(model, storeController, loadController, canvasController,
|
|
|
+ this.clipboardController = new ClipboardController(model, saveController, loadController, canvasController,
|
|
|
objectController, nodeController, multiPurposeController);
|
|
|
this.holonCanvasController = new HolonCanvasController(model);
|
|
|
|
|
|
- autoPath = System.getProperty("user.home") + "/HolonGUI/Autosave/";
|
|
|
- File dest = new File(autoPath);
|
|
|
+ autosaveDir = System.getProperty("user.home") + "/HolonGUI/Autosave/";
|
|
|
+ categoryDir = System.getProperty("user.home") + "/HolonGUI/Category/";
|
|
|
+ File autoSave = new File(autosaveDir);
|
|
|
+ File category = new File(categoryDir);
|
|
|
// deleteDirectory(dest);
|
|
|
- dest.mkdirs();
|
|
|
+ autoSave.mkdirs();
|
|
|
+ category.mkdirs();
|
|
|
try {
|
|
|
autoSave();
|
|
|
} catch (IOException e) {
|
|
@@ -161,9 +165,11 @@ public class Control {
|
|
|
|
|
|
/**
|
|
|
* init default category and objects.
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
|
- public void resetCategorys() {
|
|
|
+ public void resetCategorys() throws IOException {
|
|
|
categoryController.initCategories();
|
|
|
+ saveCategory();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -171,9 +177,11 @@ public class Control {
|
|
|
*
|
|
|
* @param cat
|
|
|
* name of the new Category
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
|
- public void addCategory(String cat) {
|
|
|
+ public void addCategory(String cat) throws IOException {
|
|
|
categoryController.addNewCategory(cat);
|
|
|
+ saveCategory();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -187,9 +195,11 @@ public class Control {
|
|
|
* Array of Elements
|
|
|
* @param img
|
|
|
* the image Path
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
|
- public void addObject(Category cat, String obj, ArrayList<HolonElement> ele, String img) {
|
|
|
+ public void addObject(Category cat, String obj, ArrayList<HolonElement> ele, String img) throws IOException {
|
|
|
categoryController.addNewHolonObject(cat, obj, ele, img);
|
|
|
+ saveCategory();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -211,9 +221,11 @@ public class Control {
|
|
|
* Category
|
|
|
* @param obj
|
|
|
* New Object Name
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
|
- public void addSwitch(Category cat, String obj) {
|
|
|
+ public void addSwitch(Category cat, String obj) throws IOException {
|
|
|
categoryController.addNewHolonSwitch(cat, obj, "/Images/switch-on.png");
|
|
|
+ saveCategory();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -221,9 +233,11 @@ public class Control {
|
|
|
*
|
|
|
* @param cat
|
|
|
* the Category
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
|
- public void deleteCategory(String cat) {
|
|
|
+ public void deleteCategory(String cat) throws IOException {
|
|
|
categoryController.deleteCategory(cat);
|
|
|
+ saveCategory();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -233,9 +247,11 @@ public class Control {
|
|
|
* the Category
|
|
|
* @param obj
|
|
|
* the Object
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
|
- public void delObjectCategory(String cat, String obj) {
|
|
|
+ public void delObjectCategory(String cat, String obj) throws IOException {
|
|
|
categoryController.deleteObject(cat, obj);
|
|
|
+ saveCategory();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -471,7 +487,7 @@ public class Control {
|
|
|
* exception
|
|
|
*/
|
|
|
public void saveFile(String path) throws IOException, ArchiveException {
|
|
|
- storeController.writeSave(path);
|
|
|
+ saveController.writeSave(path);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -485,6 +501,8 @@ public class Control {
|
|
|
*/
|
|
|
public void loadFile(String path) throws IOException, ArchiveException, ZipException {
|
|
|
loadController.readSave(path);
|
|
|
+ saveCategory();
|
|
|
+ autoSave();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -552,11 +570,15 @@ public class Control {
|
|
|
*/
|
|
|
public void autoSave() throws IOException {
|
|
|
autoSaveController.increaseAutoSaveNr();
|
|
|
- storeController.writeAutosave(autoPath + autoSaveController.getAutoSaveNr());
|
|
|
+ saveController.writeAutosave(autosaveDir + autoSaveController.getAutoSaveNr());
|
|
|
if (autoSaveController.allowed()) {
|
|
|
- new File(autoPath + (autoSaveController.getAutoSaveNr() - globalController.getNumbersOfSaves())).delete();
|
|
|
+ new File(autosaveDir + (autoSaveController.getAutoSaveNr() - globalController.getNumbersOfSaves())).delete();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void saveCategory() throws IOException {
|
|
|
+ saveController.writeCategory(categoryDir + "Category.json");
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Returns the undo save.
|
|
@@ -565,10 +587,10 @@ public class Control {
|
|
|
*/
|
|
|
public String getUndoSave() {
|
|
|
autoSaveController.decreaseAutoSaveNr();
|
|
|
- if (!new File(autoPath + (autoSaveController.getAutoSaveNr())).exists()) {
|
|
|
+ if (!new File(autosaveDir + (autoSaveController.getAutoSaveNr())).exists()) {
|
|
|
autoSaveController.increaseAutoSaveNr();
|
|
|
}
|
|
|
- return autoPath + (autoSaveController.getAutoSaveNr());
|
|
|
+ return autosaveDir + (autoSaveController.getAutoSaveNr());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -578,10 +600,10 @@ public class Control {
|
|
|
*/
|
|
|
public String getRedoSave() {
|
|
|
autoSaveController.increaseAutoSaveNr();
|
|
|
- if (!new File(autoPath + (autoSaveController.getAutoSaveNr())).exists()) {
|
|
|
+ if (!new File(autosaveDir + (autoSaveController.getAutoSaveNr())).exists()) {
|
|
|
autoSaveController.decreaseAutoSaveNr();
|
|
|
}
|
|
|
- return autoPath + (autoSaveController.getAutoSaveNr());
|
|
|
+ return autosaveDir + (autoSaveController.getAutoSaveNr());
|
|
|
}
|
|
|
|
|
|
|