translation-tool: allow running from any working directory

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@666 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-05-21 13:29:42 +00:00
parent ac980de693
commit 88e9186ca1

View file

@ -79,6 +79,21 @@ public class TranslationTool extends JFrame
setLocationRelativeTo(null);
}
private File getMicropolisJarFile()
{
try{
Class mclass = micropolisj.engine.Micropolis.class;
return new File(
mclass.getProtectionDomain()
.getCodeSource().getLocation().toURI().getPath()
);
} catch (java.net.URISyntaxException e) {
throw new Error("unexpected: "+e, e);
}
}
private void onTestClicked()
{
try
@ -86,7 +101,7 @@ public class TranslationTool extends JFrame
String javaPath = "java";
String classPath = stringsModel.workingDirectory.toString()
+ System.getProperty("path.separator")
+ "micropolisj.jar";
+ getMicropolisJarFile().toString();
ProcessBuilder processBuilder =
new ProcessBuilder(javaPath,
@ -253,7 +268,7 @@ class StringsModel extends AbstractTableModel
throws IOException
{
Properties p = new Properties();
p.load(new FileInputStream("strings/"+file+".properties"));
p.load(StringsModel.class.getResourceAsStream("/micropolisj/"+file+".properties"));
String [] propNames = p.keySet().toArray(new String[0]);
Arrays.sort(propNames);