Changeset 6952 in josm for trunk


Ignore:
Timestamp:
2014-03-31T15:15:39+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #9879 - fix unreported EDT violation that may cause freeze during startup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r6951 r6952  
    2121import org.openstreetmap.josm.Main;
    2222import org.openstreetmap.josm.gui.ExtendedDialog;
     23import org.openstreetmap.josm.gui.util.GuiHelper;
    2324
    2425/**
     
    345346    }
    346347
    347     protected void askUpdateJava(String version, String url) {
    348         try {
    349             ExtendedDialog ed = new ExtendedDialog(
    350                     Main.parent,
    351                     tr("Outdated Java version"),
    352                     new String[]{tr("Update Java"), tr("Cancel")});
    353             // Check if the dialog has not already been permanently hidden by user
    354             if (!ed.toggleEnable("askUpdateJava7").toggleCheckState()) {
    355                 ed.setButtonIcons(new String[]{"java.png", "cancel.png"}).setCancelButton(2);
    356                 ed.setMinimumSize(new Dimension(480, 300));
    357                 ed.setIcon(JOptionPane.WARNING_MESSAGE);
    358                 String content = tr("You are running version {0} of Java.", "<b>"+version+"</b>")+"<br><br>";
    359                 if ("Sun Microsystems Inc.".equals(System.getProperty("java.vendor")) && !isOpenJDK()) {
    360                     content += "<b>"+tr("This version is no longer supported by {0} since {1} and is not recommended for use.",
    361                             "Oracle", tr("February 2013"))+"</b><br><br>";
    362                 }
    363                 content += "<b>"+tr("JOSM will soon stop working with this version; we highly recommend you to update to Java {0}.", "7")+"</b><br><br>"+
    364                         tr("Would you like to update now ?");
    365                 ed.setContent(content);
    366 
    367                 if (ed.showDialog().getValue() == 1) {
    368                     openUrl(url);
    369                 }
    370             }
    371         } catch (IOException e) {
    372             Main.warn(e);
    373         }
     348    protected void askUpdateJava(final String version, final String url) {
     349        GuiHelper.runInEDTAndWait(new Runnable() {
     350            @Override
     351            public void run() {
     352                ExtendedDialog ed = new ExtendedDialog(
     353                        Main.parent,
     354                        tr("Outdated Java version"),
     355                        new String[]{tr("Update Java"), tr("Cancel")});
     356                // Check if the dialog has not already been permanently hidden by user
     357                if (!ed.toggleEnable("askUpdateJava7").toggleCheckState()) {
     358                    ed.setButtonIcons(new String[]{"java.png", "cancel.png"}).setCancelButton(2);
     359                    ed.setMinimumSize(new Dimension(480, 300));
     360                    ed.setIcon(JOptionPane.WARNING_MESSAGE);
     361                    String content = tr("You are running version {0} of Java.", "<b>"+version+"</b>")+"<br><br>";
     362                    if ("Sun Microsystems Inc.".equals(System.getProperty("java.vendor")) && !isOpenJDK()) {
     363                        content += "<b>"+tr("This version is no longer supported by {0} since {1} and is not recommended for use.",
     364                                "Oracle", tr("February 2013"))+"</b><br><br>";
     365                    }
     366                    content += "<b>"+tr("JOSM will soon stop working with this version; we highly recommend you to update to Java {0}.", "7")+"</b><br><br>"+
     367                            tr("Would you like to update now ?");
     368                    ed.setContent(content);
     369
     370                    if (ed.showDialog().getValue() == 1) {
     371                        try {
     372                            openUrl(url);
     373                        } catch (IOException e) {
     374                            Main.warn(e);
     375                        }
     376                    }
     377                }
     378            }
     379        });
    374380    }
    375381}
Note: See TracChangeset for help on using the changeset viewer.