1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import java.io.File;
|
---|
5 | import java.io.IOException;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * This interface allows platform (operating system) dependent code
|
---|
9 | * to be bundled into self-contained classes.
|
---|
10 | * @since 1023
|
---|
11 | */
|
---|
12 | public interface PlatformHook {
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * The preStartupHook will be called extremly early. It is
|
---|
16 | * guaranteed to be called before the GUI setup has started.
|
---|
17 | *
|
---|
18 | * Reason: On OSX we need to inform the Swing libraries
|
---|
19 | * that we want to be integrated with the OS before we setup our GUI.
|
---|
20 | */
|
---|
21 | public void preStartupHook();
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * The startupHook will be called early, but after the GUI
|
---|
25 | * setup has started.
|
---|
26 | *
|
---|
27 | * Reason: On OSX we need to register some callbacks with the
|
---|
28 | * OS, so we'll receive events from the system menu.
|
---|
29 | */
|
---|
30 | public void startupHook();
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * The openURL hook will be used to open an URL in the
|
---|
34 | * default web browser.
|
---|
35 | * @param url The URL to open
|
---|
36 | * @throws IOException if any I/O error occurs
|
---|
37 | */
|
---|
38 | public void openUrl(String url) throws IOException;
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * The initSystemShortcuts hook will be called by the
|
---|
42 | * Shortcut class after the modifier groups have been read
|
---|
43 | * from the config, but before any shortcuts are read from
|
---|
44 | * it or registered from within the application.
|
---|
45 | *
|
---|
46 | * Plese note that you are not allowed to register any
|
---|
47 | * shortuts from this hook, but only "systemCuts"!
|
---|
48 | *
|
---|
49 | * BTW: SystemCuts should be named "system:<whatever>",
|
---|
50 | * and it'd be best if sou'd recycle the names already used
|
---|
51 | * by the Windows and OSX hooks. Especially the later has
|
---|
52 | * really many of them.
|
---|
53 | *
|
---|
54 | * You should also register any and all shortcuts that the
|
---|
55 | * operation system handles itself to block JOSM from trying
|
---|
56 | * to use them---as that would just not work. Call setAutomatic
|
---|
57 | * on them to prevent the keyboard preferences from allowing the
|
---|
58 | * user to change them.
|
---|
59 | */
|
---|
60 | public void initSystemShortcuts();
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * The makeTooltip hook will be called whenever a tooltip for
|
---|
64 | * a menu or button is created.
|
---|
65 | *
|
---|
66 | * Tooltips are usually not system dependent, unless the
|
---|
67 | * JVM is too dumb to provide correct names for all the keys.
|
---|
68 | *
|
---|
69 | * Another reason not to use the implementation in the *nix
|
---|
70 | * hook are LAFs that don't understand HTML, such as the OSX LAFs.
|
---|
71 | *
|
---|
72 | * @param name Tooltip text to display
|
---|
73 | * @param sc Shortcut associated (to display accelerator between parenthesis)
|
---|
74 | * @return Full tooltip text (name + accelerator)
|
---|
75 | */
|
---|
76 | public String makeTooltip(String name, Shortcut sc);
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Returns the default LAF to be used on this platform to look almost as a native application.
|
---|
80 | * @return The default native LAF for this platform
|
---|
81 | */
|
---|
82 | public String getDefaultStyle();
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Determines if the platform allows full-screen.
|
---|
86 | * @return {@code true} if full screen is allowed, {@code false} otherwise
|
---|
87 | */
|
---|
88 | public boolean canFullscreen();
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Renames a file.
|
---|
92 | * @param from Source file
|
---|
93 | * @param to Target file
|
---|
94 | * @return {@code true} if the file has been renamed, {@code false} otherwise
|
---|
95 | */
|
---|
96 | public boolean rename(File from, File to);
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Returns a detailed OS description (at least family + version).
|
---|
100 | * @return A detailed OS description.
|
---|
101 | * @since 5850
|
---|
102 | */
|
---|
103 | public String getOSDescription();
|
---|
104 | }
|
---|