Commit 8948b6fb authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Merge branch 'save_current_project'

parents 8cf7c11e ec2b615d
Pipeline #98662 failed with stages
in 151 minutes and 13 seconds
...@@ -2,16 +2,19 @@ package org.vadere.gui.projectview.control; ...@@ -2,16 +2,19 @@ package org.vadere.gui.projectview.control;
import org.vadere.gui.components.utils.Messages; import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.projectview.VadereApplication;
import org.vadere.gui.projectview.model.ProjectViewModel; import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.gui.projectview.utils.ApplicationWriter; import org.vadere.gui.projectview.utils.ApplicationWriter;
import org.vadere.gui.projectview.view.VDialogManager; import org.vadere.gui.projectview.view.VDialogManager;
import org.vadere.util.io.IOUtils; import org.vadere.util.io.IOUtils;
import org.vadere.util.logging.Logger; import org.vadere.util.logging.Logger;
import javax.swing.*;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.TreeSet;
import java.util.prefs.BackingStoreException; import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import javax.swing.*;
public abstract class ActionAbstractSaveProject extends AbstractAction { public abstract class ActionAbstractSaveProject extends AbstractAction {
...@@ -99,6 +102,7 @@ public abstract class ActionAbstractSaveProject extends AbstractAction { ...@@ -99,6 +102,7 @@ public abstract class ActionAbstractSaveProject extends AbstractAction {
model.getProject().saveChanges(); model.getProject().saveChanges();
model.refreshScenarioNames(); model.refreshScenarioNames();
logger.info("save project"); logger.info("save project");
updateRecentProjectPreferences(model);
} catch (IOException e) { } catch (IOException e) {
IOUtils.errorBox( IOUtils.errorBox(
Messages.getString("SaveFileErrorMessage.text") + System.lineSeparator() Messages.getString("SaveFileErrorMessage.text") + System.lineSeparator()
...@@ -113,6 +117,16 @@ public abstract class ActionAbstractSaveProject extends AbstractAction { ...@@ -113,6 +117,16 @@ public abstract class ActionAbstractSaveProject extends AbstractAction {
} }
} }
private static void updateRecentProjectPreferences(ProjectViewModel model) {
Preferences preferences = Preferences.userNodeForPackage(VadereApplication.class);
final String key = "recent_projects";
final TreeSet<String> values = new TreeSet(Arrays.asList(preferences.get(key, "").split(",")));
values.add(model.getCurrentProjectPath());
String value = values.stream().reduce("", (a, b) -> a + "," + b);
System.out.println(values.toString());
preferences.put(key, value.replaceFirst(",", ""));
}
static void savePreferences() throws IOException, BackingStoreException { static void savePreferences() throws IOException, BackingStoreException {
ApplicationWriter.savePreferences(); ApplicationWriter.savePreferences();
logger.info("save preferences"); logger.info("save preferences");
......
...@@ -333,7 +333,7 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing ...@@ -333,7 +333,7 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
closeApplicationAction.actionPerformed(null); closeApplicationAction.actionPerformed(null);
} }
}); });
Preferences pref = Preferences.userNodeForPackage(VadereApplication.class);
pack(); pack();
} }
...@@ -365,7 +365,7 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing ...@@ -365,7 +365,7 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
JMenuItem mntmLoadProject = new JMenuItem(loadProjectAction); JMenuItem mntmLoadProject = new JMenuItem(loadProjectAction);
mntmRecentProjects = new JMenu(Messages.getString("ProjectView.mntmRecentProjects.text")); mntmRecentProjects = new JMenu(Messages.getString("ProjectView.mntmRecentProjects.text"));
mntmRecentProjects.setEnabled(false); mntmRecentProjects.setEnabled(true);
updateRecentProjectsMenu(); updateRecentProjectsMenu();
Action changeNameAction = new ActionRenameProject(Messages.getString("ProjectView.mntmChangeName.text"), model); Action changeNameAction = new ActionRenameProject(Messages.getString("ProjectView.mntmChangeName.text"), model);
...@@ -535,6 +535,7 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing ...@@ -535,6 +535,7 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
model.setCurrentScenario(bundle.getScenario()); model.setCurrentScenario(bundle.getScenario());
logger.info(String.format("selected scenario '%s'", bundle.getScenario().getName())); logger.info(String.format("selected scenario '%s'", bundle.getScenario().getName()));
scenarioJPanel.setScenario(bundle.getScenario(), true); scenarioJPanel.setScenario(bundle.getScenario(), true);
outputTableRenderer.setMarkedOutputFiles(bundle.getOutputDirectories()); outputTableRenderer.setMarkedOutputFiles(bundle.getOutputDirectories());
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"name" : "basic_1_chicken_gnm1", "name" : "basic_1_chicken_gnm1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ ], "files" : [ ],
"processors" : [ ], "processors" : [ ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel", "mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
...@@ -118,6 +118,7 @@ ...@@ -118,6 +118,7 @@
"startingWithRedLight" : false, "startingWithRedLight" : false,
"nextSpeed" : -1.0 "nextSpeed" : -1.0
} ], } ],
"absorbingAreas" : [ ],
"sources" : [ { "sources" : [ {
"id" : -1, "id" : -1,
"shape" : { "shape" : {
...@@ -139,6 +140,7 @@ ...@@ -139,6 +140,7 @@
"groupSizeDistribution" : [ 1.0 ], "groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN" "dynamicElementType" : "PEDESTRIAN"
} ], } ],
"dynamicElements" : [ ],
"attributesPedestrian" : { "attributesPedestrian" : {
"radius" : 0.195, "radius" : 0.195,
"densityDependentSpeed" : false, "densityDependentSpeed" : false,
...@@ -148,8 +150,9 @@ ...@@ -148,8 +150,9 @@
"maximumSpeed" : 2.2, "maximumSpeed" : 2.2,
"acceleration" : 2.0 "acceleration" : 2.0
}, },
"attributesCar" : null, "teleporter" : null,
"dynamicElements" : [ ] "attributesCar" : null
} },
"eventInfos" : [ ]
} }
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"name" : "basic_1_chicken_gnm1_displaced", "name" : "basic_1_chicken_gnm1_displaced",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ ], "files" : [ ],
"processors" : [ ], "processors" : [ ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel", "mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
...@@ -118,6 +118,7 @@ ...@@ -118,6 +118,7 @@
"startingWithRedLight" : false, "startingWithRedLight" : false,
"nextSpeed" : -1.0 "nextSpeed" : -1.0
} ], } ],
"absorbingAreas" : [ ],
"sources" : [ { "sources" : [ {
"id" : -1, "id" : -1,
"shape" : { "shape" : {
...@@ -139,6 +140,7 @@ ...@@ -139,6 +140,7 @@
"groupSizeDistribution" : [ 1.0 ], "groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN" "dynamicElementType" : "PEDESTRIAN"
} ], } ],
"dynamicElements" : [ ],
"attributesPedestrian" : { "attributesPedestrian" : {
"radius" : 0.195, "radius" : 0.195,
"densityDependentSpeed" : false, "densityDependentSpeed" : false,
...@@ -148,8 +150,9 @@ ...@@ -148,8 +150,9 @@
"maximumSpeed" : 2.2, "maximumSpeed" : 2.2,
"acceleration" : 2.0 "acceleration" : 2.0
}, },
"attributesCar" : null, "teleporter" : null,
"dynamicElements" : [ ] "attributesCar" : null
} },
"eventInfos" : [ ]
} }
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"name" : "basic_1_chicken_gnm2", "name" : "basic_1_chicken_gnm2",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ ], "files" : [ ],
"processors" : [ ], "processors" : [ ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel", "mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
...@@ -118,6 +118,7 @@ ...@@ -118,6 +118,7 @@
"startingWithRedLight" : false, "startingWithRedLight" : false,
"nextSpeed" : -1.0 "nextSpeed" : -1.0
} ], } ],
"absorbingAreas" : [ ],
"sources" : [ { "sources" : [ {
"id" : -1, "id" : -1,
"shape" : { "shape" : {
...@@ -139,6 +140,7 @@ ...@@ -139,6 +140,7 @@
"groupSizeDistribution" : [ 1.0 ], "groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN" "dynamicElementType" : "PEDESTRIAN"
} ], } ],
"dynamicElements" : [ ],
"attributesPedestrian" : { "attributesPedestrian" : {
"radius" : 0.195, "radius" : 0.195,
"densityDependentSpeed" : false, "densityDependentSpeed" : false,
...@@ -148,8 +150,9 @@ ...@@ -148,8 +150,9 @@
"maximumSpeed" : 2.2, "maximumSpeed" : 2.2,
"acceleration" : 2.0 "acceleration" : 2.0
}, },
"attributesCar" : null, "teleporter" : null,
"dynamicElements" : [ ] "attributesCar" : null
} },
"eventInfos" : [ ]
} }
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"name" : "basic_2_density_gnm1", "name" : "basic_2_density_gnm1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ ], "files" : [ ],
"processors" : [ ], "processors" : [ ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel", "mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
...@@ -127,6 +127,7 @@ ...@@ -127,6 +127,7 @@
"startingWithRedLight" : false, "startingWithRedLight" : false,
"nextSpeed" : -1.0 "nextSpeed" : -1.0
} ], } ],
"absorbingAreas" : [ ],
"sources" : [ { "sources" : [ {
"id" : -1, "id" : -1,
"shape" : { "shape" : {
...@@ -148,6 +149,7 @@ ...@@ -148,6 +149,7 @@
"groupSizeDistribution" : [ 1.0 ], "groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN" "dynamicElementType" : "PEDESTRIAN"
} ], } ],
"dynamicElements" : [ ],
"attributesPedestrian" : { "attributesPedestrian" : {
"radius" : 0.195, "radius" : 0.195,
"densityDependentSpeed" : false, "densityDependentSpeed" : false,
...@@ -157,8 +159,9 @@ ...@@ -157,8 +159,9 @@
"maximumSpeed" : 2.2, "maximumSpeed" : 2.2,
"acceleration" : 2.0 "acceleration" : 2.0
}, },
"attributesCar" : null, "teleporter" : null,
"dynamicElements" : [ ] "attributesCar" : null
} },
"eventInfos" : [ ]
} }
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"name" : "basic_3_1_wall_gnm1", "name" : "basic_3_1_wall_gnm1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ ], "files" : [ ],
"processors" : [ ], "processors" : [ ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel", "mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
"startingWithRedLight" : false, "startingWithRedLight" : false,
"nextSpeed" : -1.0 "nextSpeed" : -1.0
} ], } ],
"absorbingAreas" : [ ],
"sources" : [ { "sources" : [ {
"id" : -1, "id" : -1,
"shape" : { "shape" : {
...@@ -121,6 +122,7 @@ ...@@ -121,6 +122,7 @@
"groupSizeDistribution" : [ 1.0 ], "groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN" "dynamicElementType" : "PEDESTRIAN"
} ], } ],
"dynamicElements" : [ ],
"attributesPedestrian" : { "attributesPedestrian" : {
"radius" : 0.195, "radius" : 0.195,
"densityDependentSpeed" : false, "densityDependentSpeed" : false,
...@@ -130,8 +132,9 @@ ...@@ -130,8 +132,9 @@
"maximumSpeed" : 2.2, "maximumSpeed" : 2.2,
"acceleration" : 2.0 "acceleration" : 2.0
}, },
"attributesCar" : null, "teleporter" : null,
"dynamicElements" : [ ] "attributesCar" : null
} },
"eventInfos" : [ ]
} }
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"name" : "basic_3_2_wall_gnm1", "name" : "basic_3_2_wall_gnm1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ ], "files" : [ ],
"processors" : [ ], "processors" : [ ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel", "mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
"startingWithRedLight" : false, "startingWithRedLight" : false,
"nextSpeed" : -1.0 "nextSpeed" : -1.0
} ], } ],
"absorbingAreas" : [ ],
"sources" : [ { "sources" : [ {
"id" : -1, "id" : -1,
"shape" : { "shape" : {
...@@ -121,6 +122,7 @@ ...@@ -121,6 +122,7 @@
"groupSizeDistribution" : [ 1.0 ], "groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN" "dynamicElementType" : "PEDESTRIAN"
} ], } ],
"dynamicElements" : [ ],
"attributesPedestrian" : { "attributesPedestrian" : {
"radius" : 0.195, "radius" : 0.195,
"densityDependentSpeed" : false, "densityDependentSpeed" : false,
...@@ -130,8 +132,9 @@ ...@@ -130,8 +132,9 @@
"maximumSpeed" : 2.2, "maximumSpeed" : 2.2,
"acceleration" : 2.0 "acceleration" : 2.0
}, },
"attributesCar" : null, "teleporter" : null,
"dynamicElements" : [ ] "attributesCar" : null
} },
"eventInfos" : [ ]
} }
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"name" : "basic_3_3_wall_gnm1", "name" : "basic_3_3_wall_gnm1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ ], "files" : [ ],
"processors" : [ ], "processors" : [ ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel", "mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
"startingWithRedLight" : false, "startingWithRedLight" : false,
"nextSpeed" : -1.0 "nextSpeed" : -1.0
} ], } ],
"absorbingAreas" : [ ],
"sources" : [ { "sources" : [ {
"id" : -1, "id" : -1,
"shape" : { "shape" : {
...@@ -121,6 +122,7 @@ ...@@ -121,6 +122,7 @@
"groupSizeDistribution" : [ 1.0 ], "groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN" "dynamicElementType" : "PEDESTRIAN"
} ], } ],
"dynamicElements" : [ ],
"attributesPedestrian" : { "attributesPedestrian" : {
"radius" : 0.195, "radius" : 0.195,
"densityDependentSpeed" : false, "densityDependentSpeed" : false,
...@@ -130,8 +132,9 @@ ...@@ -130,8 +132,9 @@
"maximumSpeed" : 2.2, "maximumSpeed" : 2.2,
"acceleration" : 2.0 "acceleration" : 2.0
}, },
"attributesCar" : null, "teleporter" : null,
"dynamicElements" : [ ] "attributesCar" : null
} },
"eventInfos" : [ ]
} }
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"name" : "basic_4_1_wall_gnm1", "name" : "basic_4_1_wall_gnm1",
"description" : "", "description" : "",
"release" : "0.7", "release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : { "processWriters" : {
"files" : [ ], "files" : [ ],
"processors" : [ ], "processors" : [ ],
"isTimestamped" : true "isTimestamped" : true,
"isWriteMetaData" : false
}, },
"scenario" : { "scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel", "mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
"startingWithRedLight" : false, "startingWithRedLight" : false,
"nextSpeed" : -1.0 "nextSpeed" : -1.0
} ], } ],
"absorbingAreas" : [ ],
"sources" : [ { "sources" : [ {
"id" : -1, "id" : -1,
"shape" : { "shape" : {
...@@ -121,6 +122,7 @@ ...@@ -121,6 +122,7 @@
"groupSizeDistribution" : [ 1.0 ], "groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN" "dynamicElementType" : "PEDESTRIAN"
} ], } ],
"dynamicElements" : [ ],
"attributesPedestrian" : { "attributesPedestrian" : {
"radius" : 0.195, "radius" : 0.195,
"densityDependentSpeed" : false, "densityDependentSpeed" : false,
...@@ -130,8 +132,9 @@ ...@@ -130,8 +132,9 @@
"maximumSpeed" : 2.2, "maximumSpeed" : 2.2,
"acceleration" : 2.0 "acceleration" : 2.0
}, },
"attributesCar" : null, "teleporter" : null,
"dynamicElements" : [ ] "attributesCar" : null
} },
"eventInfos" : [ ]
} }
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"name" : "basic_4_2_wall_gnm1", "name" : "basic_4_2_wall_gnm1",