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