Package org.openstreetmap.josm.tools
Class PlatformHookOsx
- java.lang.Object
-
- org.openstreetmap.josm.tools.PlatformHookOsx
-
- All Implemented Interfaces:
InvocationHandler
,PlatformHook
public class PlatformHookOsx extends Object implements PlatformHook, InvocationHandler
PlatformHook
implementation for Apple macOS (formerly Mac OS X) systems.- Since:
- 1023
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.tools.PlatformHook
PlatformHook.JavaExpirationCallback, PlatformHook.NativeOsCallback, PlatformHook.WebStartMigrationCallback
-
-
Field Summary
Fields Modifier and Type Field Description private String
oSBuildNumber
private PlatformHook.NativeOsCallback
osCallback
-
Fields inherited from interface org.openstreetmap.josm.tools.PlatformHook
CONSTRUCT_FROM_PLATFORM
-
-
Constructor Summary
Constructors Constructor Description PlatformHookOsx()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
auto(Shortcut sc)
private String
buildOSBuildNumber()
boolean
canFullscreen()
Determines if the platform allows full-screen.static void
enableOSXFullscreen(Window window)
Enables fullscreen support for the given window.protected Class<?>
findHandlerClass(String className)
Find Apple handler class incom.apple.eawt
orjava.awt.desktop
packages.File
getDefaultCacheDirectory()
Returns the platform-dependent default cache directory.File
getDefaultPrefDirectory()
Returns the platform-dependent default preferences directory.String
getDefaultStyle()
Returns the default LAF to be used on this platform to look almost as a native application.File
getDefaultUserDataDirectory()
Returns the platform-dependent default user data directory.int
getMenuShortcutKeyMaskEx()
Returns extended modifier key used as the appropriate accelerator key for menu shortcuts.String
getOSBuildNumber()
Returns OS build number.String
getOSDescription()
Returns a detailed OS description (at least family + version).Platform
getPlatform()
Get the platform corresponding to this platform hook.X509Certificate
getX509Certificate(CertificateAmendment.NativeCertAmend certAmend)
Returns theX509Certificate
matching the given certificate amendment information.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.Object
invoke(Object proxy, Method method, Object[] args)
boolean
isHtmlSupportedInMenuTooltips()
Determines if HTML rendering is supported in menu tooltips.void
openUrl(String url)
The openURL hook will be used to open an URL in the default web browser.void
preStartupHook()
The preStartupHook will be called extremely early.protected void
setHandlers(Class<?> appClass, Class<?> quitHandler, Class<?> aboutHandler, Class<?> openFilesHandler, Class<?> preferencesHandler, Object proxy, Object appInstance)
Registers Apple handlers.void
setNativeOsCallback(PlatformHook.NativeOsCallback callback)
Registers the native OS callback.void
startupHook(PlatformHook.JavaExpirationCallback javaCallback, PlatformHook.WebStartMigrationCallback webStartCallback)
The startupHook will be called early, but after the GUI setup has started.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.tools.PlatformHook
afterPrefStartupHook, checkExpiredJava, checkWebStartMigration, exec, getDefaultProj4NadshiftDirectories, getPossiblePreferenceDirs, isOpenJDK, rename, resolveFileLink
-
-
-
-
Field Detail
-
oSBuildNumber
private String oSBuildNumber
-
osCallback
private PlatformHook.NativeOsCallback osCallback
-
-
Constructor Detail
-
PlatformHookOsx
public PlatformHookOsx()
-
-
Method Detail
-
getPlatform
public Platform getPlatform()
Description copied from interface:PlatformHook
Get the platform corresponding to this platform hook.- Specified by:
getPlatform
in interfacePlatformHook
- Returns:
- the platform corresponding to this platform hook
-
preStartupHook
public void preStartupHook()
Description copied from interface:PlatformHook
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.- Specified by:
preStartupHook
in interfacePlatformHook
-
startupHook
public void startupHook(PlatformHook.JavaExpirationCallback javaCallback, PlatformHook.WebStartMigrationCallback webStartCallback)
Description copied from interface:PlatformHook
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.- Specified by:
startupHook
in interfacePlatformHook
- Parameters:
javaCallback
- Java expiration callback, providing GUI feedbackwebStartCallback
- WebStart migration callback, providing GUI feedback
-
isHtmlSupportedInMenuTooltips
public boolean isHtmlSupportedInMenuTooltips()
Description copied from interface:PlatformHook
Determines if HTML rendering is supported in menu tooltips.- Specified by:
isHtmlSupportedInMenuTooltips
in interfacePlatformHook
- Returns:
true
if HTML rendering is supported in menu tooltips
-
getMenuShortcutKeyMaskEx
public int getMenuShortcutKeyMaskEx()
Description copied from interface:PlatformHook
Returns extended modifier key used as the appropriate accelerator key for menu shortcuts. It is 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
- Specified by:
getMenuShortcutKeyMaskEx
in interfacePlatformHook
- Returns:
- extended modifier key used as the appropriate accelerator key for menu shortcuts
-
setHandlers
protected void setHandlers(Class<?> appClass, Class<?> quitHandler, Class<?> aboutHandler, Class<?> openFilesHandler, Class<?> preferencesHandler, Object proxy, Object appInstance) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Registers Apple handlers.- Parameters:
appClass
- application classquitHandler
- quit handler classaboutHandler
- about handler classopenFilesHandler
- open file handler classpreferencesHandler
- preferences handler classproxy
- proxyappInstance
- application instance (instance ofappClass
)- Throws:
IllegalAccessException
- in case of reflection errorInvocationTargetException
- in case of reflection errorNoSuchMethodException
- if anyset*Handler
method cannot be found
-
findHandlerClass
protected Class<?> findHandlerClass(String className) throws ClassNotFoundException
Find Apple handler class incom.apple.eawt
orjava.awt.desktop
packages.- Parameters:
className
- simple class name- Returns:
- class
- Throws:
ClassNotFoundException
- if the handler class cannot be found
-
enableOSXFullscreen
public static void enableOSXFullscreen(Window window)
Enables fullscreen support for the given window.- Parameters:
window
- The window for which full screen will be available- Since:
- 7482
-
setNativeOsCallback
public void setNativeOsCallback(PlatformHook.NativeOsCallback callback)
Description copied from interface:PlatformHook
Registers the native OS callback. Currently only needed for macOS.- Specified by:
setNativeOsCallback
in interfacePlatformHook
- Parameters:
callback
- the native OS callback
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
Throwable
-
openUrl
public void openUrl(String url) throws IOException
Description copied from interface:PlatformHook
The openURL hook will be used to open an URL in the default web browser.- Specified by:
openUrl
in interfacePlatformHook
- Parameters:
url
- The URL to open- Throws:
IOException
- if any I/O error occurs
-
initSystemShortcuts
public void initSystemShortcuts()
Description copied from interface:PlatformHook
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.- Specified by:
initSystemShortcuts
in interfacePlatformHook
-
getDefaultStyle
public String getDefaultStyle()
Description copied from interface:PlatformHook
Returns the default LAF to be used on this platform to look almost as a native application.- Specified by:
getDefaultStyle
in interfacePlatformHook
- Returns:
- The default native LAF for this platform
-
canFullscreen
public boolean canFullscreen()
Description copied from interface:PlatformHook
Determines if the platform allows full-screen.- Specified by:
canFullscreen
in interfacePlatformHook
- Returns:
true
if full screen is allowed,false
otherwise
-
getOSDescription
public String getOSDescription()
Description copied from interface:PlatformHook
Returns a detailed OS description (at least family + version).- Specified by:
getOSDescription
in interfacePlatformHook
- Returns:
- A detailed OS description.
-
buildOSBuildNumber
private String buildOSBuildNumber()
-
getOSBuildNumber
public String getOSBuildNumber()
Description copied from interface:PlatformHook
Returns OS build number.- Specified by:
getOSBuildNumber
in interfacePlatformHook
- Returns:
- OS build number.
-
getDefaultCacheDirectory
public File getDefaultCacheDirectory()
Description copied from interface:PlatformHook
Returns the platform-dependent default cache directory.- Specified by:
getDefaultCacheDirectory
in interfacePlatformHook
- Returns:
- the platform-dependent default cache directory
-
getDefaultPrefDirectory
public File getDefaultPrefDirectory()
Description copied from interface:PlatformHook
Returns the platform-dependent default preferences directory.- Specified by:
getDefaultPrefDirectory
in interfacePlatformHook
- Returns:
- the platform-dependent default preferences directory
-
getDefaultUserDataDirectory
public File getDefaultUserDataDirectory()
Description copied from interface:PlatformHook
Returns the platform-dependent default user data directory.- Specified by:
getDefaultUserDataDirectory
in interfacePlatformHook
- Returns:
- the platform-dependent default user data directory
-
getX509Certificate
public X509Certificate getX509Certificate(CertificateAmendment.NativeCertAmend certAmend) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException
Description copied from interface:PlatformHook
Returns theX509Certificate
matching the given certificate amendment information.- Specified by:
getX509Certificate
in interfacePlatformHook
- Parameters:
certAmend
- certificate amendment- Returns:
- the
X509Certificate
matching the given certificate amendment information, ornull
- Throws:
KeyStoreException
- in case of errorNoSuchAlgorithmException
- in case of errorCertificateException
- in case of errorIOException
- in case of error
-
-