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.WebStartMigrationCallback webStartCallback)
        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
        webStartCallback - WebStart migration callback, providing GUI feedback
        Since:
        17679 (signature)
      • openUrl

        void openUrl​(String url)
              throws IOException
        The openURL hook will be used to open an URL in the default web browser.
        Parameters:
        url - The URL to open
        Throws:
        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 later has really many of them. You should also register any and all shortcuts that the operation 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

        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​(File from,
                               File to)
        Renames a file.
        Parameters:
        from - Source file
        to - Target file
        Returns:
        true if the file has been renamed, false otherwise
      • getOSDescription

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

        default String getOSBuildNumber()
        Returns OS build number.
        Returns:
        OS build number.
        Since:
        12217
      • exec

        default String exec​(String... command)
                     throws 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:
        IOException - if an I/O error occurs
        Since:
        12217
      • getDefaultCacheDirectory

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

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

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

        default List<FilegetDefaultProj4NadshiftDirectories()
        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 is 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
      • resolveFileLink

        default File resolveFileLink​(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 Collection<StringgetPossiblePreferenceDirs()
        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