Commit 4807a7a0 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

remove TraCICmdHandler interface from CommandHandler class.

This is only a functional Interface
parent 5518b3b8
......@@ -44,6 +44,7 @@ VadereModelCalibration/**/output
VadereModelTests/**/legacy
VadereUtils/output/**
VadereModelTests/*_private
**/current_commit_hash.txt
# Operating system files
.DS_Store
......@@ -53,3 +54,7 @@ VadereModelTests/*_private
**/output/
**/legacy/
**/*_private/
# Vadere Cache
**/__cache__
**/vadere-server-output
\ No newline at end of file
package org.vadere.annotation.traci.client;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface TraCIApi {
String packageName() default "org.vadere.manager.client.traci";
String[] imports() default {
"org.vadere.manager.client.traci.TraCIClientApi",
"org.vadere.manager.TraCISocket",
"org.vadere.manager.traci.commands.TraCIGetCommand",
"org.vadere.manager.traci.commands.TraCISetCommand",
"org.vadere.manager.traci.respons.TraCIGetResponse",
"org.vadere.manager.traci.writer.TraCIPacket",
"org.vadere.manager.traci.respons.TraCIResponse",
"java.io.IOException",
"java.util.ArrayList"
};
String extendedClassName() default "TraCIClientApi";
String name();
Class singleAnnotation();
Class multipleAnnotation();
Class cmdEnum();
Class varEnum();
}
......@@ -81,7 +81,7 @@ public class ScenarioElementView extends JPanel implements ISelectScenarioElemen
Theme syntaxTheme = Theme.load(in);
syntaxTheme.apply(textAreaLocal);
} catch (IOException e) {
logger.error("could not load theme" + e.getMessage());
logger.error("could not loadFromFilesystem theme" + e.getMessage());
}
txtrTextfiletextarea = textAreaLocal;
......
......@@ -47,7 +47,7 @@ public abstract class ActionAbstractAddScenario extends AbstractAction {
return;
addScenario(vadere);
} catch (IOException e) {
logger.error(String.format("topographyError during output load: '%s'", e.getLocalizedMessage()));
logger.error(String.format("topographyError during output loadFromFilesystem: '%s'", e.getLocalizedMessage()));
}
} else {
IOUtils.errorBox(Messages.getString("renameErrorDialog.text"),
......
......@@ -4,15 +4,19 @@ package org.vadere.gui.projectview.control;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.gui.projectview.view.VDialogManager;
import org.vadere.simulator.projects.VadereProject;
import org.vadere.util.logging.Logger;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import javax.swing.*;
import static org.vadere.gui.projectview.control.ActionAbstractSaveProject.saveProjectUnlessUserCancels;
public class ActionCreateProject extends AbstractAction {
private static final long serialVersionUID = 1L;
......@@ -40,10 +44,16 @@ public class ActionCreateProject extends AbstractAction {
if (newProjectName == null || newProjectName.trim().length() == 0) {
logger.info("invalid project name");
} else {
VadereProject project = new VadereProject(newProjectName, new ArrayList<>());
model.setCurrentProjectPath(null);
final String projectDirectory= VDialogManager.saveProjectDialog();
if(projectDirectory == null)
return; // do not create project without saving it first.
VadereProject project = new VadereProject(newProjectName, new ArrayList<>(), Paths.get(projectDirectory));
model.setProject(project);
model.refreshOutputTable();
saveProjectUnlessUserCancels(model);
ProjectView.getMainWindow().setProjectSpecificActionsEnabled(true);
logger.info("create project: " + newProjectName);
}
......
......@@ -70,17 +70,17 @@ public class ActionLoadProject extends AbstractAction {
else {
migrationOptions = MigrationOptions.reapplyFromVersion((Version)option);
}
// 3. load project
// 3. loadFromFilesystem project
loadProjectByPath(model, projectFilePath, migrationOptions);
} else {
// 3. load project
// 3. loadFromFilesystem project
loadProjectByPath(model, projectFilePath);
}
} else {
logger.info(String.format("user canceled load project."));
logger.info(String.format("user canceled loadFromFilesystem project."));
}
} catch (IOException e1) {
e1.printStackTrace();
......@@ -109,13 +109,12 @@ public class ActionLoadProject extends AbstractAction {
public static void loadProjectByPath(ProjectViewModel projectViewModel, String projectFilePath, MigrationOptions options) {
try {
VadereProject project = IOVadere.readProjectJson(projectFilePath, options);
projectViewModel.setCurrentProjectPath(projectFilePath);
projectViewModel.setProject(project);
projectViewModel.refreshOutputTable();
logger.info("refreshed output table - 2");
// select and load first scenario from list
// select and loadFromFilesystem first scenario from list
projectViewModel.setSelectedRowIndexInScenarioTable(0);
logger.info("selected the first scenario");
......@@ -170,7 +169,7 @@ public class ActionLoadProject extends AbstractAction {
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage(), "JoltMigrationAssistant assistant",
JOptionPane.ERROR_MESSAGE);
logger.error("could not load project: " + e.getMessage());
logger.error("could not loadFromFilesystem project: " + e.getMessage());
e.printStackTrace();
}
}
......
package org.vadere.gui.projectview.control;
import javax.swing.*;
import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.gui.projectview.view.VTable;
import java.awt.event.ActionEvent;
import javax.swing.*;
public class ActionRunSelectedScenarios extends AbstractAction {
private final ProjectViewModel model;
......
package org.vadere.gui.projectview.model;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.projectview.control.IOutputFileRefreshListener;
import org.vadere.gui.projectview.control.IProjectChangeListener;
......@@ -16,6 +17,12 @@ import org.vadere.util.logging.Logger;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -29,7 +36,7 @@ public class ProjectViewModel implements IScenarioChecker {
private final OutputFileTableModel outputTableModel;
private final VadereScenarioTableModel scenarioTableModel;
private String currentProjectPath;
// private String currentProjectPath;
private ExecutorService refreshOutputExecutor;
......@@ -190,19 +197,19 @@ public class ProjectViewModel implements IScenarioChecker {
* been saved to disk yet.
*/
public String getCurrentProjectPath() {
return currentProjectPath;
return isProjectAvailable() ? project.getProjectDirectory().toAbsolutePath().toString() : null;
}
/**
* Set path of the directory where the project is saved. It may be null if the model have not
* been saved to disk yet.
*/
public void setCurrentProjectPath(final String currentProjectPath) {
if (currentProjectPath == null) {
this.currentProjectPath = null;
} else {
this.currentProjectPath = ProjectWriter.getProjectDir(currentProjectPath);
}
public void setCurrentProjectPath(@NotNull final String currentProjectPath) {
if (isProjectAvailable())
project.setProjectDirectory(Paths.get(currentProjectPath));
else
throw new IllegalStateException();
}
public OutputBundle getSelectedOutputBundle() throws IOException {
......
{
"name" : "Neues_Szenario",
"description" : "",
"release" : "1.1",
"release" : "1.2",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -169,6 +169,8 @@
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"cacheType" : "NO_CACHE",
"cacheDir" : "",
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "UNIT",
......
package org.vadere.gui.vadere;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.LinkedList;
import java.util.stream.Collectors;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.junit.BeforeClass;
import org.junit.Test;
import org.vadere.simulator.models.osm.OptimalStepsModel;
......@@ -29,6 +18,18 @@ import org.vadere.state.attributes.models.AttributesPotentialOSM;
import org.vadere.state.scenario.Topography;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.LinkedList;
import java.util.stream.Collectors;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import static org.junit.Assert.assertEquals;
public class TestProjectWriterAndReader {
private static VadereProject testProject;
......@@ -49,7 +50,7 @@ public class TestProjectWriterAndReader {
tests.add(new Scenario(new ScenarioStore(testName + "1", "", OptimalStepsModel.class.getName(), attributes, new AttributesSimulation(), new Topography())));
tests.add(new Scenario(new ScenarioStore(testName + "2", "", OptimalStepsModel.class.getName(), attributes, new AttributesSimulation(), new Topography())));
tests.add(new Scenario(new ScenarioStore(testName + "3", "", OptimalStepsModel.class.getName(), attributes, new AttributesSimulation(), new Topography())));
testProject = new VadereProject(testProjectName, tests);
testProject = new VadereProject(testProjectName, tests, Paths.get("."));
}
/**
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>vadere</artifactId>
<groupId>org.vadere</groupId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manager</artifactId>
<name>Vadere Manager</name>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>tests</testSourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>testResources</directory>
</testResource>
<testResource>
<directory>tests</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>com.nativelibs4java</groupId>
<artifactId>maven-javacl-plugin</artifactId>
<version>1.0.0-RC4</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>write-version-control-info-to-file</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<!-- Write a file with current version of Vadere to get reproducible simulations. -->
<configuration>
<executable>git</executable>
<arguments>
<argument>rev-parse</argument>
<argument>HEAD</argument>
</arguments>
<outputFile>resources/current_commit_hash.txt</outputFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler.version}</version>
<configuration>
<source>${maven-compiler.source.version}</source>
<target>${maven-compiler.target.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.vadere</groupId>
<artifactId>annotation</artifactId>
<version>0.1-SNAPSHOT</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<!-- Use default groupId "org.apache.maven.plugins" -->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>build-vadere-console</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>org.vadere.simulator.entrypoints.cmd.VadereConsole</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>vadere-console</finalName>
<appendAssemblyId>false</appendAssemblyId>
<attach>false</attach>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- Use default groupId "org.apache.maven.plugins" -->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>build-vadere-server</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>org.vadere.manager.Manager</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>vadere-server</finalName>
<appendAssemblyId>false</appendAssemblyId>