|
@@ -2293,14 +2293,16 @@ public class GUI implements CategoryListener {
|
|
|
fileChooser.setFileFilter(holonFilter);
|
|
|
|
|
|
if (fileChooser.showSaveDialog(frmCyberPhysical) == JFileChooser.APPROVE_OPTION) {
|
|
|
- String file = fileChooser.getSelectedFile().getPath();
|
|
|
+ File selectedFile = fileChooser.getSelectedFile();
|
|
|
+ String fileName = selectedFile.getName();
|
|
|
+ String fullPath = fileChooser.getSelectedFile().getPath();
|
|
|
if (fileChooser.getFileFilter().equals(holonFilter)) {
|
|
|
- if (!file.contains("."))
|
|
|
- file += ".holon";
|
|
|
+ if (!fileName.contains("."))
|
|
|
+ fullPath += ".holon";
|
|
|
}
|
|
|
- if (!file.endsWith(".holon")) {
|
|
|
- String suffix = file.substring(file.lastIndexOf("."),
|
|
|
- file.length());
|
|
|
+ if (!fullPath.endsWith(".holon")) {
|
|
|
+ String suffix = fullPath.substring(fullPath.lastIndexOf("."),
|
|
|
+ fullPath.length());
|
|
|
String[] options = new String[] { "keep .holon",
|
|
|
"use " + suffix };
|
|
|
|
|
@@ -2315,11 +2317,11 @@ public class GUI implements CategoryListener {
|
|
|
options[1]);
|
|
|
|
|
|
if (response == 0)
|
|
|
- file = file.replace(suffix, ".holon");
|
|
|
+ fullPath = fullPath.replace(suffix, ".holon");
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- controller.saveFile(new File(file).getAbsolutePath());
|
|
|
+ controller.saveFile(new File(fullPath).getAbsolutePath());
|
|
|
} catch (IOException | ArchiveException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -2362,6 +2364,7 @@ public class GUI implements CategoryListener {
|
|
|
private void menuUndoActionPerformed() {
|
|
|
try {
|
|
|
controller.loadAutoSave(controller.getUndoSave());
|
|
|
+ controller.calculateStateForCurrentTimeStep();
|
|
|
canvas.repaint();
|
|
|
|
|
|
repaintGraphAfterUndoRedo();
|
|
@@ -2381,6 +2384,7 @@ public class GUI implements CategoryListener {
|
|
|
private void menuRedoActionPerformed() {
|
|
|
try {
|
|
|
controller.loadAutoSave(controller.getRedoSave());
|
|
|
+ controller.calculateStateForCurrentTimeStep();
|
|
|
canvas.repaint();
|
|
|
|
|
|
repaintGraphAfterUndoRedo();
|