Class PlatformHookUnixoid
- java.lang.Object
-
- org.openstreetmap.josm.tools.PlatformHookUnixoid
-
- All Implemented Interfaces:
PlatformHook
public class PlatformHookUnixoid extends java.lang.Object implements PlatformHook
PlatformHook
implementation for Unix systems.- Since:
- 1023
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PlatformHookUnixoid.LinuxReleaseInfo
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.tools.PlatformHook
PlatformHook.JavaExpirationCallback, PlatformHook.NativeOsCallback, PlatformHook.SanityCheckCallback
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
osDescription
-
Fields inherited from interface org.openstreetmap.josm.tools.PlatformHook
CONSTRUCT_FROM_PLATFORM
-
-
Constructor Summary
Constructors Constructor Description PlatformHookUnixoid()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
buildOSDescription()
java.lang.String
getAtkWrapperPackageDetails()
Get the Gnome ATK wrapper package name including detailed version.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.java.util.Optional<java.lang.String>
getDesktopEnvironment()
Returns desktop environment based on the environment variableXDG_CURRENT_DESKTOP
.private static java.io.File
getDotDirectory()
Get the dot directory~/.josm
.java.lang.String
getJavaPackageDetails()
Get the Java package name including detailed version.java.lang.String
getOSDescription()
Returns a detailed OS description (at least family + version).static java.lang.String
getPackageDetails(java.lang.String... packageNames)
Get the package name including detailed 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.java.lang.String
getWebStartPackageDetails()
Get the Web Start package name including detailed version.java.security.cert.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.static boolean
isDebianOrUbuntu()
Determines if the distribution is Debian or Ubuntu, or a derivative.void
openUrl(java.lang.String url)
The openURL hook will be used to open a URL in the default web browser.void
preStartupHook()
The preStartupHook will be called extremely early.void
startupHook(PlatformHook.JavaExpirationCallback javaCallback, PlatformHook.SanityCheckCallback sanityCheckCallback)
The startupHook will be called early, but after the GUI setup has started.private static boolean
useDotDirectory()
Returns true if the dot directory should be used for storing preferences, cache and user data.-
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, canFullscreen, checkExpiredJava, exec, getDefaultProj4NadshiftDirectories, getJavaUrl, getMenuShortcutKeyMaskEx, getOSBuildNumber, isHtmlSupportedInMenuTooltips, isOpenJDK, rename, resolveFileLink, setNativeOsCallback, startupSanityChecks, warnSoonToBeUnsupportedJava
-
-
-
-
Field Detail
-
osDescription
private java.lang.String osDescription
-
-
Constructor Detail
-
PlatformHookUnixoid
public PlatformHookUnixoid()
-
-
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.SanityCheckCallback sanityCheckCallback)
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 feedbacksanityCheckCallback
- Sanity check callback, providing GUI feedback
-
openUrl
public void openUrl(java.lang.String url) throws java.io.IOException
Description copied from interface:PlatformHook
The openURL hook will be used to open a URL in the default web browser.- Specified by:
openUrl
in interfacePlatformHook
- Parameters:
url
- The URL to open- Throws:
java.io.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 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:
initSystemShortcuts
in interfacePlatformHook
-
getDefaultStyle
public java.lang.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
-
getDesktopEnvironment
public java.util.Optional<java.lang.String> getDesktopEnvironment()
Returns desktop environment based on the environment variableXDG_CURRENT_DESKTOP
.- Returns:
- desktop environment.
-
isDebianOrUbuntu
public static boolean isDebianOrUbuntu()
Determines if the distribution is Debian or Ubuntu, or a derivative.- Returns:
true
if the distribution is Debian, Ubuntu or Mint,false
otherwise
-
getPackageDetails
public static java.lang.String getPackageDetails(java.lang.String... packageNames)
Get the package name including detailed version.- Parameters:
packageNames
- The possible package names (when a package can have different names on different distributions)- Returns:
- The package name and package version if it can be identified, null otherwise
- Since:
- 7314
-
getJavaPackageDetails
public java.lang.String getJavaPackageDetails()
Get the Java package name including detailed version.Some Java bugs are specific to a certain security update, so in addition to the Java version, we also need the exact package version.
- Returns:
- The package name and package version if it can be identified, null otherwise
-
getWebStartPackageDetails
public java.lang.String getWebStartPackageDetails()
Get the Web Start package name including detailed version.OpenJDK packages are shipped with icedtea-web package, but its version generally does not match main java package version.
Simply return
null
if there's no separate package for Java WebStart.- Returns:
- The package name and package version if it can be identified, null otherwise
-
getAtkWrapperPackageDetails
public java.lang.String getAtkWrapperPackageDetails()
Get the Gnome ATK wrapper package name including detailed version.Debian and Ubuntu derivatives come with a pre-enabled accessibility software completely buggy that makes Swing crash in a lot of different ways.
Simply return
null
if it's not found.- Returns:
- The package name and package version if it can be identified, null otherwise
-
buildOSDescription
private java.lang.String buildOSDescription()
-
getOSDescription
public java.lang.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.
-
getDotDirectory
private static java.io.File getDotDirectory()
Get the dot directory~/.josm
.- Returns:
- the dot directory
-
useDotDirectory
private static boolean useDotDirectory()
Returns true if the dot directory should be used for storing preferences, cache and user data. Currently this is the case, if the dot directory already exists.- Returns:
- true if the dot directory should be used
-
getDefaultCacheDirectory
public java.io.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 java.io.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 java.io.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 java.security.cert.X509Certificate getX509Certificate(CertificateAmendment.NativeCertAmend certAmend) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.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:
java.security.KeyStoreException
- in case of errorjava.security.NoSuchAlgorithmException
- in case of errorjava.security.cert.CertificateException
- in case of errorjava.io.IOException
- in case of error
-
getPossiblePreferenceDirs
public java.util.Collection<java.lang.String> getPossiblePreferenceDirs()
Description copied from interface:PlatformHook
Returns a set of possible platform specific directories where resources could be stored.- Specified by:
getPossiblePreferenceDirs
in interfacePlatformHook
- Returns:
- A set of possible platform specific directories where resources could be stored.
-
-