Changeset 6642 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2014-01-06T15:57:41+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r6578 r6642 27 27 import java.util.List; 28 28 import java.util.Map; 29 import java.util.Set; 30 import java.util.TreeSet; 29 31 30 32 import javax.swing.JFrame; … … 87 89 mainFrame.setIconImages(l); 88 90 mainFrame.addWindowListener(new WindowAdapter(){ 89 @Override public void windowClosing(final WindowEvent arg0) { 91 @Override 92 public void windowClosing(final WindowEvent arg0) { 90 93 Main.exitJosm(true, 0); 91 94 } … … 297 300 298 301 Thread.setDefaultUncaughtExceptionHandler(new BugReportExceptionHandler()); 299 // http://stuffthathappens.com/blog/2007/10/15/one-more-note-on-uncaught-exception-handlers/ 302 // http://stackoverflow.com/q/75218/2257172 303 // To be replaced with official API when switching to Java 7: https://bugs.openjdk.java.net/browse/JDK-4714232 300 304 System.setProperty("sun.awt.exception.handler", BugReportExceptionHandler.class.getName()); 301 305 … … 441 445 public void run() { 442 446 443 // Handle proxy errors early to inform user he should change settings to be able to use JOSM correctly 444 handleProxyErrors(); 447 // Handle proxy/network errors early to inform user he should change settings to be able to use JOSM correctly 448 if (!handleProxyErrors()) { 449 handleNetworkErrors(); 450 } 445 451 446 452 // Restore autosave layers after crash and start autosave thread … … 480 486 } 481 487 482 private void handleProxyErrors() {483 if ( proxySelector.hasErrors()) {488 private boolean handleNetworkOrProxyErrors(boolean hasErrors, String title, String message) { 489 if (hasErrors) { 484 490 ExtendedDialog ed = new ExtendedDialog( 485 Main.parent, t r("Proxy errors occurred"),491 Main.parent, title, 486 492 new String[]{tr("Change proxy settings"), tr("Cancel")}); 487 493 ed.setButtonIcons(new String[]{"dialogs/settings.png", "cancel.png"}).setCancelButton(2); 488 494 ed.setMinimumSize(new Dimension(460, 260)); 489 495 ed.setIcon(JOptionPane.WARNING_MESSAGE); 490 ed.setContent(tr("JOSM tried to access the following resources:<br>" + 491 "{0}" + 492 "but <b>failed</b> to do so, because of the following proxy errors:<br>" + 493 "{1}" + 494 "Would you like to change your proxy settings now?", 495 Utils.joinAsHtmlUnorderedList(proxySelector.getErrorResources()), 496 Utils.joinAsHtmlUnorderedList(proxySelector.getErrorMessages()) 497 )); 496 ed.setContent(message); 498 497 499 498 if (ed.showDialog().getValue() == 1) { … … 501 500 } 502 501 } 502 return hasErrors; 503 } 504 505 private boolean handleProxyErrors() { 506 return handleNetworkOrProxyErrors(proxySelector.hasErrors(), tr("Proxy errors occurred"), 507 tr("JOSM tried to access the following resources:<br>" + 508 "{0}" + 509 "but <b>failed</b> to do so, because of the following proxy errors:<br>" + 510 "{1}" + 511 "Would you like to change your proxy settings now?", 512 Utils.joinAsHtmlUnorderedList(proxySelector.getErrorResources()), 513 Utils.joinAsHtmlUnorderedList(proxySelector.getErrorMessages()) 514 )); 515 } 516 517 private boolean handleNetworkErrors() { 518 boolean condition = !networkErrors.isEmpty(); 519 if (condition) { 520 Set<String> errors = new TreeSet<String>(); 521 for (Throwable t : networkErrors.values()) { 522 errors.add(t.toString()); 523 } 524 return handleNetworkOrProxyErrors(condition, tr("Network errors occurred"), 525 tr("JOSM tried to access the following resources:<br>" + 526 "{0}" + 527 "but <b>failed</b> to do so, because of the following network errors:<br>" + 528 "{1}" + 529 "It may result of a missing proxy configuration.<br>" + 530 "Would you like to change your proxy settings now?", 531 Utils.joinAsHtmlUnorderedList(networkErrors.keySet()), 532 Utils.joinAsHtmlUnorderedList(errors) 533 )); 534 } 535 return false; 503 536 } 504 537 }
Note:
See TracChangeset
for help on using the changeset viewer.