Commit 2067f205 authored by Nico Mack's avatar Nico Mack

Improved lookup of scenario file in about section

parent 26c74233
...@@ -59,6 +59,9 @@ import java.io.InputStreamReader; ...@@ -59,6 +59,9 @@ import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -175,16 +178,16 @@ public class TangibleInterfaceManager extends Stage { ...@@ -175,16 +178,16 @@ public class TangibleInterfaceManager extends Stage {
private Map<String, Object> readAbout() { private Map<String, Object> readAbout() {
Map<String, Object> about = new HashMap<>(); Map<String, Object> about = new HashMap<>();
Element rootNode = bootstrap.getRootElement(); Element rootNode = bootstrap.getRootElement();
Matcher uriMatcher = URI_PATTERN.matcher(bootstrap.getBaseURI()); try {
if (uriMatcher.matches()) { URL url = new URL(bootstrap.getBaseURI());
File scenario = new File(uriMatcher.group(1)); File scenario = new File(url.toURI());
if (scenario.exists() && scenario.isFile()) { if (scenario.exists() && scenario.isFile()) {
about.put(About.FILE_NAME, scenario.getName()); about.put(About.FILE_NAME, scenario.getName());
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); //$NON-NLS-1$ SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); //$NON-NLS-1$
about.put(About.LAST_MODIFIED, dateFormat.format(scenario.lastModified())); about.put(About.LAST_MODIFIED, dateFormat.format(scenario.lastModified()));
} else {
LOGGER.warn("Unable to locate scenario file {}!", uriMatcher.group(1));
} }
} catch (MalformedURLException | URISyntaxException e) {
LOGGER.warn("Unable to locate scenario file {}!", bootstrap.getBaseURI()); //$NON-NLS-1$
} }
List<Element> aboutNodes = rootNode.getChildren(Externalization.ABOUT_NODE); List<Element> aboutNodes = rootNode.getChildren(Externalization.ABOUT_NODE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment