source: josm/trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java@ 5299

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

fix last checkin

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.tools;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.GraphicsEnvironment;
7import java.awt.event.KeyEvent;
8import java.io.File;
9import java.io.IOException;
10import java.util.HashMap;
11
12import 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 */
22public 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 += "&nbsp;</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}
Note: See TracBrowser for help on using the repository browser.