| 1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others |
|---|
| 2 | package org.openstreetmap.josm.tools; |
|---|
| 3 | |
|---|
| 4 | import java.io.File; |
|---|
| 5 | import java.io.IOException; |
|---|
| 6 | import java.util.HashMap; |
|---|
| 7 | |
|---|
| 8 | /** |
|---|
| 9 | * This interface allows platfrom (operating system) dependent code |
|---|
| 10 | * to be bundled into self-contained classes. |
|---|
| 11 | * |
|---|
| 12 | * For plugin authors: |
|---|
| 13 | * To implement your own PlatformHook class, implement this interface, |
|---|
| 14 | * then create the class when your plugin is loaded and store it in |
|---|
| 15 | * Main.platform. Please not that the two "startup" hooks will be |
|---|
| 16 | * called _before_ your plugin is loaded. If you need to hook there, |
|---|
| 17 | * split your class into two (one containing only the startup hooks, |
|---|
| 18 | * and one with the remainder) and send the startup class, together |
|---|
| 19 | * with propper OS detection code (see Main) for inclusion with |
|---|
| 20 | * JOSM to the JOSM team. |
|---|
| 21 | * |
|---|
| 22 | * Also, it might be a good idea to extend PlatformHookUnixoid. |
|---|
| 23 | * That class has a more or less neutral behaviour, that should |
|---|
| 24 | * work on all platforms supported by J2SE. |
|---|
| 25 | * |
|---|
| 26 | * Attention: At this time this interface is not to be considered |
|---|
| 27 | * complete. |
|---|
| 28 | */ |
|---|
| 29 | public interface PlatformHook { |
|---|
| 30 | /** |
|---|
| 31 | * The preStartupHook will be called extremly early. It is |
|---|
| 32 | * guaranteed to be called before the GUI setup has started. |
|---|
| 33 | * |
|---|
| 34 | * Reason: On OSX we need to inform the Swing libraries |
|---|
| 35 | * that we want to be integrated with the OS before we setup |
|---|
| 36 | * our GUI. |
|---|
| 37 | */ |
|---|
| 38 | public void preStartupHook(); |
|---|
| 39 | |
|---|
| 40 | /** |
|---|
| 41 | * The startupHook will be called early, but after the GUI |
|---|
| 42 | * setup has started. |
|---|
| 43 | * |
|---|
| 44 | * Reason: On OSX we need to register some callbacks with the |
|---|
| 45 | * OS, so we'll receive events from the system menu. |
|---|
| 46 | */ |
|---|
| 47 | public void startupHook(); |
|---|
| 48 | |
|---|
| 49 | /** |
|---|
| 50 | * The openURL hook will be used to open an URL in the |
|---|
| 51 | * default webbrowser. |
|---|
| 52 | */ |
|---|
| 53 | public void openUrl(String url) throws IOException; |
|---|
| 54 | |
|---|
| 55 | /** |
|---|
| 56 | * The initSystemShortcuts hook will be called by the |
|---|
| 57 | * Shortcut class after the modifier groups have been read |
|---|
| 58 | * from the config, but before any shortcuts are read from |
|---|
| 59 | * it or registered from within the application. |
|---|
| 60 | * |
|---|
| 61 | * Plese note that you are not allowed to register any |
|---|
| 62 | * shortuts from this hook, but only "systemCuts"! |
|---|
| 63 | * |
|---|
| 64 | * BTW: SystemCuts should be named "system:<whatever>", |
|---|
| 65 | * and it'd be best if sou'd recycle the names already used |
|---|
| 66 | * by the Windows and OSX hooks. Especially the later has |
|---|
| 67 | * really many of them. |
|---|
| 68 | * |
|---|
| 69 | * You should also register any and all shortcuts that the |
|---|
| 70 | * operation system handles itself to block JOSM from trying |
|---|
| 71 | * to use them---as that would just not work. Call setAutomatic |
|---|
| 72 | * on them to prevent the keyboard preferences from allowing the |
|---|
| 73 | * user to change them. |
|---|
| 74 | */ |
|---|
| 75 | public void initSystemShortcuts(); |
|---|
| 76 | |
|---|
| 77 | /** |
|---|
| 78 | * The makeTooltip hook will be called whenever a tooltip for |
|---|
| 79 | * a menu or button is created. |
|---|
| 80 | * |
|---|
| 81 | * Tooltips are usually not system dependent, unless the |
|---|
| 82 | * JVM is to dumb to provide correct names for all the keys. |
|---|
| 83 | * |
|---|
| 84 | * Another reason not to use the implementation in the *nix |
|---|
| 85 | * hook are LAFs that don't understand HTML, such as the OSX |
|---|
| 86 | * LAFs. |
|---|
| 87 | */ |
|---|
| 88 | public String makeTooltip(String name, Shortcut sc); |
|---|
| 89 | |
|---|
| 90 | public String getDefaultStyle(); |
|---|
| 91 | |
|---|
| 92 | public boolean canFullscreen(); |
|---|
| 93 | |
|---|
| 94 | public boolean rename(File from, File to); |
|---|
| 95 | } |
|---|