Interface PlatformHook

    • Method Detail

      • getPlatform

        Platform getPlatform()
        Get the platform corresponding to this platform hook.
        Returns:
        the platform corresponding to this platform hook
      • preStartupHook

        default void preStartupHook()
        The preStartupHook will be called extremely early. It is guaranteed to be called before the GUI setup has started.

        Reason: On OSX we need to inform the Swing libraries that we want to be integrated with the OS before we setup our GUI.

      • afterPrefStartupHook

        default void afterPrefStartupHook()
        The afterPrefStartupHook will be called early, but after the preferences have been loaded and basic processing of command line arguments is finished. It is guaranteed to be called before the GUI setup has started.
      • startupHook

        default void startupHook​(PlatformHook.JavaExpirationCallback javaCallback,
                                 PlatformHook.SanityCheckCallback sanityCheckCallback)
        The startupHook will be called early, but after the GUI setup has started.

        Reason: On OSX we need to register some callbacks with the OS, so we'll receive events from the system menu.

        Parameters:
        javaCallback - Java expiration callback, providing GUI feedback
        sanityCheckCallback - Sanity check callback, providing GUI feedback
        Since:
        18985
      • openUrl

        void openUrl​(java.lang.String url)
              throws java.io.IOException
        The openURL hook will be used to open a URL in the default web browser.
        Parameters:
        url - The URL to open
        Throws:
        java.io.IOException - if any I/O error occurs
      • initSystemShortcuts

        void initSystemShortcuts()
        The initSystemShortcuts hook will be called by the Shortcut class after the modifier groups have been read from the config, but before any shortcuts are read from it or registered from within the application.

        Please note that you are not allowed to register any shortcuts from this hook, but only "systemCuts"!

        BTW: SystemCuts should be named "system:<whatever>", and it'd be best if you'd recycle the names already used by the Windows and OSX hooks. Especially the latter has really many of them.

        You should also register any and all shortcuts that the operating system handles itself to block JOSM from trying to use them---as that would just not work. Call setAutomatic on them to prevent the keyboard preferences from allowing the user to change them.

      • getDefaultStyle

        java.lang.String getDefaultStyle()
        Returns the default LAF to be used on this platform to look almost as a native application.
        Returns:
        The default native LAF for this platform
      • canFullscreen

        default boolean canFullscreen()
        Determines if the platform allows full-screen.
        Returns:
        true if full screen is allowed, false otherwise
      • rename

        default boolean rename​(java.io.File from,
                               java.io.File to)
        Renames a file.
        Parameters:
        from - Source file
        to - Target file
        Returns:
        true if the file has been renamed, false otherwise
      • getOSDescription

        java.lang.String getOSDescription()
        Returns a detailed OS description (at least family + version).
        Returns:
        A detailed OS description.
        Since:
        5850
      • getOSBuildNumber

        default java.lang.String getOSBuildNumber()
        Returns OS build number.
        Returns:
        OS build number.
        Since:
        12217
      • getX509Certificate

        default java.security.cert.X509Certificate getX509Certificate​(CertificateAmendment.NativeCertAmend certAmend)
                                                               throws java.security.KeyStoreException,
                                                                      java.security.NoSuchAlgorithmException,
                                                                      java.security.cert.CertificateException,
                                                                      java.io.IOException
        Returns the X509Certificate matching the given certificate amendment information.
        Parameters:
        certAmend - certificate amendment
        Returns:
        the X509Certificate matching the given certificate amendment information, or null
        Throws:
        java.security.KeyStoreException - in case of error
        java.io.IOException - in case of error
        java.security.cert.CertificateException - in case of error
        java.security.NoSuchAlgorithmException - in case of error
        Since:
        13450
      • exec

        default java.lang.String exec​(java.lang.String... command)
                               throws java.io.IOException
        Executes a native command and returns the first line of standard output.
        Parameters:
        command - array containing the command to call and its arguments.
        Returns:
        first stripped line of standard output
        Throws:
        java.io.IOException - if an I/O error occurs
        Since:
        12217
      • getDefaultCacheDirectory

        java.io.File getDefaultCacheDirectory()
        Returns the platform-dependent default cache directory.
        Returns:
        the platform-dependent default cache directory
        Since:
        7829
      • getDefaultPrefDirectory

        java.io.File getDefaultPrefDirectory()
        Returns the platform-dependent default preferences directory.
        Returns:
        the platform-dependent default preferences directory
        Since:
        7831
      • getDefaultUserDataDirectory

        java.io.File getDefaultUserDataDirectory()
        Returns the platform-dependent default user data directory.
        Returns:
        the platform-dependent default user data directory
        Since:
        7834
      • getDefaultProj4NadshiftDirectories

        default java.util.List<java.io.File> getDefaultProj4NadshiftDirectories()
        Returns the list of platform-dependent default datum shifting directories for the PROJ.4 library.
        Returns:
        the list of platform-dependent default datum shifting directories for the PROJ.4 library
        Since:
        11642
      • isOpenJDK

        default boolean isOpenJDK()
        Determines if the JVM is OpenJDK-based.
        Returns:
        true if java.home contains "openjdk", false otherwise
        Since:
        12219
      • isHtmlSupportedInMenuTooltips

        default boolean isHtmlSupportedInMenuTooltips()
        Determines if HTML rendering is supported in menu tooltips.
        Returns:
        true if HTML rendering is supported in menu tooltips
        Since:
        18116
      • getMenuShortcutKeyMaskEx

        default int getMenuShortcutKeyMaskEx()
        Returns extended modifier key used as the appropriate accelerator key for menu shortcuts. It was advised everywhere to use Toolkit.getMenuShortcutKeyMask() to get the cross-platform modifier, but:
        • it returns KeyEvent.CTRL_MASK instead of KeyEvent.CTRL_DOWN_MASK. We used the extended modifier for years, and Oracle recommends to use it instead, so it's best to keep it
        • the method throws a HeadlessException ! So we would need to handle it for unit tests anyway
        Returns:
        extended modifier key used as the appropriate accelerator key for menu shortcuts
        Since:
        12748 (as a replacement to GuiHelper.getMenuShortcutKeyMaskEx())
      • checkExpiredJava

        default void checkExpiredJava​(PlatformHook.JavaExpirationCallback callback)
        Checks if the running version of Java has expired, proposes to user to update it if needed.
        Parameters:
        callback - Java expiration callback
        Since:
        12270 (signature), 12219
      • getJavaUrl

        default java.lang.String getJavaUrl()
        Get the Java download URL (really shouldn't be used outside of JOSM startup checks)
        Returns:
        The download URL to use.
        Since:
        18580
      • resolveFileLink

        default java.io.File resolveFileLink​(java.io.File file)
        Resolves a file link to its destination file.
        Parameters:
        file - file (link or regular file)
        Returns:
        destination file in case of a file link, file if regular
        Since:
        13691
      • getPossiblePreferenceDirs

        default java.util.Collection<java.lang.String> getPossiblePreferenceDirs()
        Returns a set of possible platform specific directories where resources could be stored.
        Returns:
        A set of possible platform specific directories where resources could be stored.
        Since:
        14144