Changeset 19103 in josm for trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
- Timestamp:
- 2024-06-13T00:23:03+02:00 (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r18985 r19103 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import static org.openstreetmap.josm.tools.Utils.getSystemEnv; … … 7 8 8 9 import java.awt.Desktop; 10 import java.awt.event.InputEvent; 9 11 import java.awt.event.KeyEvent; 10 12 import java.io.BufferedReader; … … 29 31 import java.util.Set; 30 32 import java.util.concurrent.ExecutionException; 33 import java.util.regex.Matcher; 34 import java.util.regex.Pattern; 31 35 32 36 import org.openstreetmap.josm.data.Preferences; … … 51 55 // See #12022, #16666 - Disable GNOME ATK Java wrapper as it causes a lot of serious trouble 52 56 if (isDebianOrUbuntu()) { 53 if (Utils.getJavaVersion() >= 9) { 54 // TODO: find a way to disable ATK wrapper on Java >= 9 55 // We should probably be able to do that by embedding a no-op AccessibilityProvider in our jar 56 // so that it is loaded by ServiceLoader without error 57 // But this require to compile at least one class with Java 9 58 } else { 59 // Java 8 does a simple Class.newInstance() from system classloader 60 Utils.updateSystemProperty("javax.accessibility.assistive_technologies", "java.lang.Object"); 61 } 62 } 63 } 64 65 @Override 66 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback, 67 SanityCheckCallback sanityCheckCallback) { 68 checkWebStartMigration(webStartCallback); 69 PlatformHook.super.startupHook(javaCallback, webStartCallback, sanityCheckCallback); 57 // TODO: find a way to disable ATK wrapper on Java >= 9 58 // We should probably be able to do that by embedding a no-op AccessibilityProvider in our jar 59 // so that it is loaded by ServiceLoader without error 60 // But this require to compile at least one class with Java 9 61 } 62 } 63 64 @Override 65 public void startupHook(JavaExpirationCallback javaCallback, SanityCheckCallback sanityCheckCallback) { 66 PlatformHook.super.startupHook(javaCallback, sanityCheckCallback); 70 67 } 71 68 … … 91 88 92 89 @Override 90 @SuppressWarnings("squid:S103") // NOSONAR LineLength 93 91 public void initSystemShortcuts() { 92 final String reserved = marktr("reserved"); 94 93 // CHECKSTYLE.OFF: LineLength 95 94 // TODO: Insert system shortcuts here. See Windows and especially OSX to see how to. 96 95 for (int i = KeyEvent.VK_F1; i <= KeyEvent.VK_F12; ++i) { 97 Shortcut.registerSystemShortcut("screen:to ogle"+i, tr("reserved"), i, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)96 Shortcut.registerSystemShortcut("screen:toggle"+i, tr(reserved), i, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK) 98 97 .setAutomatic(); 99 98 } 100 Shortcut.registerSystemShortcut("system:reset", tr( "reserved"), KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)99 Shortcut.registerSystemShortcut("system:reset", tr(reserved), KeyEvent.VK_DELETE, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK) 101 100 .setAutomatic(); 102 Shortcut.registerSystemShortcut("system:resetX", tr( "reserved"), KeyEvent.VK_BACK_SPACE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK)101 Shortcut.registerSystemShortcut("system:resetX", tr(reserved), KeyEvent.VK_BACK_SPACE, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK) 103 102 .setAutomatic(); 104 103 // CHECKSTYLE.ON: LineLength … … 175 174 /** 176 175 * Get the Java package name including detailed version. 177 * 176 * <p> 178 177 * Some Java bugs are specific to a certain security update, so in addition 179 178 * to the Java version, we also need the exact package version. … … 183 182 public String getJavaPackageDetails() { 184 183 String home = getSystemProperty("java.home"); 185 if (home.contains("java-8-openjdk") || home.contains("java-1.8.0-openjdk")) { 186 return getPackageDetails("openjdk-8-jre", "java-1_8_0-openjdk", "java-1.8.0-openjdk"); 187 } else if (home.contains("java-9-openjdk") || home.contains("java-1.9.0-openjdk")) { 188 return getPackageDetails("openjdk-9-jre", "java-1_9_0-openjdk", "java-1.9.0-openjdk", "java-9-openjdk"); 189 } else if (home.contains("java-10-openjdk")) { 190 return getPackageDetails("openjdk-10-jre", "java-10-openjdk"); 191 } else if (home.contains("java-11-openjdk")) { 192 return getPackageDetails("openjdk-11-jre", "java-11-openjdk"); 193 } else if (home.contains("java-17-openjdk")) { 194 return getPackageDetails("openjdk-17-jre", "java-17-openjdk"); 184 if (home == null) { 185 return null; 186 } 187 Matcher matcher = Pattern.compile("java-(\\d+)-openjdk").matcher(home); 188 if (matcher.find()) { 189 String version = matcher.group(1); 190 return getPackageDetails("openjdk-" + version + "-jre", "java-" + version + "-openjdk"); 195 191 } else if (home.contains("java-openjdk")) { 196 192 return getPackageDetails("java-openjdk"); … … 205 201 /** 206 202 * Get the Web Start package name including detailed version. 207 * 203 * <p> 208 204 * OpenJDK packages are shipped with icedtea-web package, 209 205 * but its version generally does not match main java package version. 210 * 206 * <p> 211 207 * Simply return {@code null} if there's no separate package for Java WebStart. 212 208 * … … 222 218 /** 223 219 * Get the Gnome ATK wrapper package name including detailed version. 224 * 220 * <p> 225 221 * Debian and Ubuntu derivatives come with a pre-enabled accessibility software 226 222 * completely buggy that makes Swing crash in a lot of different ways. 227 * 223 * <p> 228 224 * Simply return {@code null} if it's not found. 229 225 *
Note:
See TracChangeset
for help on using the changeset viewer.