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); 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() private void onTestClicked()
{ {
try try
@ -86,7 +101,7 @@ public class TranslationTool extends JFrame
String javaPath = "java"; String javaPath = "java";
String classPath = stringsModel.workingDirectory.toString() String classPath = stringsModel.workingDirectory.toString()
+ System.getProperty("path.separator") + System.getProperty("path.separator")
+ "micropolisj.jar"; + getMicropolisJarFile().toString();
ProcessBuilder processBuilder = ProcessBuilder processBuilder =
new ProcessBuilder(javaPath, new ProcessBuilder(javaPath,
@ -253,7 +268,7 @@ class StringsModel extends AbstractTableModel
throws IOException throws IOException
{ {
Properties p = new Properties(); 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]); String [] propNames = p.keySet().toArray(new String[0]);
Arrays.sort(propNames); Arrays.sort(propNames);