Changeset 7401 in josm
- Timestamp:
- 2014-08-15T17:45:34+02:00 (10 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/images/presets
-
Property svn:ignore
set to
Thumbs.db
-
Property svn:ignore
set to
-
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r7005 r7401 28 28 import javax.swing.JScrollPane; 29 29 import javax.swing.KeyStroke; 30 import javax.swing.SwingUtilities;31 30 import javax.swing.UIManager; 32 31 33 32 import org.openstreetmap.josm.gui.help.HelpBrowser; 34 33 import org.openstreetmap.josm.gui.help.HelpUtil; 34 import org.openstreetmap.josm.gui.util.GuiHelper; 35 35 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 36 36 import org.openstreetmap.josm.tools.GBC; … … 538 538 /** 539 539 * Sets the button that will react to ENTER. 540 * @param defaultButtonIdx The button index (starts to )540 * @param defaultButtonIdx The button index (starts to 1) 541 541 * @return {@code this} 542 542 */ … … 558 558 559 559 /** 560 * Don't focus the "do not show this again" check box, but the default button.560 * Always makes sure the default button has initial focus. 561 561 */ 562 562 protected void fixFocus() { 563 if (toggleable && defaultButton != null) { 564 SwingUtilities.invokeLater(new Runnable() { 565 @Override public void run() { 563 if (defaultButton != null) { 564 GuiHelper.runInEDT(new Runnable() { 565 @Override 566 public void run() { 566 567 defaultButton.requestFocusInWindow(); 567 568 } -
trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java
r7376 r7401 25 25 import org.openstreetmap.josm.Main; 26 26 import org.openstreetmap.josm.actions.ShowStatusReportAction; 27 import org.openstreetmap.josm.data.Version; 27 28 import org.openstreetmap.josm.gui.ExtendedDialog; 28 29 import org.openstreetmap.josm.gui.preferences.plugin.PluginPreference; … … 56 57 @Override 57 58 public void run() { 58 // Give the user a chance to deactivate the plugin which threw the exception (if it was thrown from a plugin)59 // Give the user a chance to deactivate the plugin which threw the exception (if it was thrown from a plugin) 59 60 final PluginDownloadTask pluginDownloadTask = PluginHandler.updateOrdisablePluginAfterException(e); 60 61 … … 64 65 // Then ask for submitting a bug report, for exceptions thrown from a plugin too, unless updated to a new version 65 66 if (pluginDownloadTask == null) { 66 ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Unexpected Exception"), new String[] {tr("Do nothing"), tr("Report Bug")}); 67 String[] buttonTexts = new String[] {tr("Do nothing"), tr("Report Bug")}; 68 String[] buttonIcons = new String[] {"cancel", "bug"}; 69 int defaultButtonIdx = 1; 70 String message = tr("An unexpected exception occurred.<br>" + 71 "This is always a coding error. If you are running the latest<br>" + 72 "version of JOSM, please consider being kind and file a bug report." 73 ); 74 // Check user is running current tested version, the error may already be fixed 75 int josmVersion = Version.getInstance().getVersion(); 76 if (josmVersion != Version.JOSM_UNKNOWN_VERSION) { 77 try { 78 int latestVersion = Integer.parseInt(new WikiReader(). 79 read(Main.getJOSMWebsite()+"/wiki/TestedVersion?format=txt").trim()); 80 if (latestVersion > josmVersion) { 81 buttonTexts = new String[] {tr("Do nothing"), tr("Update JOSM"), tr("Report Bug")}; 82 buttonIcons = new String[] {"cancel", "download", "bug"}; 83 defaultButtonIdx = 2; 84 message = tr("An unexpected exception occurred. This is always a coding error.<br><br>" + 85 "However, you are running an old version of JOSM ({0}),<br>" + 86 "instead of using the current tested version (<b>{1}</b>).<br><br>"+ 87 "<b>Please update JOSM</b> before considering to file a bug report.", 88 String.valueOf(josmVersion), String.valueOf(latestVersion)); 89 } 90 } catch (IOException | NumberFormatException e) { 91 Main.warn("Unable to detect latest version of JOSM: "+e.getMessage()); 92 } 93 } 94 // Show dialog 95 ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Unexpected Exception"), buttonTexts); 96 ed.setButtonIcons(buttonIcons); 67 97 ed.setIcon(JOptionPane.ERROR_MESSAGE); 98 ed.setCancelButton(1); 99 ed.setDefaultButton(defaultButtonIdx); 68 100 JPanel pnl = new JPanel(new GridBagLayout()); 69 pnl.add(new JLabel( 70 "<html>" + tr("An unexpected exception occurred.<br>" + 71 "This is always a coding error. If you are running the latest<br>" + 72 "version of JOSM, please consider being kind and file a bug report." 73 ) 74 + "</html>"), GBC.eol()); 101 pnl.add(new JLabel("<html>" + message + "</html>"), GBC.eol()); 75 102 JCheckBox cbSuppress = null; 76 103 if (exceptionCounter > 1) { … … 83 110 suppressExceptionDialogs = true; 84 111 } 85 if (ed.getValue() != 2) return; 86 askForBugReport(e); 112 if (ed.getValue() <= 1) { 113 // "Do nothing" 114 return; 115 } else if (ed.getValue() < buttonTexts.length) { 116 // "Update JOSM" 117 try { 118 Main.platform.openUrl(Main.getJOSMWebsite()); 119 } catch (IOException e) { 120 Main.warn("Unable to access JOSM website: "+e.getMessage()); 121 } 122 } else { 123 // "Report bug" 124 askForBugReport(e); 125 } 87 126 } else { 88 127 // Ask for restart to install new plugin -
trunk/src/org/openstreetmap/josm/tools/WikiReader.java
r7033 r7401 36 36 * Read the page specified by the url and return the content. 37 37 * 38 * If the url is within the baseurl path, parse it as an trac wikipage and replace relative 39 * pathes etc.. 38 * If the url is within the baseurl path, parse it as an trac wikipage and replace relative paths etc.. 39 * @param url the URL to read 40 * @return The page as string 40 41 * 41 42 * @throws IOException Throws, if the page could not be loaded. … … 44 45 URL u = new URL(url); 45 46 try (BufferedReader in = Utils.openURLReader(u)) { 46 if (url.startsWith(baseurl) && !url.endsWith("?format=txt")) 47 boolean txt = url.endsWith("?format=txt"); 48 if (url.startsWith(baseurl) && !txt) 47 49 return readFromTrac(in, u); 48 return readNormal(in );50 return readNormal(in, !txt); 49 51 } 50 52 } 51 53 54 /** 55 * Reads the localized version of the given wiki page. 56 * @param text The page title, without locale prefix 57 * @return the localized version of the given wiki page 58 * @throws IOException if any I/O error occurs 59 */ 52 60 public String readLang(String text) throws IOException { 53 61 String languageCode; … … 89 97 } 90 98 91 private String readNormal(BufferedReader in ) throws IOException {99 private String readNormal(BufferedReader in, boolean html) throws IOException { 92 100 StringBuilder b = new StringBuilder(); 93 101 for (String line = in.readLine(); line != null; line = in.readLine()) { … … 96 104 } 97 105 } 98 return "<html>" + b + "</html>";106 return html ? "<html>" + b + "</html>" : b.toString(); 99 107 } 100 108
Note:
See TracChangeset
for help on using the changeset viewer.