1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.GraphicsEnvironment;
|
---|
7 | import java.awt.event.KeyEvent;
|
---|
8 | import java.io.File;
|
---|
9 | import java.io.IOException;
|
---|
10 | import java.util.HashMap;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.Main;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * see PlatformHook.java
|
---|
16 | *
|
---|
17 | * BTW: THIS IS A STUB. See comments below for details.
|
---|
18 | *
|
---|
19 | * Don't write (Main.platform instanceof PlatformHookUnixoid) because other platform
|
---|
20 | * hooks are subclasses of this class.
|
---|
21 | */
|
---|
22 | public class PlatformHookUnixoid implements PlatformHook {
|
---|
23 | @Override
|
---|
24 | public void preStartupHook(){
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Override
|
---|
28 | public void startupHook() {
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public void openUrl(String url) throws IOException {
|
---|
33 | String[] programs = {"gnome-open", "kfmclient openURL", "firefox"};
|
---|
34 | for (String program : programs) {
|
---|
35 | try {
|
---|
36 | Runtime.getRuntime().exec(program+" "+url);
|
---|
37 | return;
|
---|
38 | } catch (IOException e) {
|
---|
39 | }
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | @Override
|
---|
44 | public void initSystemShortcuts() {
|
---|
45 | // TODO: Insert system shortcuts here. See Windows and especially OSX to see how to.
|
---|
46 | for(int i = KeyEvent.VK_F1; i <= KeyEvent.VK_F12; ++i)
|
---|
47 | Shortcut.registerSystemShortcut("screen:toogle"+i, tr("reserved"), i, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK).setAutomatic();
|
---|
48 | Shortcut.registerSystemShortcut("system:reset", tr("reserved"), KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK).setAutomatic();
|
---|
49 | Shortcut.registerSystemShortcut("system:resetX", tr("reserved"), KeyEvent.VK_BACK_SPACE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK).setAutomatic();
|
---|
50 | }
|
---|
51 | /**
|
---|
52 | * This should work for all platforms. Yeah, should.
|
---|
53 | * See PlatformHook.java for a list of reasons why
|
---|
54 | * this is implemented here...
|
---|
55 | */
|
---|
56 | @Override
|
---|
57 | public String makeTooltip(String name, Shortcut sc) {
|
---|
58 | String result = "";
|
---|
59 | result += "<html>";
|
---|
60 | result += name;
|
---|
61 | if (sc != null && sc.getKeyText().length() != 0) {
|
---|
62 | result += " ";
|
---|
63 | result += "<font size='-2'>";
|
---|
64 | result += "("+sc.getKeyText()+")";
|
---|
65 | result += "</font>";
|
---|
66 | }
|
---|
67 | result += " </html>";
|
---|
68 | return result;
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | public String getDefaultStyle() {
|
---|
73 | return "javax.swing.plaf.metal.MetalLookAndFeel";
|
---|
74 | }
|
---|
75 |
|
---|
76 | @Override
|
---|
77 | public boolean canFullscreen()
|
---|
78 | {
|
---|
79 | return GraphicsEnvironment.getLocalGraphicsEnvironment()
|
---|
80 | .getDefaultScreenDevice().isFullScreenSupported();
|
---|
81 | }
|
---|
82 |
|
---|
83 | @Override
|
---|
84 | public boolean rename(File from, File to)
|
---|
85 | {
|
---|
86 | return from.renameTo(to);
|
---|
87 | }
|
---|
88 | }
|
---|