Ignore:
Timestamp:
2017-08-27T00:45:21+02:00 (3 years ago)
Author:
Don-vip
Message:

see #15182 - remove dependence on GUI for tools.PlatformHook

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r12665 r12670  
    210210    }
    211211
     212    /**
     213     * Asks user to update its version of Java.
     214     * @param updVersion target update version
     215     * @param url download URL
     216     * @param major true for a migration towards a major version of Java (8:9), false otherwise
     217     * @param eolDate the EOL/expiration date
     218     * @since 12270
     219     */
     220    public static void askUpdateJava(String updVersion, String url, String eolDate, boolean major) {
     221        ExtendedDialog ed = new ExtendedDialog(
     222                Main.parent,
     223                tr("Outdated Java version"),
     224                tr("OK"), tr("Update Java"), tr("Cancel"));
     225        // Check if the dialog has not already been permanently hidden by user
     226        if (!ed.toggleEnable("askUpdateJava"+updVersion).toggleCheckState()) {
     227            ed.setButtonIcons("ok", "java", "cancel").setCancelButton(3);
     228            ed.setMinimumSize(new Dimension(480, 300));
     229            ed.setIcon(JOptionPane.WARNING_MESSAGE);
     230            StringBuilder content = new StringBuilder(tr("You are running version {0} of Java.",
     231                    "<b>"+System.getProperty("java.version")+"</b>")).append("<br><br>");
     232            if ("Sun Microsystems Inc.".equals(System.getProperty("java.vendor")) && !platform.isOpenJDK()) {
     233                content.append("<b>").append(tr("This version is no longer supported by {0} since {1} and is not recommended for use.",
     234                        "Oracle", eolDate)).append("</b><br><br>");
     235            }
     236            content.append("<b>")
     237                   .append(major ?
     238                        tr("JOSM will soon stop working with this version; we highly recommend you to update to Java {0}.", updVersion) :
     239                        tr("You may face critical Java bugs; we highly recommend you to update to Java {0}.", updVersion))
     240                   .append("</b><br><br>")
     241                   .append(tr("Would you like to update now ?"));
     242            ed.setContent(content.toString());
     243
     244            if (ed.showDialog().getValue() == 2) {
     245                try {
     246                    platform.openUrl(url);
     247                } catch (IOException e) {
     248                    Logging.warn(e);
     249                }
     250            }
     251        }
     252    }
     253
    212254    @Override
    213255    protected List<InitializationTask> beforeInitializationTasks() {
    214256        return Arrays.asList(
    215257            new InitializationTask(tr("Starting file watcher"), fileWatcher::start),
    216             new InitializationTask(tr("Executing platform startup hook"), platform::startupHook),
     258            new InitializationTask(tr("Executing platform startup hook"), () -> platform.startupHook(MainApplication::askUpdateJava)),
    217259            new InitializationTask(tr("Building main menu"), this::initializeMainWindow),
    218260            new InitializationTask(tr("Updating user interface"), () -> {
Note: See TracChangeset for help on using the changeset viewer.