Changeset 17679 in josm
- Timestamp:
- 2021-03-28T14:58:23+02:00 (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r17637 r17679 139 139 } 140 140 // Add WebStart package details if run from JNLP 141 if (Utils.isRunning JavaWebStart()) {141 if (Utils.isRunningWebStart()) { 142 142 String webStartDetails = platform.getWebStartPackageDetails(); 143 143 if (webStartDetails != null) { -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r17668 r17679 342 342 } 343 343 344 /** 345 * Asks user to update its version of Java. 346 * @param updVersion target update version 347 * @param url download URL 348 * @param major true for a migration towards a major version of Java (8:9), false otherwise 349 * @param eolDate the EOL/expiration date 350 * @since 12270 351 */ 352 public static void askUpdateJava(String updVersion, String url, String eolDate, boolean major) { 353 ExtendedDialog ed = new ExtendedDialog( 354 mainFrame, 355 tr("Outdated Java version"), 356 tr("OK"), tr("Update Java"), tr("Cancel")); 344 private static void askUpdate(String title, String update, String property, String icon, StringBuilder content, String url) { 345 ExtendedDialog ed = new ExtendedDialog(mainFrame, title, tr("OK"), update, tr("Cancel")); 357 346 // Check if the dialog has not already been permanently hidden by user 358 if (!ed.toggleEnable( "askUpdateJava"+updVersion).toggleCheckState()) {359 ed.setButtonIcons("ok", "java", "cancel").setCancelButton(3);347 if (!ed.toggleEnable(property).toggleCheckState()) { 348 ed.setButtonIcons("ok", icon, "cancel").setCancelButton(3); 360 349 ed.setMinimumSize(new Dimension(480, 300)); 361 350 ed.setIcon(JOptionPane.WARNING_MESSAGE); 362 StringBuilder content = new StringBuilder(tr("You are running version {0} of Java.",363 "<b>"+getSystemProperty("java.version")+"</b>")).append("<br><br>");364 if ("Sun Microsystems Inc.".equals(getSystemProperty("java.vendor")) && !PlatformManager.getPlatform().isOpenJDK()) {365 content.append("<b>").append(tr("This version is no longer supported by {0} since {1} and is not recommended for use.",366 "Oracle", eolDate)).append("</b><br><br>");367 }368 content.append("<b>")369 .append(major ?370 tr("JOSM will soon stop working with this version; we highly recommend you to update to Java {0}.", updVersion) :371 tr("You may face critical Java bugs; we highly recommend you to update to Java {0}.", updVersion))372 .append("</b><br><br>")373 .append(tr("Would you like to update now ?"));374 351 ed.setContent(content.toString()); 375 352 … … 382 359 } 383 360 } 361 } 362 363 /** 364 * Asks user to update its version of Java. 365 * @param updVersion target update version 366 * @param url download URL 367 * @param major true for a migration towards a major version of Java (8:11), false otherwise 368 * @param eolDate the EOL/expiration date 369 * @since 12270 370 */ 371 public static void askUpdateJava(String updVersion, String url, String eolDate, boolean major) { 372 StringBuilder content = new StringBuilder(tr("You are running version {0} of Java.", 373 "<b>"+getSystemProperty("java.version")+"</b>")).append("<br><br>"); 374 if ("Sun Microsystems Inc.".equals(getSystemProperty("java.vendor")) && !PlatformManager.getPlatform().isOpenJDK()) { 375 content.append("<b>").append(tr("This version is no longer supported by {0} since {1} and is not recommended for use.", 376 "Oracle", eolDate)).append("</b><br><br>"); 377 } 378 content.append("<b>") 379 .append(major ? 380 tr("JOSM will soon stop working with this version; we highly recommend you to update to Java {0}.", updVersion) : 381 tr("You may face critical Java bugs; we highly recommend you to update to Java {0}.", updVersion)) 382 .append("</b><br><br>") 383 .append(tr("Would you like to update now ?")); 384 askUpdate(tr("Outdated Java version"), tr("Update Java"), "askUpdateJava"+updVersion, "java", content, url); 385 } 386 387 /** 388 * Asks user to migrate to OpenWebStart 389 * @param url download URL 390 * @since 17679 391 */ 392 public static void askMigrateWebStart(String url) { 393 // CHECKSTYLE.OFF: LineLength 394 StringBuilder content = new StringBuilder(tr("You are running an <b>Oracle</b> implementation of Java WebStart.")) 395 .append("<br><br>") 396 .append(tr("It was for years the recommended way to use JOSM. Oracle removed WebStart from Java 11,<br>but the open source community reimplemented the Java Web Start technology as a new product: <b>OpenWebStart</b>")) 397 .append("<br><br>") 398 .append(tr("OpenWebStart is now considered mature enough by JOSM developers to ask everyone to move away from an Oracle implementation,<br>allowing you to benefit from a recent version of Java, and allowing JOSM developers to move forward by planning the Java {0} migration.", "11")) 399 .append("<br><br>") 400 .append(tr("Would you like to <b>download OpenWebStart now</b>? (Please do!)")); 401 askUpdate(tr("Outdated Java WebStart version"), tr("Update to OpenWebStart"), "askUpdateWebStart", "presets/transport/rocket", content, url); 402 // CHECKSTYLE.ON: LineLength 384 403 } 385 404 -
trunk/src/org/openstreetmap/josm/gui/MainInitialization.java
r17369 r17679 72 72 new InitializationTask(tr("Starting file watcher"), FileWatcher.getDefaultInstance()::start), 73 73 new InitializationTask(tr("Executing platform startup hook"), 74 () -> PlatformManager.getPlatform().startupHook(MainApplication::askUpdateJava)), 74 () -> PlatformManager.getPlatform().startupHook(MainApplication::askUpdateJava, MainApplication::askMigrateWebStart)), 75 75 new InitializationTask(tr("Building main menu"), application::initializeMainWindow), 76 76 new InitializationTask(tr("Updating user interface"), () -> { -
trunk/src/org/openstreetmap/josm/tools/PlatformHook.java
r16619 r17679 85 85 * Reason: On OSX we need to register some callbacks with the 86 86 * OS, so we'll receive events from the system menu. 87 * @param callback Java expiration callback, providing GUI feedback 88 * @since 12270 (signature) 89 */ 90 default void startupHook(JavaExpirationCallback callback) { 87 * @param javaCallback Java expiration callback, providing GUI feedback 88 * @param webStartCallback WebStart migration callback, providing GUI feedback 89 * @since 17679 (signature) 90 */ 91 default void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) { 91 92 // Do nothing 92 93 } … … 262 263 */ 263 264 void askUpdateJava(String updVersion, String url, String eolDate, boolean major); 265 } 266 267 /** 268 * Called when Oracle Java WebStart is detected at startup. 269 * @since 17679 270 */ 271 @FunctionalInterface 272 interface WebStartMigrationCallback { 273 /** 274 * Asks user to migrate to OpenWebStart. 275 * @param url download URL 276 */ 277 void askMigrateWebStart(String url); 264 278 } 265 279 … … 285 299 286 300 /** 301 * Checks if we run Oracle Web Start, proposes to user to migrate to OpenWebStart. 302 * @param callback WebStart migration callback 303 * @since 17679 304 */ 305 default void checkWebStartMigration(WebStartMigrationCallback callback) { 306 if (Utils.isRunningJavaWebStart()) { 307 callback.askMigrateWebStart(Config.getPref().get("openwebstart.download.url", "https://openwebstart.com/download/")); 308 } 309 } 310 311 /** 287 312 * Called when interfacing with native OS functions. Currently only used with macOS. 288 313 * The callback must perform all GUI-related tasks associated to an OS request. -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r17676 r17679 60 60 61 61 @Override 62 public void startupHook(JavaExpirationCallback callback) {62 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) { 63 63 // Here we register callbacks for the menu entries in the system menu and file opening through double-click 64 64 // https://openjdk.java.net/jeps/272 … … 98 98 Logging.warn("Failed to register with macOS: " + ex); 99 99 } 100 checkExpiredJava(callback); 100 checkExpiredJava(javaCallback); 101 checkWebStartMigration(webStartCallback); 101 102 } 102 103 -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r16924 r17679 61 61 } 62 62 } 63 } 64 65 @Override 66 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) { 67 checkWebStartMigration(webStartCallback); 63 68 } 64 69 -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r16120 r17679 154 154 155 155 @Override 156 public void startupHook(JavaExpirationCallback callback) { 157 checkExpiredJava(callback); 156 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) { 157 checkExpiredJava(javaCallback); 158 checkWebStartMigration(webStartCallback); 158 159 } 159 160 -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r17374 r17679 67 67 import java.util.zip.ZipFile; 68 68 69 import org.openstreetmap.josm.spi.preferences.Config; 70 69 71 import com.kitfox.svg.xml.XMLParseUtil; 70 import org.openstreetmap.josm.spi.preferences.Config;71 72 72 73 /** … … 1720 1721 1721 1722 /** 1722 * Determines whether JOSM has been started via JavaWeb Start.1723 * @return true if JOSM has been started via JavaWeb Start1724 * @since 1 57401725 */ 1726 public static boolean isRunning JavaWebStart() {1723 * Determines whether JOSM has been started via Web Start (JNLP). 1724 * @return true if JOSM has been started via Web Start (JNLP) 1725 * @since 17679 1726 */ 1727 public static boolean isRunningWebStart() { 1727 1728 try { 1728 1729 // See http://stackoverflow.com/a/16200769/2257172 … … 1731 1732 return false; 1732 1733 } 1734 } 1735 1736 /** 1737 * Determines whether JOSM has been started via Oracle Java Web Start. 1738 * @return true if JOSM has been started via Oracle Java Web Start 1739 * @since 15740 1740 */ 1741 public static boolean isRunningJavaWebStart() { 1742 return isRunningWebStart() && Package.getPackage("com.sun.javaws") != null; 1743 } 1744 1745 /** 1746 * Determines whether JOSM has been started via Open Web Start (IcedTea-Web). 1747 * @return true if JOSM has been started via Open Web Start (IcedTea-Web) 1748 * @since 17679 1749 */ 1750 public static boolean isRunningOpenWebStart() { 1751 return isRunningWebStart() && Package.getPackage("net.adoptopenjdk.icedteaweb") != null; 1733 1752 } 1734 1753 -
trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookOsxTest.java
r17275 r17679 37 37 @Test 38 38 void testStartupHook() { 39 hook.startupHook((a, b, c, d) -> System.out.println("callback")); 39 hook.startupHook((a, b, c, d) -> System.out.println("java callback"), u -> System.out.println("webstart callback")); 40 40 } 41 41 -
trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java
r17677 r17679 55 55 @Test 56 56 void testStartupHook() { 57 hook.startupHook((a, b, c, d) -> System.out.println("callback")); 57 hook.startupHook((a, b, c, d) -> System.out.println("java callback"), u -> System.out.println("webstart callback")); 58 58 } 59 59
Note:
See TracChangeset
for help on using the changeset viewer.