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