001 // License: GPL. Copyright 2007 by Immanuel Scholz and others 002 package org.openstreetmap.josm.tools; 003 004 import java.io.File; 005 import java.io.IOException; 006 import java.util.HashMap; 007 008 /** 009 * This interface allows platfrom (operating system) dependent code 010 * to be bundled into self-contained classes. 011 * 012 * For plugin authors: 013 * To implement your own PlatformHook class, implement this interface, 014 * then create the class when your plugin is loaded and store it in 015 * Main.platform. Please not that the two "startup" hooks will be 016 * called _before_ your plugin is loaded. If you need to hook there, 017 * split your class into two (one containing only the startup hooks, 018 * and one with the remainder) and send the startup class, together 019 * with propper OS detection code (see Main) for inclusion with 020 * JOSM to the JOSM team. 021 * 022 * Also, it might be a good idea to extend PlatformHookUnixoid. 023 * That class has a more or less neutral behaviour, that should 024 * work on all platforms supported by J2SE. 025 * 026 * Attention: At this time this interface is not to be considered 027 * complete. 028 */ 029 public interface PlatformHook { 030 /** 031 * The preStartupHook will be called extremly early. It is 032 * guaranteed to be called before the GUI setup has started. 033 * 034 * Reason: On OSX we need to inform the Swing libraries 035 * that we want to be integrated with the OS before we setup 036 * our GUI. 037 */ 038 public void preStartupHook(); 039 040 /** 041 * The startupHook will be called early, but after the GUI 042 * setup has started. 043 * 044 * Reason: On OSX we need to register some callbacks with the 045 * OS, so we'll receive events from the system menu. 046 */ 047 public void startupHook(); 048 049 /** 050 * The openURL hook will be used to open an URL in the 051 * default webbrowser. 052 */ 053 public void openUrl(String url) throws IOException; 054 055 /** 056 * The initSystemShortcuts hook will be called by the 057 * Shortcut class after the modifier groups have been read 058 * from the config, but before any shortcuts are read from 059 * it or registered from within the application. 060 * 061 * Plese note that you are not allowed to register any 062 * shortuts from this hook, but only "systemCuts"! 063 * 064 * BTW: SystemCuts should be named "system:<whatever>", 065 * and it'd be best if sou'd recycle the names already used 066 * by the Windows and OSX hooks. Especially the later has 067 * really many of them. 068 * 069 * You should also register any and all shortcuts that the 070 * operation system handles itself to block JOSM from trying 071 * to use them---as that would just not work. Call setAutomatic 072 * on them to prevent the keyboard preferences from allowing the 073 * user to change them. 074 */ 075 public void initSystemShortcuts(); 076 077 /** 078 * The makeTooltip hook will be called whenever a tooltip for 079 * a menu or button is created. 080 * 081 * Tooltips are usually not system dependent, unless the 082 * JVM is to dumb to provide correct names for all the keys. 083 * 084 * Another reason not to use the implementation in the *nix 085 * hook are LAFs that don't understand HTML, such as the OSX 086 * LAFs. 087 */ 088 public String makeTooltip(String name, Shortcut sc); 089 090 public String getDefaultStyle(); 091 092 public boolean canFullscreen(); 093 094 public boolean rename(File from, File to); 095 }