source: osm/applications/editors/josm/plugins/restart/src/josmrestartplugin/RestartJosmAction.java@ 25159

Last change on this file since 25159 was 24193, checked in by upliner, 15 years ago

Add restart plugin

File size: 1.5 KB
Line 
1package josmrestartplugin;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
4
5import java.awt.event.ActionEvent;
6import java.awt.event.KeyEvent;
7import java.io.File;
8
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.actions.JosmAction;
11import org.openstreetmap.josm.tools.PlatformHookWindows;
12import org.openstreetmap.josm.tools.Shortcut;
13
14public class RestartJosmAction extends JosmAction {
15
16 public RestartJosmAction() {
17 super(tr("Restart JOSM"), null, tr("Restart JOSM"),
18 Shortcut.registerShortcut("file:restart",
19 tr("File: {0}", tr("Restart JOSM")),
20 KeyEvent.VK_R, Shortcut.GROUP_MENU),
21 true);
22 }
23
24 public void actionPerformed(ActionEvent arg0) {
25 if (!Main.exitJosm(false)) return;
26 try {
27 File jarfile = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI());
28 long memmax = Runtime.getRuntime().maxMemory();
29 String javacmd = "java";
30 if (Main.platform instanceof PlatformHookWindows) javacmd = "javaw";
31 String[] cmds = new String[] {
32 javacmd,
33 "-Xmx" + memmax,
34 "-jar",
35 jarfile.getAbsolutePath()
36 };
37 for (String s : cmds)
38 System.out.print(s + " ");
39 System.out.println();
40
41 Runtime.getRuntime().exec(cmds);
42 } catch (Exception e) {
43 e.printStackTrace();
44 }
45 System.exit(0);
46 }
47}
Note: See TracBrowser for help on using the repository browser.