Interface PlatformHook
- All Known Implementing Classes:
PlatformHookOsx,PlatformHookUnixoid,PlatformHookWindows
- Since:
- 1023
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceCalled when an outdated version of Java is detected at startup.static interfaceCalled when interfacing with native OS functions.static interfaceInform the user that a sanity check or checks failed -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PlatformVisitor<PlatformHook>Visitor to construct a PlatformHook from a givenPlatformobject. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidThe afterPrefStartupHook will be called early, but after the preferences have been loaded and basic processing of command line arguments is finished.default booleanDetermines if the platform allows full-screen.default StringExecutes a native command and returns the first line of standard output.Returns the platform-dependent default cache directory.Returns the platform-dependent default preferences directory.Returns the list of platform-dependent default datum shifting directories for the PROJ.4 library.Returns the default LAF to be used on this platform to look almost as a native application.Returns the platform-dependent default user data directory.default StringGet the Java download URL (really shouldn't be used outside of JOSM startup checks)default intReturns extended modifier key used as the appropriate accelerator key for menu shortcuts.default StringReturns OS build number.Returns a detailed OS description (at least family + version).Get the platform corresponding to this platform hook.default Collection<String>Returns a set of possible platform specific directories where resources could be stored.default X509CertificateReturns theX509Certificatematching the given certificate amendment information.voidThe 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.default booleanDetermines if HTML rendering is supported in menu tooltips.default booleanDetermines if the JVM is OpenJDK-based.voidThe openURL hook will be used to open a URL in the default web browser.default voidThe preStartupHook will be called extremely early.default booleanRenames a file.default FileresolveFileLink(File file) Resolves a file link to its destination file.default voidRegisters the native OS callback.default voidstartupHook(PlatformHook.JavaExpirationCallback javaCallback, PlatformHook.SanityCheckCallback sanityCheckCallback) The startupHook will be called early, but after the GUI setup has started.default voidstartupSanityChecks(PlatformHook.SanityCheckCallback sanityCheckCallback) Check startup preconditionsdefault voidChecks if we will soon not be supporting the running version of Java
-
Field Details
-
CONSTRUCT_FROM_PLATFORM
Visitor to construct a PlatformHook from a givenPlatformobject.
-
-
Method Details
-
getPlatform
Get the platform corresponding to this platform hook.- Returns:
- the platform corresponding to this platform hook
-
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
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 feedbacksanityCheckCallback- Sanity check callback, providing GUI feedback- Since:
- 18985
-
openUrl
The openURL hook will be used to open a 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 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
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
Determines if the platform allows full-screen.- Returns:
trueif full screen is allowed,falseotherwise
-
rename
Renames a file.- Parameters:
from- Source fileto- Target file- Returns:
trueif the file has been renamed,falseotherwise
-
getOSDescription
Returns a detailed OS description (at least family + version).- Returns:
- A detailed OS description.
- Since:
- 5850
-
getOSBuildNumber
Returns OS build number.- Returns:
- OS build number.
- Since:
- 12217
-
getX509Certificate
default X509Certificate getX509Certificate(CertificateAmendment.NativeCertAmend certAmend) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException Returns theX509Certificatematching the given certificate amendment information.- Parameters:
certAmend- certificate amendment- Returns:
- the
X509Certificatematching the given certificate amendment information, ornull - Throws:
KeyStoreException- in case of errorIOException- in case of errorCertificateException- in case of errorNoSuchAlgorithmException- in case of error- Since:
- 13450
-
exec
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
Returns the platform-dependent default cache directory.- Returns:
- the platform-dependent default cache directory
- Since:
- 7829
-
getDefaultPrefDirectory
Returns the platform-dependent default preferences directory.- Returns:
- the platform-dependent default preferences directory
- Since:
- 7831
-
getDefaultUserDataDirectory
Returns the platform-dependent default user data directory.- Returns:
- the platform-dependent default user data directory
- Since:
- 7834
-
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
Determines if the JVM is OpenJDK-based.- Returns:
trueifjava.homecontains "openjdk",falseotherwise- Since:
- 12219
-
isHtmlSupportedInMenuTooltips
Determines if HTML rendering is supported in menu tooltips.- Returns:
trueif HTML rendering is supported in menu tooltips- Since:
- 18116
-
getMenuShortcutKeyMaskEx
Returns extended modifier key used as the appropriate accelerator key for menu shortcuts. It was advised everywhere to useToolkit.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())
-
warnSoonToBeUnsupportedJava
Checks if we will soon not be supporting the running version of Java- Parameters:
callback- Java expiration callback- Since:
- 18580
-
getJavaUrl
Get the Java download URL (really shouldn't be used outside of JOSM startup checks)- Returns:
- The download URL to use.
- Since:
- 18580
-
startupSanityChecks
Check startup preconditions- Parameters:
sanityCheckCallback- The callback to inform the user about failed checks
-
setNativeOsCallback
Registers the native OS callback. Currently only needed for macOS.- Parameters:
callback- the native OS callback- Since:
- 12695
-
resolveFileLink
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
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
-