Commit 7bd2e58d authored by Timy Phan's avatar Timy Phan

added update recent_projects preferences

parent 26068c1e
Pipeline #98160 failed with stages
in 48 seconds
......@@ -2,16 +2,19 @@ package org.vadere.gui.projectview.control;
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.utils.ApplicationWriter;
import org.vadere.gui.projectview.view.VDialogManager;
import org.vadere.util.io.IOUtils;
import org.vadere.util.logging.Logger;
import javax.swing.*;
import java.io.IOException;
import java.util.Arrays;
import java.util.TreeSet;
import java.util.prefs.BackingStoreException;
import javax.swing.*;
import java.util.prefs.Preferences;
public abstract class ActionAbstractSaveProject extends AbstractAction {
......@@ -99,6 +102,7 @@ public abstract class ActionAbstractSaveProject extends AbstractAction {
model.getProject().saveChanges();
model.refreshScenarioNames();
logger.info("save project");
updateRecentProjectPreferences(model);
} catch (IOException e) {
IOUtils.errorBox(
Messages.getString("SaveFileErrorMessage.text") + System.lineSeparator()
......@@ -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 {
ApplicationWriter.savePreferences();
logger.info("save preferences");
......
......@@ -5,34 +5,7 @@ import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.postvisualization.control.Player;
import org.vadere.gui.projectview.VadereApplication;
import org.vadere.gui.projectview.control.ActionAddScenario;
import org.vadere.gui.projectview.control.ActionCloneScenario;
import org.vadere.gui.projectview.control.ActionCloseApplication;
import org.vadere.gui.projectview.control.ActionCreateProject;
import org.vadere.gui.projectview.control.ActionDeleteOutputDirectories;
import org.vadere.gui.projectview.control.ActionDeleteScenarios;
import org.vadere.gui.projectview.control.ActionEditScenarioDescription;
import org.vadere.gui.projectview.control.ActionGenerateScenarioFromOutputFile;
import org.vadere.gui.projectview.control.ActionInterruptScenarios;
import org.vadere.gui.projectview.control.ActionLoadProject;
import org.vadere.gui.projectview.control.ActionLoadRecentProject;
import org.vadere.gui.projectview.control.ActionOpenInExplorer;
import org.vadere.gui.projectview.control.ActionOutputToScenario;
import org.vadere.gui.projectview.control.ActionPauseScenario;
import org.vadere.gui.projectview.control.ActionRenameOutputFile;
import org.vadere.gui.projectview.control.ActionRenameProject;
import org.vadere.gui.projectview.control.ActionRenameScenario;
import org.vadere.gui.projectview.control.ActionRunAllScenarios;
import org.vadere.gui.projectview.control.ActionRunOutput;
import org.vadere.gui.projectview.control.ActionRunSelectedScenarios;
import org.vadere.gui.projectview.control.ActionSaveAsProject;
import org.vadere.gui.projectview.control.ActionSaveProject;
import org.vadere.gui.projectview.control.ActionSeeDiscardChanges;
import org.vadere.gui.projectview.control.ActionShowAboutDialog;
import org.vadere.gui.projectview.control.ActionToClipboard;
import org.vadere.gui.projectview.control.IOutputFileRefreshListener;
import org.vadere.gui.projectview.control.IProjectChangeListener;
import org.vadere.gui.projectview.control.ShowResultDialogAction;
import org.vadere.gui.projectview.control.*;
import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.gui.projectview.model.ProjectViewModel.OutputBundle;
import org.vadere.gui.projectview.model.ProjectViewModel.ScenarioBundle;
......@@ -47,6 +20,9 @@ import org.vadere.util.io.IOUtils;
import org.vadere.util.logging.Logger;
import org.vadere.util.opencl.CLUtils;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ListSelectionEvent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
......@@ -61,10 +37,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.prefs.Preferences;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ListSelectionEvent;
/**
* Main view of the Vadere GUI.
*
......@@ -354,7 +326,7 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
closeApplicationAction.actionPerformed(null);
}
});
Preferences pref = Preferences.userNodeForPackage(VadereApplication.class);
pack();
}
......@@ -376,7 +348,7 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
JMenuItem mntmLoadProject = new JMenuItem(loadProjectAction);
mntmRecentProjects = new JMenu(Messages.getString("ProjectView.mntmRecentProjects.text"));
mntmRecentProjects.setEnabled(false);
mntmRecentProjects.setEnabled(true);
updateRecentProjectsMenu();
Action changeNameAction = new ActionRenameProject(Messages.getString("ProjectView.mntmChangeName.text"), model);
......@@ -546,6 +518,7 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
model.setCurrentScenario(bundle.getScenario());
logger.info(String.format("selected scenario '%s'", bundle.getScenario().getName()));
scenarioJPanel.setScenario(bundle.getScenario(), true);
outputTableRenderer.setMarkedOutputFiles(bundle.getOutputDirectories());
......
......@@ -2,11 +2,11 @@
"name" : "basic_1_chicken_gnm1",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -118,6 +118,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -139,6 +140,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -148,8 +150,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "basic_1_chicken_gnm1_displaced",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -118,6 +118,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -139,6 +140,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -148,8 +150,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "basic_1_chicken_gnm2",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -118,6 +118,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -139,6 +140,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -148,8 +150,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "basic_2_density_gnm1",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -127,6 +127,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -148,6 +149,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -157,8 +159,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "basic_3_1_wall_gnm1",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -100,6 +100,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -121,6 +122,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -130,8 +132,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "basic_3_2_wall_gnm1",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -100,6 +100,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -121,6 +122,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -130,8 +132,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "basic_3_3_wall_gnm1",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -100,6 +100,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -121,6 +122,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -130,8 +132,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "basic_4_1_wall_gnm1",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -100,6 +100,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -121,6 +122,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -130,8 +132,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "basic_4_2_wall_gnm1",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -58,7 +58,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......@@ -100,6 +100,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -121,6 +122,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -130,8 +132,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "rimea_01_pathway_gnm1",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -91,6 +91,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -112,6 +113,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -121,8 +123,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "rimea_04_flow_gnm1_025_h",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -91,6 +91,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -112,6 +113,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -121,8 +123,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "rimea_04_flow_gnm1_050_h",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -91,6 +91,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -112,6 +113,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -121,8 +123,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name" : "rimea_04_flow_gnm1_075_h",
"description" : "",
"release" : "0.7",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ ],
"processors" : [ ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.gnm.GradientNavigationModel",
......@@ -91,6 +91,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
......@@ -112,6 +113,7 @@
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -121,8 +123,9 @@
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null,
"dynamicElements" : [ ]
}
"teleporter" : null,
"attributesCar" : null
},
"eventInfos" : [ ]
}
}
\ No newline at end of file