public class PlatformHookWindows extends java.lang.Object implements PlatformHook
PlatformHook implementation for Microsoft Windows systems.| Modifier and Type | Class and Description |
|---|---|
static class |
PlatformHookWindows.FontEntry
Simple data class to hold information about a font.
|
PlatformHook.JavaExpirationCallback, PlatformHook.NativeOsCallback| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
CURRENT_VERSION |
private static java.util.regex.Pattern |
MS_VERSION_PATTERN
Pattern of Microsoft .NET and Powershell version numbers in registry.
|
private java.lang.String |
oSBuildNumber |
private static java.lang.String |
WINDOWS_ROOT |
CONSTRUCT_FROM_PLATFORM| Constructor and Description |
|---|
PlatformHookWindows() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPrefStartupHook()
The afterPrefStartupHook will be called early, but after
the preferences have been loaded and basic processing of
command line arguments is finished.
|
private static java.lang.String |
buildOSBuildNumber() |
protected void |
extendFontconfig(java.lang.String templateFileName)
Add more fallback fonts to the Java runtime, in order to get
support for more scripts.
|
protected java.util.Collection<PlatformHookWindows.FontEntry> |
getAdditionalFonts()
Get default list of additional fonts to add to the configuration.
|
static java.lang.String |
getCurrentBuild()
Returns the Windows current build number from registry (example: "15063")
|
java.io.File |
getDefaultCacheDirectory()
Returns the platform-dependent default cache directory.
|
java.io.File |
getDefaultPrefDirectory()
Returns the platform-dependent default preferences directory.
|
java.lang.String |
getDefaultStyle()
Returns the default LAF to be used on this platform to look almost as a native application.
|
java.io.File |
getDefaultUserDataDirectory()
Returns the platform-dependent default user data directory.
|
protected java.util.Collection<java.lang.String> |
getInstalledFonts()
Get a list of fonts that are installed on the system.
|
java.lang.String |
getOSBuildNumber()
Returns OS build number.
|
java.lang.String |
getOSDescription()
Returns a detailed OS description (at least family + version).
|
Platform |
getPlatform()
Get the platform corresponding to this platform hook.
|
java.util.Collection<java.lang.String> |
getPossiblePreferenceDirs()
Returns a set of possible platform specific directories where resources could be stored.
|
static int |
getPowerShellVersion()
Returns the major version number of PowerShell.
|
static java.lang.String |
getProductName()
Returns the Windows product name from registry (example: "Windows 10 Pro")
|
static java.lang.String |
getReleaseId()
Returns the Windows release identifier from registry (example: "1703")
|
static java.security.KeyStore |
getRootKeystore()
Loads Windows-ROOT keystore.
|
java.security.cert.X509Certificate |
getX509Certificate(CertificateAmendment.NativeCertAmend certAmend)
Returns the
X509Certificate 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.
|
static boolean |
isDotNet45Installed()
Determines if the .NET framework 4.5 (or later) is installed.
|
void |
openUrl(java.lang.String url)
The openURL hook will be used to open an URL in the
default web browser.
|
boolean |
rename(java.io.File from,
java.io.File to)
Renames a file.
|
java.io.File |
resolveFileLink(java.io.File file)
Resolves a file link to its destination file.
|
void |
startupHook(PlatformHook.JavaExpirationCallback callback)
The startupHook will be called early, but after the GUI
setup has started.
|
static java.lang.String |
webRequest(java.lang.String uri)
Performs a web request using Windows CryptoAPI (through PowerShell).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanFullscreen, checkExpiredJava, exec, getDefaultProj4NadshiftDirectories, getMenuShortcutKeyMaskEx, isOpenJDK, preStartupHook, setNativeOsCallbackprivate static final java.util.regex.Pattern MS_VERSION_PATTERN
private static final java.lang.String WINDOWS_ROOT
private static final java.lang.String CURRENT_VERSION
private java.lang.String oSBuildNumber
public PlatformHookWindows()
public Platform getPlatform()
PlatformHookgetPlatform in interface PlatformHookpublic void afterPrefStartupHook()
PlatformHookafterPrefStartupHook in interface PlatformHookpublic void startupHook(PlatformHook.JavaExpirationCallback callback)
PlatformHookstartupHook in interface PlatformHookcallback - Java expiration callback, providing GUI feedbackpublic void openUrl(java.lang.String url) throws java.io.IOException
PlatformHookopenUrl in interface PlatformHookurl - The URL to openjava.io.IOException - if any I/O error occurspublic void initSystemShortcuts()
PlatformHookinitSystemShortcuts in interface PlatformHookpublic java.lang.String getDefaultStyle()
PlatformHookgetDefaultStyle in interface PlatformHookpublic boolean rename(java.io.File from, java.io.File to)
PlatformHookrename in interface PlatformHookfrom - Source fileto - Target filetrue if the file has been renamed, false otherwisepublic java.lang.String getOSDescription()
PlatformHookgetOSDescription in interface PlatformHookpublic static java.lang.String getProductName() throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException - if Java language access control is enforced and the underlying method is inaccessiblejava.lang.reflect.InvocationTargetException - if the underlying method throws an exceptionpublic static java.lang.String getReleaseId() throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException - if Java language access control is enforced and the underlying method is inaccessiblejava.lang.reflect.InvocationTargetException - if the underlying method throws an exceptionpublic static java.lang.String getCurrentBuild() throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException - if Java language access control is enforced and the underlying method is inaccessiblejava.lang.reflect.InvocationTargetException - if the underlying method throws an exceptionprivate static java.lang.String buildOSBuildNumber()
public java.lang.String getOSBuildNumber()
PlatformHookgetOSBuildNumber in interface PlatformHookpublic static java.security.KeyStore getRootKeystore() throws java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException, java.security.KeyStoreException
java.security.NoSuchAlgorithmException - if the algorithm used to check the integrity of the keystore cannot be foundjava.security.cert.CertificateException - if any of the certificates in the keystore could not be loadedjava.io.IOException - if there is an I/O or format problem with the keystore data, if a password is required but not givenjava.security.KeyStoreException - if no Provider supports a KeyStore implementation for the type "Windows-ROOT"public java.security.cert.X509Certificate getX509Certificate(CertificateAmendment.NativeCertAmend certAmend) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException
PlatformHookX509Certificate matching the given certificate amendment information.getX509Certificate in interface PlatformHookcertAmend - certificate amendmentX509Certificate matching the given certificate amendment information, or nulljava.security.KeyStoreException - in case of errorjava.security.NoSuchAlgorithmException - in case of errorjava.security.cert.CertificateException - in case of errorjava.io.IOException - in case of errorpublic java.io.File getDefaultCacheDirectory()
PlatformHookgetDefaultCacheDirectory in interface PlatformHookpublic java.io.File getDefaultPrefDirectory()
PlatformHookgetDefaultPrefDirectory in interface PlatformHookpublic java.io.File getDefaultUserDataDirectory()
PlatformHookgetDefaultUserDataDirectory in interface PlatformHookprotected void extendFontconfig(java.lang.String templateFileName)
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
templateFileName - file name of the fontconfig.properties template fileprotected java.util.Collection<java.lang.String> getInstalledFonts()
extendFontconfig(java.lang.String), have to set system
property first, which is then read by sun.awt.FontConfiguration upon initialization.)protected java.util.Collection<PlatformHookWindows.FontEntry> getAdditionalFonts()
public static boolean isDotNet45Installed()
true if the .NET framework 4.5 (or later) is installed.public static int getPowerShellVersion()
public static java.lang.String webRequest(java.lang.String uri) throws java.io.IOException
uri - the web URI to requestjava.io.IOException - if any I/O error occurspublic java.io.File resolveFileLink(java.io.File file)
PlatformHookresolveFileLink in interface PlatformHookfile - file (link or regular file)public java.util.Collection<java.lang.String> getPossiblePreferenceDirs()
PlatformHookgetPossiblePreferenceDirs in interface PlatformHook