| 1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
|---|
| 2 | package org.openstreetmap.josm.tools;
|
|---|
| 3 |
|
|---|
| 4 | import org.openstreetmap.josm.tools.Shortcut;
|
|---|
| 5 |
|
|---|
| 6 | import java.io.IOException;
|
|---|
| 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 initShortcutGroups hook will be called by the
|
|---|
| 57 | * Shortcut class if it detects that there are no
|
|---|
| 58 | * groups in teh config file. So that will happen
|
|---|
| 59 | * once on each JOSM installation only.
|
|---|
| 60 | *
|
|---|
| 61 | * Please note that ShorCut will load its config on demand,
|
|---|
| 62 | * that is, at the moment the first shortcut is registered.
|
|---|
| 63 | *
|
|---|
| 64 | * In this hook, you have to fill the preferences with
|
|---|
| 65 | * data, not the internal structures! Also, do not try
|
|---|
| 66 | * to register any shortcuts from within.
|
|---|
| 67 | */
|
|---|
| 68 | public void initShortcutGroups();
|
|---|
| 69 |
|
|---|
| 70 | /**
|
|---|
| 71 | * The initSystemShortcuts hook will be called by the
|
|---|
| 72 | * Shortcut class after the modifier groups have been read
|
|---|
| 73 | * from the config, but before any shortcuts are read from
|
|---|
| 74 | * it or registered from within the application.
|
|---|
| 75 | *
|
|---|
| 76 | * Plese note that you are not allowed to register any
|
|---|
| 77 | * shortuts from this hook, but only "systemCuts"!
|
|---|
| 78 | *
|
|---|
| 79 | * BTW: SystemCuts should be named "system:<whatever>",
|
|---|
| 80 | * and it'd be best if sou'd recycle the names already used
|
|---|
| 81 | * by the Windows and OSX hooks. Especially the later has
|
|---|
| 82 | * really many of them.
|
|---|
| 83 | *
|
|---|
| 84 | * You should also register any and all shortcuts that the
|
|---|
| 85 | * operation system handles itself to block JOSM from trying
|
|---|
| 86 | * to use them---as that would just not work. Call setAutomatic
|
|---|
| 87 | * on them to prevent the keyboard preferences from allowing the
|
|---|
| 88 | * user to change them.
|
|---|
| 89 | */
|
|---|
| 90 | public void initSystemShortcuts();
|
|---|
| 91 |
|
|---|
| 92 | /**
|
|---|
| 93 | * The makeTooltip hook will be called whenever a tooltip for
|
|---|
| 94 | * a menu or button is created.
|
|---|
| 95 | *
|
|---|
| 96 | * Tooltips are usually not system dependent, unless the
|
|---|
| 97 | * JVM is to dumb to provide correct names for all the keys.
|
|---|
| 98 | *
|
|---|
| 99 | * Another reason not to use the implementation in the *nix
|
|---|
| 100 | * hook are LAFs that don't understand HTML, such as the OSX
|
|---|
| 101 | * LAFs.
|
|---|
| 102 | */
|
|---|
| 103 | public String makeTooltip(String name, Shortcut sc);
|
|---|
| 104 | }
|
|---|