Ticket #1622: PlatformHook.java

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