Commit 33f18144 authored by Nico Mack's avatar Nico Mack

Added scenario filename and modification date to about section

parent 1a71db6d
<html>
<h1>${Title}</h1>
<p>${Description}</p>
<p>Version : ${Version}</p>
<p>Version : <b>${Version}</b> <i>Current Scenario : <b>${Filename}</b> (${LastModified})</i></p>
<hr>
<h2>Installed Tulip Packages</h2>
<p>${Packages}</p>
......
BUILD_DATE=BuildDate
BUILD_NUMBER=BuildNumber
DESCRIPTION=Description
FILE_NAME=Filename
LAST_MODIFIED=LastModified
NAME=Name
TITLE=Title
PACKAGES=Packages
......
......@@ -53,11 +53,13 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Area;
import java.awt.geom.Line2D;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -126,6 +128,7 @@ public class TangibleInterfaceManager extends Stage {
private static final String ABOUT_HTML_TEMPLATE = "about.html";
private static final String PACKAGE_HTML_TEMPLATE = "package.html";
private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\$\\{([a-z0-9\\-_]+)\\}", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
private static final Pattern URI_PATTERN = Pattern.compile("^file:(.*?)$", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
// ---------------------------------------------------------------------------
// ***************************************************************************
......@@ -172,6 +175,16 @@ public class TangibleInterfaceManager extends Stage {
private Map<String, Object> readAbout() {
Map<String, Object> about = new HashMap<>();
Element rootNode = bootstrap.getRootElement();
Matcher uriMatcher = URI_PATTERN.matcher(bootstrap.getBaseURI());
if (uriMatcher.matches()) {
File scenario = new File(uriMatcher.group(1));
if (scenario.exists() && scenario.isFile()) {
about.put(About.FILE_NAME, scenario.getName());
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); //$NON-NLS-1$
about.put(About.LAST_MODIFIED, dateFormat.format(scenario.lastModified()));
}
}
List<Element> aboutNodes = rootNode.getChildren(Externalization.ABOUT_NODE);
if ((aboutNodes != null) && (aboutNodes.size() == 1)) {
Element aboutNode = aboutNodes.get(0);
......
......@@ -36,6 +36,8 @@ public class About extends NLS {
public static String BUILD_DATE;
public static String BUILD_NUMBER;
public static String DESCRIPTION;
public static String FILE_NAME;
public static String LAST_MODIFIED;
public static String NAME;
public static String TITLE;
public static String PACKAGES;
......
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