Changeset 18790 in josm


Ignore:
Timestamp:
2023-08-07T15:31:04+02:00 (16 months ago)
Author:
taylor.smock
Message:

Fix #23103, see #17858: Notify users that a plugin requires a newer Java version

We were previously only logging a warning if a plugin required a newer Java
version. We additionally needed to update the download link generation for Azul
and sync the next minimum Java version with that used by the JOSM wiki check.

There was also a help topic that linked to a dead page (which was also
unavailable in the internet archive).

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r18368 r18790  
    7878import org.openstreetmap.josm.tools.ImageProvider;
    7979import org.openstreetmap.josm.tools.Logging;
     80import org.openstreetmap.josm.tools.OpenBrowser;
     81import org.openstreetmap.josm.tools.PlatformManager;
    8082import org.openstreetmap.josm.tools.ResourceProvider;
    8183import org.openstreetmap.josm.tools.SubclassFilteredCollection;
     
    646648    }
    647649
    648     private static void logJavaUpdateRequired(String plugin, int requiredVersion) {
    649         Logging.warn(
    650                 tr("Plugin {0} requires Java version {1}. The current Java version is {2}. "
    651                         +"You have to update Java in order to use this plugin.",
     650    private static void alertJavaUpdateRequired(Component parent, String plugin, int requiredVersion) {
     651        final ButtonSpec[] options = new ButtonSpec[] {
     652                new ButtonSpec(tr("OK"), ImageProvider.get("ok"), tr("Click to close the dialog"), null),
     653                new ButtonSpec(tr("Update Java"), ImageProvider.get("java"), tr("Update Java"), null)
     654        };
     655        final int selected = HelpAwareOptionPane.showOptionDialog(
     656                parent,
     657                "<html>" + tr("Plugin {0} requires Java version {1}. The current Java version is {2}.<br>"
     658                                + "You have to update Java in order to use this plugin.",
    652659                        plugin, Integer.toString(requiredVersion), Utils.getJavaVersion()
    653                 ));
     660                ) + "</html>",
     661                tr("Warning"),
     662                JOptionPane.WARNING_MESSAGE,
     663                null,
     664                options,
     665                options[0],
     666                null
     667        );
     668        if (selected == 1) {
     669            if (Utils.isRunningJavaWebStart()) {
     670                OpenBrowser.displayUrl(Config.getPref().get("openwebstart.download.url", "https://openwebstart.com/download/"));
     671            } else if (!Utils.isRunningWebStart()) {
     672                final String javaUrl = PlatformManager.getPlatform().getJavaUrl();
     673                OpenBrowser.displayUrl(javaUrl);
     674            }
     675        }
    654676    }
    655677
     
    663685                tr("Warning"),
    664686                JOptionPane.WARNING_MESSAGE,
    665                 ht("/Plugin/Loading#JOSMUpdateRequired")
     687                null
    666688        );
    667689    }
     
    688710        // make sure the plugin is compatible with the current Java version
    689711        if (plugin.localminjavaversion > Utils.getJavaVersion()) {
    690             // Just log a warning until we switch to Java 11 so that javafx plugin does not trigger a popup
    691             logJavaUpdateRequired(plugin.name, plugin.localminjavaversion);
     712            alertJavaUpdateRequired(parent, plugin.name, plugin.localminjavaversion);
    692713            return false;
    693714        }
  • trunk/src/org/openstreetmap/josm/tools/PlatformHook.java

    r18580 r18790  
    313313     */
    314314    default void warnSoonToBeUnsupportedJava(JavaExpirationCallback callback) {
    315         // Java 11 is our next minimum version, and OpenWebStart should be replacing Oracle WebStart
    316         // We'd go to 17, but some Linux distributions (Debian) default to Java 11.
    317         // And OpenWebStart currently doesn't have Java 17 JREs.
    318         if (Utils.getJavaVersion() < 11 && !Utils.isRunningWebStart()) {
     315        // Java 17 is our next minimum version, and OpenWebStart should be replacing Oracle WebStart
     316        if (Utils.getJavaVersion() < 17 && !Utils.isRunningWebStart()) {
    319317            String latestVersion = Utils.getJavaLatestVersion();
    320318            String currentVersion = Utils.getSystemProperty("java.version");
     
    334332     */
    335333    default String getJavaUrl() {
    336         StringBuilder defaultDownloadUrl = new StringBuilder("https://www.azul.com/downloads/?version=java-17-lts&package=jre-fx");
     334        StringBuilder defaultDownloadUrl = new StringBuilder("https://www.azul.com/downloads/?version=java-17-lts");
    337335        if (PlatformManager.isPlatformWindows()) {
    338336            defaultDownloadUrl.append("&os=windows");
     
    348346            if ("x86_64".equals(osArch) || "amd64".equals(osArch)
    349347                    || "AMD64".equalsIgnoreCase(System.getenv("PROCESSOR_ARCHITEW6432"))) {
    350                 defaultDownloadUrl.append("&architecture=x86-64-bit");
     348                defaultDownloadUrl.append("&architecture=x86-64-bit").append("&package=jdk-fx"); // jdk-fx has an installer
    351349            } else if ("aarch64".equals(osArch)) {
    352                 defaultDownloadUrl.append("&architecture=arm-64-bit");
     350                defaultDownloadUrl.append("&architecture=arm-64-bit").append("&package=jdk-fx"); // jdk-fx has an installer
    353351            } else if ("x86".equals(osArch)) {
    354352                // Honestly, just about everyone should be on x86_64 at this point. But just in case someone
    355353                // is running JOSM on a 10-year-old computer. They'd probably be better off running a RPi.
    356                 defaultDownloadUrl.append("&architecture=x86-32-bit");
     354                defaultDownloadUrl.append("&architecture=x86-32-bit").append("&package=jdk"); // jdk has an installer
    357355            } // else user will have to figure it out themselves.
    358356        }
    359         defaultDownloadUrl.append("#download-openjdk"); // Scrolls to download section
     357        defaultDownloadUrl.append("#zulu"); // Scrolls to download section
    360358        return defaultDownloadUrl.toString();
    361359    }
Note: See TracChangeset for help on using the changeset viewer.