Class PlatformHookWindows
- All Implemented Interfaces:
PlatformHook
PlatformHook implementation for Microsoft Windows systems.- Since:
- 1023
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSimple data class to hold information about a font.Nested classes/interfaces inherited from interface org.openstreetmap.josm.tools.PlatformHook
PlatformHook.JavaExpirationCallback, PlatformHook.NativeOsCallback, PlatformHook.SanityCheckCallback -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final PatternPattern of Microsoft .NET and Powershell version numbers in registry.private Stringprivate static final StringFields inherited from interface org.openstreetmap.josm.tools.PlatformHook
CONSTRUCT_FROM_PLATFORM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThe afterPrefStartupHook will be called early, but after the preferences have been loaded and basic processing of command line arguments is finished.private static Stringprotected voidextendFontconfig(String templateFileName) Add more fallback fonts to the Java runtime, in order to get support for more scripts.protected Collection<PlatformHookWindows.FontEntry>Get default list of additional fonts to add to the configuration.static StringReturns the Windows current build number from registry (example: "15063")Returns the platform-dependent default cache directory.Returns the platform-dependent default preferences directory.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.static StringReturns the Windows display version from registry (example: "22H2")protected Collection<String>Get a list of fonts that are installed on the system.Returns OS build number.Returns a detailed OS description (at least family + version).Get the platform corresponding to this platform hook.Returns a set of possible platform specific directories where resources could be stored.static intReturns the major version number of PowerShell.static StringReturns the Windows product name from registry (example: "Windows 10 Pro")static StringReturns the Windows release identifier from registry (example: "1703")static KeyStoreLoads Windows-ROOT keystore.Returns 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.static booleanDetermines if the .NET framework 4.5 (or later) is installed.voidThe openURL hook will be used to open a URL in the default web browser.booleanRenames a file.resolveFileLink(File file) Resolves a file link to its destination file.private static booleansha256matches(Certificate result, CertificateAmendment.NativeCertAmend certAmend, MessageDigest md) voidstartupHook(PlatformHook.JavaExpirationCallback javaCallback, PlatformHook.SanityCheckCallback sanityCheckCallback) The startupHook will be called early, but after the GUI setup has started.static StringwebRequest(String uri) Performs a web request using Windows CryptoAPI (through PowerShell).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.tools.PlatformHook
canFullscreen, exec, getDefaultProj4NadshiftDirectories, getJavaUrl, getMenuShortcutKeyMaskEx, isHtmlSupportedInMenuTooltips, isOpenJDK, preStartupHook, setNativeOsCallback, startupSanityChecks, warnSoonToBeUnsupportedJava
-
Field Details
-
MS_VERSION_PATTERN
Pattern of Microsoft .NET and Powershell version numbers in registry. -
WINDOWS_ROOT
- See Also:
-
CURRENT_VERSION
- See Also:
-
oSBuildNumber
-
-
Constructor Details
-
PlatformHookWindows
public PlatformHookWindows()
-
-
Method Details
-
getPlatform
Description copied from interface:PlatformHookGet the platform corresponding to this platform hook.- Specified by:
getPlatformin interfacePlatformHook- Returns:
- the platform corresponding to this platform hook
-
afterPrefStartupHook
Description copied from interface:PlatformHookThe 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.- Specified by:
afterPrefStartupHookin interfacePlatformHook
-
startupHook
public void startupHook(PlatformHook.JavaExpirationCallback javaCallback, PlatformHook.SanityCheckCallback sanityCheckCallback) Description copied from interface:PlatformHookThe 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:
startupHookin interfacePlatformHook- Parameters:
javaCallback- Java expiration callback, providing GUI feedbacksanityCheckCallback- Sanity check callback, providing GUI feedback
-
openUrl
Description copied from interface:PlatformHookThe openURL hook will be used to open a URL in the default web browser.- Specified by:
openUrlin interfacePlatformHook- Parameters:
url- The URL to open- Throws:
IOException- if any I/O error occurs
-
initSystemShortcuts
Description copied from interface:PlatformHookThe 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.
- Specified by:
initSystemShortcutsin interfacePlatformHook
-
getDefaultStyle
Description copied from interface:PlatformHookReturns the default LAF to be used on this platform to look almost as a native application.- Specified by:
getDefaultStylein interfacePlatformHook- Returns:
- The default native LAF for this platform
-
rename
Description copied from interface:PlatformHookRenames a file.- Specified by:
renamein interfacePlatformHook- Parameters:
from- Source fileto- Target file- Returns:
trueif the file has been renamed,falseotherwise
-
getOSDescription
Description copied from interface:PlatformHookReturns a detailed OS description (at least family + version).- Specified by:
getOSDescriptionin interfacePlatformHook- Returns:
- A detailed OS description.
-
getProductName
Returns the Windows product name from registry (example: "Windows 10 Pro")- Returns:
- the Windows product name from registry
- Throws:
IllegalAccessException- if Java language access control is enforced and the underlying method is inaccessibleInvocationTargetException- if the underlying method throws an exception- Since:
- 12744
-
getReleaseId
Returns the Windows release identifier from registry (example: "1703")- Returns:
- the Windows release identifier from registry
- Throws:
IllegalAccessException- if Java language access control is enforced and the underlying method is inaccessibleInvocationTargetException- if the underlying method throws an exception- Since:
- 12744
-
getDisplayVersion
Returns the Windows display version from registry (example: "22H2")- Returns:
- the Windows display version from registry
- Throws:
IllegalAccessException- if Java language access control is enforced and the underlying method is inaccessibleInvocationTargetException- if the underlying method throws an exception- Since:
- 19041
-
getCurrentBuild
Returns the Windows current build number from registry (example: "15063")- Returns:
- the Windows current build number from registry
- Throws:
IllegalAccessException- if Java language access control is enforced and the underlying method is inaccessibleInvocationTargetException- if the underlying method throws an exception- Since:
- 12744
-
buildOSBuildNumber
-
getOSBuildNumber
Description copied from interface:PlatformHookReturns OS build number.- Specified by:
getOSBuildNumberin interfacePlatformHook- Returns:
- OS build number.
-
getRootKeystore
public static KeyStore getRootKeystore() throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreExceptionLoads Windows-ROOT keystore.- Returns:
- Windows-ROOT keystore
- Throws:
NoSuchAlgorithmException- if the algorithm used to check the integrity of the keystore cannot be foundCertificateException- if any of the certificates in the keystore could not be loadedIOException- if there is an I/O or format problem with the keystore data, if a password is required but not givenKeyStoreException- if no Provider supports a KeyStore implementation for the type "Windows-ROOT"- Since:
- 7343
-
getX509Certificate
public X509Certificate getX509Certificate(CertificateAmendment.NativeCertAmend certAmend) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException Description copied from interface:PlatformHookReturns theX509Certificatematching the given certificate amendment information.- Specified by:
getX509Certificatein interfacePlatformHook- Parameters:
certAmend- certificate amendment- Returns:
- the
X509Certificatematching the given certificate amendment information, ornull - Throws:
KeyStoreException- in case of errorNoSuchAlgorithmException- in case of errorCertificateException- in case of errorIOException- in case of error
-
sha256matches
private static boolean sha256matches(Certificate result, CertificateAmendment.NativeCertAmend certAmend, MessageDigest md) throws CertificateEncodingException - Throws:
CertificateEncodingException
-
getDefaultCacheDirectory
Description copied from interface:PlatformHookReturns the platform-dependent default cache directory.- Specified by:
getDefaultCacheDirectoryin interfacePlatformHook- Returns:
- the platform-dependent default cache directory
-
getDefaultPrefDirectory
Description copied from interface:PlatformHookReturns the platform-dependent default preferences directory.- Specified by:
getDefaultPrefDirectoryin interfacePlatformHook- Returns:
- the platform-dependent default preferences directory
-
getDefaultUserDataDirectory
Description copied from interface:PlatformHookReturns the platform-dependent default user data directory.- Specified by:
getDefaultUserDataDirectoryin interfacePlatformHook- Returns:
- the platform-dependent default user data directory
-
extendFontconfig
Add more fallback fonts to the Java runtime, in order to get support for more scripts.
The font configuration in Java doesn't include some Indic scripts, even though MS Windows ships with fonts that cover these unicode ranges.
To fix this, the fontconfig.properties template is copied to the JOSM cache folder. Then, the additional entries are added to the font configuration. Finally the system property "sun.awt.fontconfig" is set to the customized fontconfig.properties file.
This is a crude hack, but better than no font display at all for these languages. There is no guarantee, that the template file ($JAVA_HOME/lib/fontconfig.properties.src) matches the default configuration (which is in a binary format). Furthermore, the system property "sun.awt.fontconfig" is undocumented and may no longer work in future versions of Java.
Related Java bug: JDK-8008572
- Parameters:
templateFileName- file name of the fontconfig.properties template file
-
getInstalledFonts
Get a list of fonts that are installed on the system. Must be done without triggering the Java Font initialization. (SeeextendFontconfig(java.lang.String), have to set system property first, which is then read by sun.awt.FontConfiguration upon initialization.)- Returns:
- list of file names
-
getAdditionalFonts
Get default list of additional fonts to add to the configuration. Java will choose thee first font in the list that can render a certain character.- Returns:
- list of FontEntry objects
-
isDotNet45Installed
Determines if the .NET framework 4.5 (or later) is installed. Windows 7 ships by default with an older version.- Returns:
trueif the .NET framework 4.5 (or later) is installed.- Since:
- 13463
-
getPowerShellVersion
Returns the major version number of PowerShell.- Returns:
- the major version number of PowerShell. -1 in case of error
- Since:
- 13465
-
webRequest
Performs a web request using Windows CryptoAPI (through PowerShell). This is useful to ensure Windows trust store will contain a specific root CA.- Parameters:
uri- the web URI to request- Returns:
- HTTP response from the given URI
- Throws:
IOException- if any I/O error occurs- Since:
- 13458
-
resolveFileLink
Description copied from interface:PlatformHookResolves a file link to its destination file.- Specified by:
resolveFileLinkin interfacePlatformHook- Parameters:
file- file (link or regular file)- Returns:
- destination file in case of a file link, file if regular
-
getPossiblePreferenceDirs
Description copied from interface:PlatformHookReturns a set of possible platform specific directories where resources could be stored.- Specified by:
getPossiblePreferenceDirsin interfacePlatformHook- Returns:
- A set of possible platform specific directories where resources could be stored.
-