Changeset 10611 in josm for trunk/src/org/openstreetmap/josm/gui/MainApplication.java
- Timestamp:
- 2016-07-23T18:46:45+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r10508 r10611 34 34 import java.util.Set; 35 35 import java.util.TreeSet; 36 import java.util.concurrent.Callable;37 36 38 37 import javax.swing.JOptionPane; … … 426 425 OAuthAccessTokenHolder.getInstance().init(Main.pref, CredentialsManager.getInstance()); 427 426 428 final SplashScreen splash = GuiHelper.runInEDTAndWaitAndReturn(new Callable<SplashScreen>() { 429 @Override 430 public SplashScreen call() { 431 return new SplashScreen(); 432 } 433 }); 427 final SplashScreen splash = GuiHelper.runInEDTAndWaitAndReturn(SplashScreen::new); 434 428 final SplashScreen.SplashProgressMonitor monitor = splash.getProgressMonitor(); 435 429 monitor.beginTask(tr("Initializing")); 436 GuiHelper.runInEDT(new Runnable() { 437 @Override 438 public void run() { 439 splash.setVisible(Main.pref.getBoolean("draw.splashscreen", true)); 440 } 441 }); 430 GuiHelper.runInEDT(() -> splash.setVisible(Main.pref.getBoolean("draw.splashscreen", true))); 442 431 Main.setInitStatusListener(new InitStatusListener() { 443 432 … … 474 463 475 464 // Wait for splash disappearance (fix #9714) 476 GuiHelper.runInEDTAndWait(new Runnable() { 477 @Override 478 public void run() { 479 splash.setVisible(false); 480 splash.dispose(); 481 mainFrame.setVisible(true); 482 } 465 GuiHelper.runInEDTAndWait(() -> { 466 splash.setVisible(false); 467 splash.dispose(); 468 mainFrame.setVisible(true); 483 469 }); 484 470 … … 571 557 private static void checkIPv6() { 572 558 if ("auto".equals(Main.pref.get("prefer.ipv6", "auto"))) { 573 new Thread(new Runnable() { /* this may take some time (DNS, Connect) */ 574 @Override 575 public void run() { 576 boolean hasv6 = false; 577 boolean wasv6 = Main.pref.getBoolean("validated.ipv6", false); 578 try { 579 /* Use the check result from last run of the software, as after the test, value 580 changes have no effect anymore */ 581 if (wasv6) { 582 Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true"); 583 } 584 for (InetAddress a : InetAddress.getAllByName("josm.openstreetmap.de")) { 585 if (a instanceof Inet6Address) { 586 if (a.isReachable(1000)) { 587 /* be sure it REALLY works */ 588 Socket s = new Socket(); 589 s.connect(new InetSocketAddress(a, 80), 1000); 590 s.close(); 591 Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true"); 592 if (!wasv6) { 593 Main.info(tr("Detected useable IPv6 network, prefering IPv6 over IPv4 after next restart.")); 594 } else { 595 Main.info(tr("Detected useable IPv6 network, prefering IPv6 over IPv4.")); 596 } 597 hasv6 = true; 559 new Thread((Runnable) () -> { /* this may take some time (DNS, Connect) */ 560 boolean hasv6 = false; 561 boolean wasv6 = Main.pref.getBoolean("validated.ipv6", false); 562 try { 563 /* Use the check result from last run of the software, as after the test, value 564 changes have no effect anymore */ 565 if (wasv6) { 566 Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true"); 567 } 568 for (InetAddress a : InetAddress.getAllByName("josm.openstreetmap.de")) { 569 if (a instanceof Inet6Address) { 570 if (a.isReachable(1000)) { 571 /* be sure it REALLY works */ 572 Socket s = new Socket(); 573 s.connect(new InetSocketAddress(a, 80), 1000); 574 s.close(); 575 Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true"); 576 if (!wasv6) { 577 Main.info(tr("Detected useable IPv6 network, prefering IPv6 over IPv4 after next restart.")); 578 } else { 579 Main.info(tr("Detected useable IPv6 network, prefering IPv6 over IPv4.")); 598 580 } 599 break; /* we're done */581 hasv6 = true; 600 582 } 601 } 602 } catch (IOException | SecurityException e) { 603 if (Main.isDebugEnabled()) { 604 Main.debug("Exception while checking IPv6 connectivity: "+e); 583 break; /* we're done */ 605 584 } 606 585 } 607 if (wasv6 && !hasv6) { 608 Main.info(tr("Detected no useable IPv6 network, prefering IPv4 over IPv6 after next restart.")); 609 Main.pref.put("validated.ipv6", hasv6); // be sure it is stored before the restart! 610 new RestartAction().actionPerformed(null); 586 } catch (IOException | SecurityException e) { 587 if (Main.isDebugEnabled()) { 588 Main.debug("Exception while checking IPv6 connectivity: "+e); 611 589 } 612 Main.pref.put("validated.ipv6", hasv6); 613 } 590 } 591 if (wasv6 && !hasv6) { 592 Main.info(tr("Detected no useable IPv6 network, prefering IPv4 over IPv6 after next restart.")); 593 Main.pref.put("validated.ipv6", hasv6); // be sure it is stored before the restart! 594 new RestartAction().actionPerformed(null); 595 } 596 Main.pref.put("validated.ipv6", hasv6); 614 597 }, "IPv6-checker").start(); 615 598 }
Note:
See TracChangeset
for help on using the changeset viewer.