[6380] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
[1023] | 2 | package org.openstreetmap.josm.tools;
|
---|
| 3 |
|
---|
[4153] | 4 | import java.io.File;
|
---|
[1023] | 5 | import java.io.IOException;
|
---|
[7206] | 6 | import java.security.KeyStore;
|
---|
| 7 | import java.security.KeyStoreException;
|
---|
| 8 | import java.security.NoSuchAlgorithmException;
|
---|
| 9 | import java.security.cert.CertificateException;
|
---|
[1023] | 10 |
|
---|
| 11 | /**
|
---|
[6443] | 12 | * This interface allows platform (operating system) dependent code
|
---|
[1023] | 13 | * to be bundled into self-contained classes.
|
---|
[6443] | 14 | * @since 1023
|
---|
[1023] | 15 | */
|
---|
| 16 | public interface PlatformHook {
|
---|
[6830] | 17 |
|
---|
[1169] | 18 | /**
|
---|
| 19 | * The preStartupHook will be called extremly early. It is
|
---|
| 20 | * guaranteed to be called before the GUI setup has started.
|
---|
| 21 | *
|
---|
| 22 | * Reason: On OSX we need to inform the Swing libraries
|
---|
[6443] | 23 | * that we want to be integrated with the OS before we setup our GUI.
|
---|
[1169] | 24 | */
|
---|
[8512] | 25 | void preStartupHook();
|
---|
| 26 |
|
---|
[8015] | 27 | /**
|
---|
| 28 | * The afterPrefStartupHook will be called early, but after
|
---|
| 29 | * the preferences have been loaded and basic processing of
|
---|
[8512] | 30 | * command line arguments is finished.
|
---|
[8015] | 31 | * It is guaranteed to be called before the GUI setup has started.
|
---|
| 32 | */
|
---|
[8512] | 33 | void afterPrefStartupHook();
|
---|
[1023] | 34 |
|
---|
[1169] | 35 | /**
|
---|
| 36 | * The startupHook will be called early, but after the GUI
|
---|
| 37 | * setup has started.
|
---|
| 38 | *
|
---|
| 39 | * Reason: On OSX we need to register some callbacks with the
|
---|
| 40 | * OS, so we'll receive events from the system menu.
|
---|
| 41 | */
|
---|
[8512] | 42 | void startupHook();
|
---|
[1023] | 43 |
|
---|
[1169] | 44 | /**
|
---|
| 45 | * The openURL hook will be used to open an URL in the
|
---|
[6443] | 46 | * default web browser.
|
---|
| 47 | * @param url The URL to open
|
---|
| 48 | * @throws IOException if any I/O error occurs
|
---|
[1169] | 49 | */
|
---|
[8512] | 50 | void openUrl(String url) throws IOException;
|
---|
[1023] | 51 |
|
---|
[1169] | 52 | /**
|
---|
| 53 | * The initSystemShortcuts hook will be called by the
|
---|
| 54 | * Shortcut class after the modifier groups have been read
|
---|
| 55 | * from the config, but before any shortcuts are read from
|
---|
| 56 | * it or registered from within the application.
|
---|
| 57 | *
|
---|
| 58 | * Plese note that you are not allowed to register any
|
---|
| 59 | * shortuts from this hook, but only "systemCuts"!
|
---|
| 60 | *
|
---|
[6830] | 61 | * BTW: SystemCuts should be named "system:<whatever>",
|
---|
[1169] | 62 | * and it'd be best if sou'd recycle the names already used
|
---|
| 63 | * by the Windows and OSX hooks. Especially the later has
|
---|
| 64 | * really many of them.
|
---|
| 65 | *
|
---|
| 66 | * You should also register any and all shortcuts that the
|
---|
| 67 | * operation system handles itself to block JOSM from trying
|
---|
| 68 | * to use them---as that would just not work. Call setAutomatic
|
---|
| 69 | * on them to prevent the keyboard preferences from allowing the
|
---|
| 70 | * user to change them.
|
---|
| 71 | */
|
---|
[8512] | 72 | void initSystemShortcuts();
|
---|
[1023] | 73 |
|
---|
[1169] | 74 | /**
|
---|
| 75 | * The makeTooltip hook will be called whenever a tooltip for
|
---|
| 76 | * a menu or button is created.
|
---|
| 77 | *
|
---|
| 78 | * Tooltips are usually not system dependent, unless the
|
---|
[6443] | 79 | * JVM is too dumb to provide correct names for all the keys.
|
---|
[1169] | 80 | *
|
---|
| 81 | * Another reason not to use the implementation in the *nix
|
---|
[6443] | 82 | * hook are LAFs that don't understand HTML, such as the OSX LAFs.
|
---|
[6830] | 83 | *
|
---|
| 84 | * @param name Tooltip text to display
|
---|
[6443] | 85 | * @param sc Shortcut associated (to display accelerator between parenthesis)
|
---|
| 86 | * @return Full tooltip text (name + accelerator)
|
---|
[1169] | 87 | */
|
---|
[8512] | 88 | String makeTooltip(String name, Shortcut sc);
|
---|
[2371] | 89 |
|
---|
[6443] | 90 | /**
|
---|
| 91 | * Returns the default LAF to be used on this platform to look almost as a native application.
|
---|
| 92 | * @return The default native LAF for this platform
|
---|
| 93 | */
|
---|
[8512] | 94 | String getDefaultStyle();
|
---|
[4153] | 95 |
|
---|
[6443] | 96 | /**
|
---|
| 97 | * Determines if the platform allows full-screen.
|
---|
| 98 | * @return {@code true} if full screen is allowed, {@code false} otherwise
|
---|
| 99 | */
|
---|
[8512] | 100 | boolean canFullscreen();
|
---|
[4203] | 101 |
|
---|
[6443] | 102 | /**
|
---|
| 103 | * Renames a file.
|
---|
| 104 | * @param from Source file
|
---|
| 105 | * @param to Target file
|
---|
| 106 | * @return {@code true} if the file has been renamed, {@code false} otherwise
|
---|
| 107 | */
|
---|
[8512] | 108 | boolean rename(File from, File to);
|
---|
[6070] | 109 |
|
---|
[5850] | 110 | /**
|
---|
| 111 | * Returns a detailed OS description (at least family + version).
|
---|
| 112 | * @return A detailed OS description.
|
---|
| 113 | * @since 5850
|
---|
| 114 | */
|
---|
[8512] | 115 | String getOSDescription();
|
---|
[7206] | 116 |
|
---|
| 117 | /**
|
---|
| 118 | * Setup system keystore to add JOSM HTTPS certificate (for remote control).
|
---|
[7343] | 119 | * @param entryAlias The entry alias to use
|
---|
[7335] | 120 | * @param trustedCert the JOSM certificate for localhost
|
---|
[7343] | 121 | * @return {@code true} if something has changed as a result of the call (certificate installation, etc.)
|
---|
[7206] | 122 | * @throws KeyStoreException in case of error
|
---|
| 123 | * @throws IOException in case of error
|
---|
| 124 | * @throws CertificateException in case of error
|
---|
| 125 | * @throws NoSuchAlgorithmException in case of error
|
---|
[7343] | 126 | * @since 7343
|
---|
[7206] | 127 | */
|
---|
[8512] | 128 | boolean setupHttpsCertificate(String entryAlias, KeyStore.TrustedCertificateEntry trustedCert)
|
---|
[7206] | 129 | throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException;
|
---|
[7829] | 130 |
|
---|
| 131 | /**
|
---|
| 132 | * Returns the platform-dependent default cache directory.
|
---|
| 133 | * @return the platform-dependent default cache directory
|
---|
| 134 | * @since 7829
|
---|
| 135 | */
|
---|
[8512] | 136 | File getDefaultCacheDirectory();
|
---|
[7831] | 137 |
|
---|
| 138 | /**
|
---|
| 139 | * Returns the platform-dependent default preferences directory.
|
---|
| 140 | * @return the platform-dependent default preferences directory
|
---|
| 141 | * @since 7831
|
---|
| 142 | */
|
---|
[8512] | 143 | File getDefaultPrefDirectory();
|
---|
[7834] | 144 |
|
---|
| 145 | /**
|
---|
| 146 | * Returns the platform-dependent default user data directory.
|
---|
| 147 | * @return the platform-dependent default user data directory
|
---|
| 148 | * @since 7834
|
---|
| 149 | */
|
---|
[8512] | 150 | File getDefaultUserDataDirectory();
|
---|
[1023] | 151 | }
|
---|