001 // License: GPL. Copyright 2007 by Immanuel Scholz and others 002 package org.openstreetmap.josm.tools; 003 004 import static org.openstreetmap.josm.tools.I18n.tr; 005 006 import java.awt.GraphicsEnvironment; 007 import java.awt.event.KeyEvent; 008 import java.io.File; 009 import java.io.IOException; 010 import java.util.HashMap; 011 012 import org.openstreetmap.josm.Main; 013 014 /** 015 * see PlatformHook.java 016 * 017 * BTW: THIS IS A STUB. See comments below for details. 018 * 019 * Don't write (Main.platform instanceof PlatformHookUnixoid) because other platform 020 * hooks are subclasses of this class. 021 */ 022 public class PlatformHookUnixoid implements PlatformHook { 023 @Override 024 public void preStartupHook(){ 025 } 026 027 @Override 028 public void startupHook() { 029 } 030 031 @Override 032 public void openUrl(String url) throws IOException { 033 String[] programs = {"gnome-open", "kfmclient openURL", "firefox"}; 034 for (String program : programs) { 035 try { 036 Runtime.getRuntime().exec(program+" "+url); 037 return; 038 } catch (IOException e) { 039 } 040 } 041 } 042 043 @Override 044 public void initSystemShortcuts() { 045 // TODO: Insert system shortcuts here. See Windows and especially OSX to see how to. 046 for(int i = KeyEvent.VK_F1; i <= KeyEvent.VK_F12; ++i) 047 Shortcut.registerSystemShortcut("screen:toogle"+i, tr("reserved"), i, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK).setAutomatic(); 048 Shortcut.registerSystemShortcut("system:reset", tr("reserved"), KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK).setAutomatic(); 049 Shortcut.registerSystemShortcut("system:resetX", tr("reserved"), KeyEvent.VK_BACK_SPACE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK).setAutomatic(); 050 } 051 /** 052 * This should work for all platforms. Yeah, should. 053 * See PlatformHook.java for a list of reasons why 054 * this is implemented here... 055 */ 056 @Override 057 public String makeTooltip(String name, Shortcut sc) { 058 String result = ""; 059 result += "<html>"; 060 result += name; 061 if (sc != null && sc.getKeyText().length() != 0) { 062 result += " "; 063 result += "<font size='-2'>"; 064 result += "("+sc.getKeyText()+")"; 065 result += "</font>"; 066 } 067 result += " </html>"; 068 return result; 069 } 070 071 @Override 072 public String getDefaultStyle() { 073 return "javax.swing.plaf.metal.MetalLookAndFeel"; 074 } 075 076 @Override 077 public boolean canFullscreen() 078 { 079 return GraphicsEnvironment.getLocalGraphicsEnvironment() 080 .getDefaultScreenDevice().isFullScreenSupported(); 081 } 082 083 @Override 084 public boolean rename(File from, File to) 085 { 086 return from.renameTo(to); 087 } 088 }