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

Last change on this file since 27852 was 27852, checked in by stoecker, 12 years ago

fix shortcut deprecation

File size: 1.6 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_J, Shortcut.ALT_CTRL_SHIFT),
21 false);
22 putValue("toolbar", "action/restart");
23 Main.toolbar.register(this);
24 }
25
26 public void actionPerformed(ActionEvent arg0) {
27 if (!Main.exitJosm(false)) return;
28 try {
29 File jarfile = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI());
30 long memmax = Runtime.getRuntime().maxMemory();
31 String javacmd = "java";
32 if (Main.platform instanceof PlatformHookWindows) javacmd = "javaw";
33 String[] cmds = new String[] {
34 javacmd,
35 "-Xmx" + memmax,
36 "-jar",
37 jarfile.getAbsolutePath()
38 };
39 for (String s : cmds)
40 System.out.print(s + " ");
41 System.out.println();
42
43 Runtime.getRuntime().exec(cmds);
44 } catch (Exception e) {
45 e.printStackTrace();
46 }
47 System.exit(0);
48 }
49}
Note: See TracBrowser for help on using the repository browser.