Changeset 10611 in josm
- Timestamp:
- 2016-07-23T18:46:45+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 155 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r10608 r10611 256 256 * @see #FLAG_HAS_DIRECTIONS 257 257 */ 258 public static final Predicate<Tag> directionalKeyPredicate = tag -> directionKeys.match(tag);258 public static final Predicate<Tag> directionalKeyPredicate = directionKeys::match; 259 259 260 260 /** -
trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
r10378 r10611 194 194 } 195 195 196 private final Comparator<Node> nodeComparator = new Comparator<Node>() { 197 @Override 198 public int compare(Node n1, Node n2) { 199 return format(n1).compareTo(format(n2)); 200 } 201 }; 196 private final Comparator<Node> nodeComparator = (n1, n2) -> format(n1).compareTo(format(n2)); 202 197 203 198 @Override … … 289 284 } 290 285 291 private final Comparator<Way> wayComparator = new Comparator<Way>() { 292 @Override 293 public int compare(Way w1, Way w2) { 294 return format(w1).compareTo(format(w2)); 295 } 296 }; 286 private final Comparator<Way> wayComparator = (w1, w2) -> format(w1).compareTo(format(w2)); 297 287 298 288 @Override … … 349 339 } 350 340 351 private final Comparator<Relation> relationComparator = new Comparator<Relation>() { 352 @Override 353 public int compare(Relation r1, Relation r2) { 354 //TODO This doesn't work correctly with formatHooks 355 356 TaggingPreset preset1 = TaggingPresetNameTemplateList.getInstance().findPresetTemplate(r1); 357 TaggingPreset preset2 = TaggingPresetNameTemplateList.getInstance().findPresetTemplate(r2); 358 359 if (preset1 != null || preset2 != null) { 360 String name1 = formatRelationNameAndType(r1, new StringBuilder(), preset1).toString(); 361 String name2 = formatRelationNameAndType(r2, new StringBuilder(), preset2).toString(); 362 363 int comp = AlphanumComparator.getInstance().compare(name1, name2); 364 if (comp != 0) 365 return comp; 366 } else { 367 368 String type1 = getRelationTypeName(r1); 369 String type2 = getRelationTypeName(r2); 370 371 int comp = AlphanumComparator.getInstance().compare(type1, type2); 372 if (comp != 0) 373 return comp; 374 375 String name1 = getRelationName(r1); 376 String name2 = getRelationName(r2); 377 378 comp = AlphanumComparator.getInstance().compare(name1, name2); 379 if (comp != 0) 380 return comp; 381 } 382 383 int comp = Integer.compare(r1.getMembersCount(), r2.getMembersCount()); 384 if (comp != 0) 385 return comp; 386 387 388 comp = Boolean.compare(r1.hasIncompleteMembers(), r2.hasIncompleteMembers()); 389 if (comp != 0) 390 return comp; 391 392 return Long.compare(r1.getUniqueId(), r2.getUniqueId()); 393 } 341 private final Comparator<Relation> relationComparator = (r1, r2) -> { 342 //TODO This doesn't work correctly with formatHooks 343 344 TaggingPreset preset1 = TaggingPresetNameTemplateList.getInstance().findPresetTemplate(r1); 345 TaggingPreset preset2 = TaggingPresetNameTemplateList.getInstance().findPresetTemplate(r2); 346 347 if (preset1 != null || preset2 != null) { 348 String name11 = formatRelationNameAndType(r1, new StringBuilder(), preset1).toString(); 349 String name21 = formatRelationNameAndType(r2, new StringBuilder(), preset2).toString(); 350 351 int comp1 = AlphanumComparator.getInstance().compare(name11, name21); 352 if (comp1 != 0) 353 return comp1; 354 } else { 355 356 String type1 = getRelationTypeName(r1); 357 String type2 = getRelationTypeName(r2); 358 359 int comp2 = AlphanumComparator.getInstance().compare(type1, type2); 360 if (comp2 != 0) 361 return comp2; 362 363 String name12 = getRelationName(r1); 364 String name22 = getRelationName(r2); 365 366 comp2 = AlphanumComparator.getInstance().compare(name12, name22); 367 if (comp2 != 0) 368 return comp2; 369 } 370 371 int comp3 = Integer.compare(r1.getMembersCount(), r2.getMembersCount()); 372 if (comp3 != 0) 373 return comp3; 374 375 376 comp3 = Boolean.compare(r1.hasIncompleteMembers(), r2.hasIncompleteMembers()); 377 if (comp3 != 0) 378 return comp3; 379 380 return Long.compare(r1.getUniqueId(), r2.getUniqueId()); 394 381 }; 395 382 … … 644 631 */ 645 632 public String formatAsHtmlUnorderedList(Collection<? extends OsmPrimitive> primitives, int maxElements) { 646 final Collection<String> displayNames = Utils.transform(primitives, new Function<OsmPrimitive, String>() { 647 648 @Override 649 public String apply(OsmPrimitive x) { 650 return x.getDisplayName(DefaultNameFormatter.this); 651 } 652 }); 633 final Collection<String> displayNames = Utils.transform(primitives, 634 (Function<OsmPrimitive, String>) x -> x.getDisplayName(DefaultNameFormatter.this)); 653 635 return Utils.joinAsHtmlUnorderedList(Utils.limit(displayNames, maxElements, "...")); 654 636 } -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r10378 r10611 576 576 private void requestFocusToDefaultButton() { 577 577 if (defaultButton != null) { 578 GuiHelper.runInEDT(new Runnable() { 579 @Override 580 public void run() { 581 defaultButton.requestFocusInWindow(); 582 } 583 }); 578 GuiHelper.runInEDT(() -> defaultButton.requestFocusInWindow()); 584 579 } 585 580 } -
trunk/src/org/openstreetmap/josm/gui/FileDrop.java
r10600 r10611 16 16 import java.awt.dnd.DropTargetListener; 17 17 import java.awt.dnd.InvalidDnDOperationException; 18 import java.awt.event.HierarchyEvent;19 import java.awt.event.HierarchyListener;20 18 import java.io.BufferedReader; 21 19 import java.io.File; … … 97 95 BorderFactory.createMatteBorder(2, 2, 2, 2, defaultBorderColor), // Drag border 98 96 true, // Recursive 99 new FileDrop.Listener() { 100 @Override 101 public void filesDropped(File[] files) { 102 // start asynchronous loading of files 103 OpenFileAction.OpenFileTask task = new OpenFileAction.OpenFileTask(Arrays.asList(files), null); 104 task.setRecordHistory(true); 105 Main.worker.submit(task); 106 } 97 files -> { 98 // start asynchronous loading of files 99 OpenFileAction.OpenFileTask task = new OpenFileAction.OpenFileTask(Arrays.asList(files), null); 100 task.setRecordHistory(true); 101 Main.worker.submit(task); 107 102 } 108 103 ); … … 173 168 174 169 // Listen for hierarchy changes and remove the drop target when the parent gets cleared out. 175 c.addHierarchyListener(new HierarchyListener() { 176 @Override 177 public void hierarchyChanged(HierarchyEvent evt) { 178 Main.trace("FileDrop: Hierarchy changed."); 179 Component parent = c.getParent(); 180 if (parent == null) { 181 c.setDropTarget(null); 182 Main.trace("FileDrop: Drop target cleared from component."); 183 } else { 184 new DropTarget(c, dropListener); 185 Main.trace("FileDrop: Drop target added to component."); 186 } 170 c.addHierarchyListener(evt -> { 171 Main.trace("FileDrop: Hierarchy changed."); 172 Component parent = c.getParent(); 173 if (parent == null) { 174 c.setDropTarget(null); 175 Main.trace("FileDrop: Drop target cleared from component."); 176 } else { 177 new DropTarget(c, dropListener); 178 Main.trace("FileDrop: Drop target added to component."); 187 179 } 188 180 }); -
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r8846 r10611 139 139 private void getMOTD() { 140 140 // Asynchronously get MOTD to speed-up JOSM startup 141 Thread t = new Thread(new Runnable() { 142 @Override 143 public void run() { 144 if (!contentInitialized && Main.pref.getBoolean("help.displaymotd", true)) { 145 try { 146 content = new MotdContent().updateIfRequiredString(); 147 contentInitialized = true; 148 ProxyPreference.removeProxyPreferenceListener(GettingStarted.this); 149 } catch (IOException ex) { 150 Main.warn(tr("Failed to read MOTD. Exception was: {0}", ex.toString())); 151 content = "<html>" + STYLE + "<h1>" + "JOSM - " + tr("Java OpenStreetMap Editor") 152 + "</h1>\n<h2 align=\"center\">(" + tr("Message of the day not available") + ")</h2></html>"; 153 // In case of MOTD not loaded because of proxy error, listen to preference changes to retry after update 154 ProxyPreference.addProxyPreferenceListener(GettingStarted.this); 155 } 141 Thread t = new Thread((Runnable) () -> { 142 if (!contentInitialized && Main.pref.getBoolean("help.displaymotd", true)) { 143 try { 144 content = new MotdContent().updateIfRequiredString(); 145 contentInitialized = true; 146 ProxyPreference.removeProxyPreferenceListener(GettingStarted.this); 147 } catch (IOException ex) { 148 Main.warn(tr("Failed to read MOTD. Exception was: {0}", ex.toString())); 149 content = "<html>" + STYLE + "<h1>" + "JOSM - " + tr("Java OpenStreetMap Editor") 150 + "</h1>\n<h2 align=\"center\">(" + tr("Message of the day not available") + ")</h2></html>"; 151 // In case of MOTD not loaded because of proxy error, listen to preference changes to retry after update 152 ProxyPreference.addProxyPreferenceListener(GettingStarted.this); 156 153 } 154 } 157 155 158 if (content != null) { 159 EventQueue.invokeLater(new Runnable() { 160 @Override 161 public void run() { 162 lg.setText(fixImageLinks(content)); 163 } 164 }); 165 } 156 if (content != null) { 157 EventQueue.invokeLater(() -> lg.setText(fixImageLinks(content))); 166 158 } 167 159 }, "MOTD-Loader"); -
trunk/src/org/openstreetmap/josm/gui/HelpAwareOptionPane.java
r10378 r10611 152 152 b.setFocusable(true); 153 153 b.setEnabled(spec.isEnabled()); 154 spec.addChangeListener(new ChangeListener() { 155 @Override public void stateChanged(ChangeEvent e) { 156 b.setEnabled(spec.isEnabled()); 157 } 158 }); 154 spec.addChangeListener(e -> b.setEnabled(spec.isEnabled())); 159 155 buttons.add(b); 160 156 } … … 353 349 public static void showMessageDialogInEDT(final Component parentComponent, final Object msg, final String title, 354 350 final int messageType, final String helpTopic) { 355 GuiHelper.runInEDT(new Runnable() { 356 @Override 357 public void run() { 358 showOptionDialog(parentComponent, msg, title, messageType, null, null, null, helpTopic); 359 } 360 }); 351 GuiHelper.runInEDT(() -> showOptionDialog(parentComponent, msg, title, messageType, null, null, null, helpTopic)); 361 352 } 362 353 } -
trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
r10378 r10611 54 54 * (for the preferences). We don't want this in the imagery menu. 55 55 */ 56 public static final Comparator<ImageryInfo> alphabeticImageryComparator = new Comparator<ImageryInfo>() { 57 @Override 58 public int compare(ImageryInfo ii1, ImageryInfo ii2) { 59 return ii1.getName().toLowerCase(Locale.ENGLISH).compareTo(ii2.getName().toLowerCase(Locale.ENGLISH)); 60 } 61 }; 56 public static final Comparator<ImageryInfo> alphabeticImageryComparator = 57 (ii1, ii2) -> ii1.getName().toLowerCase(Locale.ENGLISH).compareTo(ii2.getName().toLowerCase(Locale.ENGLISH)); 62 58 63 59 private final transient Action offsetAction = new JosmAction( -
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 } -
trunk/src/org/openstreetmap/josm/gui/MainFrame.java
r10432 r10611 14 14 import java.awt.event.WindowAdapter; 15 15 import java.awt.event.WindowEvent; 16 import java.beans.PropertyChangeEvent;17 16 import java.beans.PropertyChangeListener; 18 17 import java.util.LinkedList; … … 27 26 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 28 27 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 29 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;30 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;31 28 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 32 29 import org.openstreetmap.josm.gui.layer.OsmDataLayer.LayerStateChangeListener; … … 40 37 */ 41 38 public class MainFrame extends JFrame { 42 private final transient LayerStateChangeListener updateTitleOnLayerStateChange = new LayerStateChangeListener() { 43 @Override 44 public void uploadDiscouragedChanged(OsmDataLayer layer, boolean newValue) { 39 private final transient LayerStateChangeListener updateTitleOnLayerStateChange = (layer, newValue) -> onLayerChange(layer); 40 41 private final transient PropertyChangeListener updateTitleOnSaveChange = evt -> { 42 if (evt.getPropertyName().equals(OsmDataLayer.REQUIRES_SAVE_TO_DISK_PROP) 43 || evt.getPropertyName().equals(OsmDataLayer.REQUIRES_UPLOAD_TO_SERVER_PROP)) { 44 OsmDataLayer layer = (OsmDataLayer) evt.getSource(); 45 45 onLayerChange(layer); 46 }47 };48 49 private final transient PropertyChangeListener updateTitleOnSaveChange = new PropertyChangeListener() {50 @Override51 public void propertyChange(PropertyChangeEvent evt) {52 if (evt.getPropertyName().equals(OsmDataLayer.REQUIRES_SAVE_TO_DISK_PROP)53 || evt.getPropertyName().equals(OsmDataLayer.REQUIRES_UPLOAD_TO_SERVER_PROP)) {54 OsmDataLayer layer = (OsmDataLayer) evt.getSource();55 onLayerChange(layer);56 }57 46 } 58 47 }; … … 102 91 addWindowListener(new WindowAdapter() { 103 92 @Override 104 public void windowClosing(final WindowEvent arg0) {93 public void windowClosing(final WindowEvent evt) { 105 94 Main.exitJosm(true, 0); 106 95 } … … 109 98 110 99 // This listener is never removed, since the main frame exists forever. 111 Main.getLayerManager().addActiveLayerChangeListener(new ActiveLayerChangeListener() { 112 @Override 113 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 114 refreshTitle(); 115 } 116 }); 100 Main.getLayerManager().addActiveLayerChangeListener(e -> refreshTitle()); 117 101 Main.getLayerManager().addLayerChangeListener(new ManageLayerListeners(), true); 118 102 -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r10345 r10611 113 113 import org.openstreetmap.josm.actions.audio.AudioSlowerAction; 114 114 import org.openstreetmap.josm.actions.search.SearchAction; 115 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;116 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;117 115 import org.openstreetmap.josm.gui.dialogs.MenuItemSearchDialog; 118 116 import org.openstreetmap.josm.gui.io.RecentlyOpenedFilesMenu; … … 803 801 } 804 802 805 Main.pref.addPreferenceChangeListener(new PreferenceChangedListener() { 806 @Override 807 public void preferenceChanged(PreferenceChangeEvent e) { 808 if ("audio.menuinvisible".equals(e.getKey())) { 809 showAudioMenu(!Boolean.parseBoolean(e.getNewValue().toString())); 810 } 803 Main.pref.addPreferenceChangeListener(e -> { 804 if ("audio.menuinvisible".equals(e.getKey())) { 805 showAudioMenu(!Boolean.parseBoolean(e.getNewValue().toString())); 811 806 } 812 807 }); -
trunk/src/org/openstreetmap/josm/gui/MainPanel.java
r10508 r10611 163 163 } 164 164 }); 165 GuiHelper.runInEDTAndWait(new Runnable() { 166 @Override 167 public void run() { 168 updateContent(!layerManager.getLayers().isEmpty()); 169 } 170 }); 165 GuiHelper.runInEDTAndWait(() -> updateContent(!layerManager.getLayers().isEmpty())); 171 166 } 172 167 } -
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r10604 r10611 13 13 import java.awt.event.ActionEvent; 14 14 import java.awt.event.KeyEvent; 15 import java.awt.event.MouseWheelEvent;16 import java.awt.event.MouseWheelListener;17 15 import java.util.ArrayList; 18 16 import java.util.Collection; … … 53 51 import org.openstreetmap.josm.actions.mapmode.SelectAction; 54 52 import org.openstreetmap.josm.actions.mapmode.ZoomAction; 55 import org.openstreetmap.josm.data.Preferences;56 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;57 53 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; 58 54 import org.openstreetmap.josm.data.ViewportData; … … 497 493 if (Main.pref.getBoolean("sidetoolbar.scrollable", true)) { 498 494 final ScrollViewport svp = new ScrollViewport(sideToolBar, ScrollViewport.VERTICAL_DIRECTION); 499 svp.addMouseWheelListener(new MouseWheelListener() { 500 @Override 501 public void mouseWheelMoved(MouseWheelEvent e) { 502 svp.scroll(0, e.getUnitsToScroll() * 5); 503 } 504 }); 495 svp.addMouseWheelListener(e -> svp.scroll(0, e.getUnitsToScroll() * 5)); 505 496 sideToolBar = svp; 506 497 } 507 498 sideToolBar.setVisible(Main.pref.getBoolean("sidetoolbar.visible", true)); 508 sidetoolbarPreferencesChangedListener = new Preferences.PreferenceChangedListener() { 509 @Override 510 public void preferenceChanged(PreferenceChangeEvent e) { 511 if ("sidetoolbar.visible".equals(e.getKey())) { 512 sideToolBar.setVisible(Main.pref.getBoolean("sidetoolbar.visible")); 513 } 499 sidetoolbarPreferencesChangedListener = e -> { 500 if ("sidetoolbar.visible".equals(e.getKey())) { 501 sideToolBar.setVisible(Main.pref.getBoolean("sidetoolbar.visible")); 514 502 } 515 503 }; -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r10448 r10611 78 78 import org.openstreetmap.josm.tools.GBC; 79 79 import org.openstreetmap.josm.tools.ImageProvider; 80 import org.openstreetmap.josm.tools.Predicate;81 80 82 81 /** … … 294 293 // display them if the middle mouse button is pressed and keep them until the mouse is moved 295 294 if (middleMouseDown || isAtOldPosition) { 296 Collection<OsmPrimitive> osms = mv.getAllNearest(ms.mousePos, new Predicate<OsmPrimitive>() { 297 @Override 298 public boolean evaluate(OsmPrimitive o) { 299 return isUsablePredicate.evaluate(o) && isSelectablePredicate.evaluate(o); 300 } 301 }); 295 Collection<OsmPrimitive> osms = mv.getAllNearest(ms.mousePos, 296 o -> isUsablePredicate.evaluate(o) && isSelectablePredicate.evaluate(o)); 302 297 303 298 final JPanel c = new JPanel(new GridBagLayout()); … … 505 500 final Popup staticPopup = popup; 506 501 popup = null; 507 EventQueue.invokeLater(new Runnable() { 508 @Override 509 public void run() { 510 staticPopup.hide(); 511 } 512 }); 502 EventQueue.invokeLater(() -> staticPopup.hide()); 513 503 } 514 504 … … 524 514 // If an old popup exists, remove it when the new popup has been drawn to keep flickering to a minimum 525 515 final Popup staticOldPopup = this.popup; 526 EventQueue.invokeLater(new Runnable() { 527 @Override 528 public void run() { 529 staticPopup.show(); 530 staticOldPopup.hide(); 531 } 516 EventQueue.invokeLater(() -> { 517 staticPopup.show(); 518 staticOldPopup.hide(); 532 519 }); 533 520 } else { 534 521 // There is no old popup 535 EventQueue.invokeLater(new Runnable() { 536 @Override 537 public void run() { 538 staticPopup.show(); 539 } 540 }); 522 EventQueue.invokeLater(() -> staticPopup.show()); 541 523 } 542 524 this.popupLabels = lbls; … … 1010 992 statusText.add(entry); 1011 993 1012 GuiHelper.runInEDT(new Runnable() { 1013 @Override 1014 public void run() { 1015 helpText.setText(text); 1016 helpText.setToolTipText(text); 1017 } 994 GuiHelper.runInEDT(() -> { 995 helpText.setText(text); 996 helpText.setToolTipText(text); 1018 997 }); 1019 998 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r10604 r10611 48 48 import org.openstreetmap.josm.data.imagery.ImageryInfo; 49 49 import org.openstreetmap.josm.data.osm.DataSet; 50 import org.openstreetmap.josm.data.osm.OsmPrimitive;51 50 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 52 51 import org.openstreetmap.josm.data.osm.visitor.paint.Rendering; … … 1267 1266 } 1268 1267 1269 private final transient SelectionChangedListener repaintSelectionChangedListener = new SelectionChangedListener() { 1270 @Override 1271 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 1272 repaint(); 1273 } 1274 }; 1268 private final transient SelectionChangedListener repaintSelectionChangedListener = newSelection -> repaint(); 1275 1269 1276 1270 /** -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r10600 r10611 51 51 import org.openstreetmap.josm.data.preferences.IntegerProperty; 52 52 import org.openstreetmap.josm.data.projection.Projection; 53 import org.openstreetmap.josm.data.projection.ProjectionChangeListener;54 53 import org.openstreetmap.josm.data.projection.Projections; 55 54 import org.openstreetmap.josm.gui.help.Helpful; … … 84 83 } 85 84 86 public transient Predicate<OsmPrimitive> isSelectablePredicate = new Predicate<OsmPrimitive>() { 87 @Override 88 public boolean evaluate(OsmPrimitive prim) { 89 if (!prim.isSelectable()) return false; 90 // if it isn't displayed on screen, you cannot click on it 91 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock(); 92 try { 93 return !MapPaintStyles.getStyles().get(prim, getDist100Pixel(), NavigatableComponent.this).isEmpty(); 94 } finally { 95 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().unlock(); 96 } 85 public transient Predicate<OsmPrimitive> isSelectablePredicate = prim -> { 86 if (!prim.isSelectable()) return false; 87 // if it isn't displayed on screen, you cannot click on it 88 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock(); 89 try { 90 return !MapPaintStyles.getStyles().get(prim, getDist100Pixel(), NavigatableComponent.this).isEmpty(); 91 } finally { 92 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().unlock(); 97 93 } 98 94 }; … … 143 139 // The only events that may move/resize this map view are window movements or changes to the map view size. 144 140 // We can clean this up more by only recalculating the state on repaint. 145 private final transient HierarchyListener hierarchyListener = new HierarchyListener() { 146 @Override 147 public void hierarchyChanged(HierarchyEvent e) { 148 long interestingFlags = HierarchyEvent.ANCESTOR_MOVED | HierarchyEvent.SHOWING_CHANGED; 149 if ((e.getChangeFlags() & interestingFlags) != 0) { 150 updateLocationState(); 151 } 141 private final transient HierarchyListener hierarchyListener = e -> { 142 long interestingFlags = HierarchyEvent.ANCESTOR_MOVED | HierarchyEvent.SHOWING_CHANGED; 143 if ((e.getChangeFlags() & interestingFlags) != 0) { 144 updateLocationState(); 152 145 } 153 146 }; … … 181 174 state = MapViewState.createDefaultState(getWidth(), getHeight()); 182 175 // uses weak link. 183 Main.addProjectionChangeListener(new ProjectionChangeListener() { 184 @Override 185 public void projectionChanged(Projection oldValue, Projection newValue) { 186 fixProjection(); 187 } 188 }); 176 Main.addProjectionChangeListener((oldValue, newValue) -> fixProjection()); 189 177 } 190 178 -
trunk/src/org/openstreetmap/josm/gui/NotificationManager.java
r10256 r10611 218 218 @Override 219 219 public void actionPerformed(ActionEvent e) { 220 SwingUtilities.invokeLater(new Runnable() { 221 @Override 222 public void run() { 223 HelpBrowser.setUrlForHelpTopic(note.getHelpTopic()); 224 } 225 }); 220 SwingUtilities.invokeLater(() -> HelpBrowser.setUrlForHelpTopic(note.getHelpTopic())); 226 221 } 227 222 }); -
trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
r10223 r10611 96 96 finish(); 97 97 } else { 98 EventQueue.invokeAndWait(new Runnable() { 99 @Override 100 public void run() { 101 finish(); 102 } 103 }); 98 EventQueue.invokeAndWait(this::finish); 104 99 } 105 100 } … … 114 109 afterFinish(); 115 110 } else { 116 EventQueue.invokeAndWait(new Runnable() { 117 @Override 118 public void run() { 119 afterFinish(); 120 } 121 }); 111 EventQueue.invokeAndWait(this::afterFinish); 122 112 } 123 113 } … … 126 116 if (!ignoreException) { 127 117 // Exception has to thrown in EDT to be shown to user 128 SwingUtilities.invokeLater(new Runnable() { 129 @Override 130 public void run() { 131 if (e instanceof RuntimeException) { 132 BugReportExceptionHandler.handleException(e); 133 } else { 134 ExceptionDialogUtil.explainException(e); 135 } 118 SwingUtilities.invokeLater(() -> { 119 if (e instanceof RuntimeException) { 120 BugReportExceptionHandler.handleException(e); 121 } else { 122 ExceptionDialogUtil.explainException(e); 136 123 } 137 124 }); … … 150 137 public final void run() { 151 138 if (EventQueue.isDispatchThread()) { 152 new Thread(new Runnable() { 153 @Override 154 public void run() { 155 doRealRun(); 156 } 157 }, getClass().getName()).start(); 139 new Thread((Runnable) this::doRealRun, getClass().getName()).start(); 158 140 } else { 159 141 doRealRun(); -
trunk/src/org/openstreetmap/josm/gui/ScrollViewport.java
r10378 r10611 6 6 import java.awt.Point; 7 7 import java.awt.Rectangle; 8 import java.awt.event.ActionEvent;9 import java.awt.event.ActionListener;10 8 import java.awt.event.ComponentAdapter; 11 9 import java.awt.event.ComponentEvent; … … 70 68 private final List<JButton> buttons = new ArrayList<>(); 71 69 72 private final Timer timer = new Timer(100, new ActionListener() { 73 @Override 74 public void actionPerformed(ActionEvent arg0) { 75 ScrollViewport.this.scroll(); 76 } 77 }); 70 private final Timer timer = new Timer(100, evt -> ScrollViewport.this.scroll()); 78 71 79 72 private int scrollDirection = NO_SCROLL; -
trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
r10446 r10611 172 172 eventSource.addMouseMotionListener(this); 173 173 selectionEndedListener.addPropertyChangeListener(this); 174 eventSource.addPropertyChangeListener("scale", new PropertyChangeListener() { 175 @Override 176 public void propertyChange(PropertyChangeEvent evt) { 177 abortSelecting(); 178 } 179 }); 174 eventSource.addPropertyChangeListener("scale", evt -> abortSelecting()); 180 175 eventSource.addTemporaryLayer(selectionHintLayer); 181 176 } -
trunk/src/org/openstreetmap/josm/gui/SideButton.java
r10489 r10611 7 7 import java.awt.Insets; 8 8 import java.awt.event.ActionListener; 9 import java.beans.PropertyChangeEvent;10 9 import java.beans.PropertyChangeListener; 11 10 … … 85 84 // SideButton is constructed get the proper icon size 86 85 if (action != null) { 87 propertyChangeListener = new PropertyChangeListener() { 88 @Override 89 public void propertyChange(PropertyChangeEvent evt) { 90 if (javax.swing.Action.SMALL_ICON.equals(evt.getPropertyName())) { 91 fixIcon(null); 92 } 86 propertyChangeListener = evt -> { 87 if (javax.swing.Action.SMALL_ICON.equals(evt.getPropertyName())) { 88 fixIcon(null); 93 89 } 94 90 }; -
trunk/src/org/openstreetmap/josm/gui/SplashScreen.java
r10428 r10611 119 119 @Override 120 120 public void stateChanged(ChangeEvent ignore) { 121 GuiHelper.runInEDT(new Runnable() { 122 @Override 123 public void run() { 124 progressRenderer.setTasks(progressMonitor.toString()); 125 } 126 }); 121 GuiHelper.runInEDT(() -> progressRenderer.setTasks(progressMonitor.toString())); 127 122 } 128 123 -
trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
r10600 r10611 96 96 private static CopyOnWriteArrayList<TileSourceProvider> providers = new CopyOnWriteArrayList<>(); 97 97 static { 98 addTileSourceProvider(new TileSourceProvider() { 99 @Override 100 public List<TileSource> getTileSources() { 101 return Arrays.<TileSource>asList( 102 new OsmTileSource.Mapnik(), 103 new OsmTileSource.CycleMap()); 104 } 105 }); 98 addTileSourceProvider(() -> Arrays.<TileSource>asList( 99 new OsmTileSource.Mapnik(), 100 new OsmTileSource.CycleMap())); 106 101 addTileSourceProvider(new TMSTileSourceProvider()); 107 102 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r10454 r10611 806 806 public void adapt(final JToggleButton btn) { 807 807 btn.addItemListener(this); 808 addPropertyChangeListener( 809 new PropertyChangeListener() { 810 @Override 811 public void propertyChange(PropertyChangeEvent evt) { 812 if (evt.getPropertyName().equals(PROP_SELECTED)) { 813 btn.setSelected((Boolean) evt.getNewValue()); 814 } 815 } 808 addPropertyChangeListener(evt -> { 809 if (evt.getPropertyName().equals(PROP_SELECTED)) { 810 btn.setSelected((Boolean) evt.getNewValue()); 816 811 } 817 );812 }); 818 813 } 819 814 -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
r10527 r10611 98 98 public static synchronized CombinePrimitiveResolverDialog getInstance() { 99 99 if (instance == null) { 100 GuiHelper.runInEDTAndWait(new Runnable() { 101 @Override public void run() { 102 instance = new CombinePrimitiveResolverDialog(Main.parent); 103 } 104 }); 100 GuiHelper.runInEDTAndWait(() -> instance = new CombinePrimitiveResolverDialog(Main.parent)); 105 101 } 106 102 return instance; … … 136 132 public void setTargetPrimitive(final OsmPrimitive primitive) { 137 133 this.targetPrimitive = primitive; 138 GuiHelper.runInEDTAndWait(new Runnable() { 139 @Override public void run() { 140 updateTitle(); 141 if (primitive instanceof Way) { 142 pnlRelationMemberConflictResolver.initForWayCombining(); 143 } else if (primitive instanceof Node) { 144 pnlRelationMemberConflictResolver.initForNodeMerging(); 145 } 134 GuiHelper.runInEDTAndWait(() -> { 135 updateTitle(); 136 if (primitive instanceof Way) { 137 pnlRelationMemberConflictResolver.initForWayCombining(); 138 } else if (primitive instanceof Node) { 139 pnlRelationMemberConflictResolver.initForNodeMerging(); 146 140 } 147 141 }); … … 576 570 final TagCollection normalizedTags) throws UserCancelException { 577 571 String conflicts = Utils.joinAsHtmlUnorderedList(Utils.transform(normalizedTags.getKeysWithMultipleValues(), 578 new Function<String, String>() { 579 @Override 580 public String apply(String key) { 581 return tr("{0} ({1})", key, Utils.join(tr(", "), Utils.transform(normalizedTags.getValues(key), 582 new Function<String, String>() { 583 @Override 584 public String apply(String x) { 585 return x == null || x.isEmpty() ? tr("<i>missing</i>") : x; 586 } 587 }))); 588 } 589 })); 572 (Function<String, String>) key -> tr("{0} ({1})", key, Utils.join(tr(", "), Utils.transform(normalizedTags.getValues(key), 573 (Function<String, String>) x -> x == null || x.isEmpty() ? tr("<i>missing</i>") : x))))); 590 574 String msg = /* for correct i18n of plural forms - see #9110 */ trn("You are about to combine {0} objects, " 591 575 + "but the following tags are used conflictingly:<br/>{1}" -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellEditor.java
r9078 r10611 9 9 import java.awt.event.FocusEvent; 10 10 import java.awt.event.ItemEvent; 11 import java.awt.event.ItemListener;12 11 import java.awt.event.KeyEvent; 13 12 import java.util.concurrent.CopyOnWriteArrayList; … … 120 119 } 121 120 ); 122 editor.addItemListener( 123 new ItemListener() { 124 @Override 125 public void itemStateChanged(ItemEvent e) { 126 if (e.getStateChange() == ItemEvent.SELECTED) 127 fireEditingStopped(); 128 } 129 } 130 ); 121 editor.addItemListener(e -> { 122 if (e.getStateChange() == ItemEvent.SELECTED) 123 fireEditingStopped(); 124 }); 131 125 editor.setRenderer(new EditorCellRenderer()); 132 126 listeners = new CopyOnWriteArrayList<>(); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionEditor.java
r9143 r10611 3 3 4 4 import java.awt.Component; 5 import java.awt.event.ActionEvent;6 import java.awt.event.ActionListener;7 5 import java.util.EventObject; 8 6 … … 38 36 @Override 39 37 public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { 40 addActionListener(new ActionListener() { 41 @Override 42 public void actionPerformed(ActionEvent e) { 43 stopCellEditing(); 44 } 45 }); 38 addActionListener(e -> stopCellEditing()); 46 39 setSelectedItem(value); 47 40 this.originalValue = (RelationMemberConflictDecisionType) value; -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java
r10308 r10611 29 29 }; 30 30 31 private final transient TableCellRenderer tableRenderer = new TableCellRenderer() { 32 @Override 33 public Component getTableCellRendererComponent(JTable table, Object value, 34 boolean isSelected, boolean hasFocus, int row, int column) { 35 return setColors(defaultTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column), 36 table, isSelected, row); 37 } 38 }; 31 private final transient TableCellRenderer tableRenderer = (table, value, isSelected, hasFocus, row, column) 32 -> setColors(defaultTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column), 33 table, isSelected, row); 39 34 40 35 private static Component setColors(Component comp, JTable table, boolean isSelected, int row) { -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java
r10593 r10611 25 25 import org.openstreetmap.josm.data.osm.RelationToChildReference; 26 26 import org.openstreetmap.josm.gui.util.GuiHelper; 27 import org.openstreetmap.josm.tools.Predicate;28 27 import org.openstreetmap.josm.tools.Utils; 29 28 … … 235 234 iterators.add(i.iterator()); 236 235 } 237 while (Utils.forAll(iterators, new Predicate<Iterator<RelationMemberConflictDecision>>() { 238 @Override 239 public boolean evaluate(Iterator<RelationMemberConflictDecision> it) { 240 return it.hasNext(); 241 } 242 })) { 236 while (Utils.forAll(iterators, it -> it.hasNext())) { 243 237 final List<RelationMemberConflictDecision> decisions = new ArrayList<>(); 244 238 final Collection<String> roles = new HashSet<>(); … … 310 304 public void refresh() { 311 305 updateNumConflicts(); 312 GuiHelper.runInEDTAndWait(new Runnable() { 313 @Override public void run() { 314 fireTableDataChanged(); 315 } 316 }); 306 GuiHelper.runInEDTAndWait(this::fireTableDataChanged); 317 307 } 318 308 -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolver.java
r10179 r10611 13 13 import javax.swing.JPanel; 14 14 import javax.swing.JScrollPane; 15 import javax.swing.event.ChangeEvent;16 import javax.swing.event.ChangeListener;17 15 18 16 import org.openstreetmap.josm.Main; … … 56 54 pnl.add(cbShowTagsWithConflictsOnly, gc); 57 55 pnl.add(cbShowTagsWithMultiValuesOnly, gc); 58 cbShowTagsWithConflictsOnly.addChangeListener( 59 new ChangeListener() { 60 @Override 61 public void stateChanged(ChangeEvent e) { 62 model.setShowTagsWithConflictsOnly(cbShowTagsWithConflictsOnly.isSelected()); 63 cbShowTagsWithMultiValuesOnly.setEnabled(cbShowTagsWithConflictsOnly.isSelected()); 64 } 65 } 66 ); 56 cbShowTagsWithConflictsOnly.addChangeListener(e -> { 57 model.setShowTagsWithConflictsOnly(cbShowTagsWithConflictsOnly.isSelected()); 58 cbShowTagsWithMultiValuesOnly.setEnabled(cbShowTagsWithConflictsOnly.isSelected()); 59 }); 67 60 cbShowTagsWithConflictsOnly.setSelected( 68 61 Main.pref.getBoolean(getClass().getName() + ".showTagsWithConflictsOnly", false) 69 62 ); 70 63 cbShowTagsWithMultiValuesOnly.addChangeListener( 71 new ChangeListener() { 72 @Override 73 public void stateChanged(ChangeEvent e) { 74 model.setShowTagsWithMultiValuesOnly(cbShowTagsWithMultiValuesOnly.isSelected()); 75 } 76 } 64 e -> model.setShowTagsWithMultiValuesOnly(cbShowTagsWithMultiValuesOnly.isSelected()) 77 65 ); 78 66 cbShowTagsWithMultiValuesOnly.setSelected( -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverModel.java
r10593 r10611 6 6 import java.util.ArrayList; 7 7 import java.util.Collections; 8 import java.util.Comparator;9 8 import java.util.HashMap; 10 9 import java.util.HashSet; … … 68 67 Collections.sort( 69 68 displayedKeys, 70 new Comparator<String>() { 71 @Override 72 public int compare(String key1, String key2) { 73 if (decisions.get(key1).isDecided() && !decisions.get(key2).isDecided()) 74 return 1; 75 else if (!decisions.get(key1).isDecided() && decisions.get(key2).isDecided()) 76 return -1; 77 return key1.compareTo(key2); 78 } 69 (key1, key2) -> { 70 if (decisions.get(key1).isDecided() && !decisions.get(key2).isDecided()) 71 return 1; 72 else if (!decisions.get(key1).isDecided() && decisions.get(key2).isDecided()) 73 return -1; 74 return key1.compareTo(key2); 79 75 } 80 76 ); … … 115 111 refreshNumConflicts(); 116 112 sort(); 117 GuiHelper.runInEDTAndWait(new Runnable() { 118 @Override public void run() { 119 fireTableDataChanged(); 120 } 121 }); 113 GuiHelper.runInEDTAndWait(this::fireTableDataChanged); 122 114 } 123 115 … … 184 176 } 185 177 } 186 GuiHelper.runInEDTAndWait(new Runnable() { 187 @Override public void run() { 188 fireTableDataChanged(); 189 } 190 }); 178 GuiHelper.runInEDTAndWait(this::fireTableDataChanged); 191 179 refreshNumConflicts(); 192 180 } -
trunk/src/org/openstreetmap/josm/gui/datatransfer/ClipboardUtils.java
r10604 r10611 12 12 import java.awt.datatransfer.UnsupportedFlavorException; 13 13 import java.io.IOException; 14 import java.util.concurrent.Callable;15 14 16 15 import org.openstreetmap.josm.Main; … … 139 138 */ 140 139 public static boolean copy(final Transferable transferable) { 141 return GuiHelper.runInEDTAndWaitAndReturn(new Callable<Boolean>() { 142 @Override 143 public Boolean call() throws Exception { 144 try { 145 getClipboard().setContents(transferable, new DoNothingClipboardOwner()); 146 return true; 147 } catch (IllegalStateException ex) { 148 Main.error(ex); 149 return false; 150 } 140 return GuiHelper.runInEDTAndWaitAndReturn(() -> { 141 try { 142 getClipboard().setContents(transferable, new DoNothingClipboardOwner()); 143 return true; 144 } catch (IllegalStateException ex) { 145 Main.error(ex); 146 return false; 151 147 } 152 148 }); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java
r10453 r10611 522 522 } 523 523 524 Runnable r = new Runnable() { 525 @Override 526 public void run() { 527 // first, wait for the download task to finish, if a download task was launched 528 if (future != null) { 529 try { 530 future.get(); 531 } catch (InterruptedException e) { 532 Main.warn("InterruptedException in "+getClass().getSimpleName()+" while downloading changeset header"); 533 } catch (ExecutionException e) { 534 Main.error(e); 535 BugReportExceptionHandler.handleException(e.getCause()); 536 return; 537 } 524 Runnable r = () -> { 525 // first, wait for the download task to finish, if a download task was launched 526 if (future != null) { 527 try { 528 future.get(); 529 } catch (InterruptedException e1) { 530 Main.warn(e1, "InterruptedException in ChangesetDialog while downloading changeset header"); 531 } catch (ExecutionException e2) { 532 Main.error(e2); 533 BugReportExceptionHandler.handleException(e2.getCause()); 534 return; 538 535 } 539 if (task != null) {540 if (task.isCanceled())541 // don't launch the changeset manager if the download task was canceled542 return;543 if (task.isFailed()) {544 toDownload.clear();545 }536 } 537 if (task != null) { 538 if (task.isCanceled()) 539 // don't launch the changeset manager if the download task was canceled 540 return; 541 if (task.isFailed()) { 542 toDownload.clear(); 546 543 } 547 // launch the task548 GuiHelper.runInEDT(new Runnable() {549 @Override550 public void run() {551 launchChangesetManager(sel);552 }553 });554 544 } 545 // launch the task 546 GuiHelper.runInEDT(() -> launchChangesetManager(sel)); 555 547 }; 556 548 Main.worker.submit(r); -
trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
r10600 r10611 49 49 import org.openstreetmap.josm.tools.ImageProvider; 50 50 import org.openstreetmap.josm.tools.InputMapUtils; 51 import org.openstreetmap.josm.tools.Predicate;52 51 import org.openstreetmap.josm.tools.Shortcut; 53 52 … … 197 196 addShowNotifyListener(updater); 198 197 199 tree.addTreeSelectionListener(new TreeSelectionListener() { 200 @Override 201 public void valueChanged(TreeSelectionEvent e) { 202 updater.updateEnabledState(); 203 } 204 }); 198 tree.addTreeSelectionListener(e -> updater.updateEnabledState()); 205 199 206 200 tree.getModel().addTreeModelListener(new TreeModelListener() { … … 342 336 return new FilteredCollection<>( 343 337 c.getParticipatingPrimitives(), 344 new Predicate<OsmPrimitive>() { 345 @Override 346 public boolean evaluate(OsmPrimitive o) { 347 OsmPrimitive p = currentLayer.data.getPrimitiveById(o); 348 return p != null && p.isUsable(); 349 } 338 o -> { 339 OsmPrimitive p = currentLayer.data.getPrimitiveById(o); 340 return p != null && p.isUsable(); 350 341 } 351 342 ); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r10446 r10611 123 123 lstConflicts.setCellRenderer(new OsmPrimitivRenderer()); 124 124 lstConflicts.addMouseListener(new MouseEventHandler()); 125 addListSelectionListener(new ListSelectionListener() { 126 @Override 127 public void valueChanged(ListSelectionEvent e) { 128 Main.map.mapView.repaint(); 129 } 130 }); 125 addListSelectionListener(e -> Main.map.mapView.repaint()); 131 126 132 127 SideButton btnResolve = new SideButton(actResolve); … … 236 231 OsmDataLayer editLayer = Main.getLayerManager().getEditLayer(); 237 232 conflicts = editLayer == null ? new ConflictCollection() : editLayer.getConflicts(); 238 GuiHelper.runInEDT(new Runnable() { 239 @Override 240 public void run() { 241 model.fireContentChanged(); 242 updateTitle(); 243 } 233 GuiHelper.runInEDT(() -> { 234 model.fireContentChanged(); 235 updateTitle(); 244 236 }); 245 237 } … … 597 589 ) 598 590 }; 599 GuiHelper.runInEDT(new Runnable() { 600 @Override 601 public void run() { 602 HelpAwareOptionPane.showOptionDialog( 603 Main.parent, 604 sb.toString(), 605 tr("Conflicts detected"), 606 JOptionPane.WARNING_MESSAGE, 607 null, /* no icon */ 608 options, 609 options[0], 610 ht("/Concepts/Conflict#WarningAboutDetectedConflicts") 611 ); 612 unfurlDialog(); 613 Main.map.repaint(); 614 } 591 GuiHelper.runInEDT(() -> { 592 HelpAwareOptionPane.showOptionDialog( 593 Main.parent, 594 sb.toString(), 595 tr("Conflicts detected"), 596 JOptionPane.WARNING_MESSAGE, 597 null, /* no icon */ 598 options, 599 options[0], 600 ht("/Concepts/Conflict#WarningAboutDetectedConflicts") 601 ); 602 unfurlDialog(); 603 Main.map.repaint(); 615 604 }); 616 605 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java
r10378 r10611 276 276 277 277 public void updateDialogHeader() { 278 SwingUtilities.invokeLater(new Runnable() { 279 @Override 280 public void run() { 281 setTitle(tr("Filter Hidden:{0} Disabled:{1}", filterModel.disabledAndHiddenCount, filterModel.disabledCount)); 282 } 283 }); 278 SwingUtilities.invokeLater(() -> setTitle( 279 tr("Filter Hidden:{0} Disabled:{1}", filterModel.disabledAndHiddenCount, filterModel.disabledCount))); 284 280 } 285 281 -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r10446 r10611 21 21 import javax.swing.JTabbedPane; 22 22 import javax.swing.SingleSelectionModel; 23 import javax.swing.event.ChangeEvent;24 import javax.swing.event.ChangeListener;25 23 26 24 import org.openstreetmap.josm.Main; … … 78 76 final JPanel pMapPaint = new JPanel(); 79 77 tabs.addTab(tr("map style"), pMapPaint); 80 tabs.getModel().addChangeListener(new ChangeListener() { 81 82 @Override 83 public void stateChanged(ChangeEvent e) { 84 if (!mappaintTabLoaded && ((SingleSelectionModel) e.getSource()).getSelectedIndex() == 1) { 85 mappaintTabLoaded = true; 86 genericMonospacePanel(pMapPaint, buildMapPaintText()); 87 } 78 tabs.getModel().addChangeListener(e -> { 79 if (!mappaintTabLoaded && ((SingleSelectionModel) e.getSource()).getSelectedIndex() == 1) { 80 mappaintTabLoaded = true; 81 genericMonospacePanel(pMapPaint, buildMapPaintText()); 88 82 } 89 83 }); … … 91 85 final JPanel pEditCounts = new JPanel(); 92 86 tabs.addTab(tr("edit counts"), pEditCounts); 93 tabs.getModel().addChangeListener(new ChangeListener() { 94 95 @Override 96 public void stateChanged(ChangeEvent e) { 97 if (!editcountTabLoaded && ((SingleSelectionModel) e.getSource()).getSelectedIndex() == 2) { 98 editcountTabLoaded = true; 99 genericMonospacePanel(pEditCounts, buildListOfEditorsText(primitives)); 100 } 87 tabs.getModel().addChangeListener(e -> { 88 if (!editcountTabLoaded && ((SingleSelectionModel) e.getSource()).getSelectedIndex() == 2) { 89 editcountTabLoaded = true; 90 genericMonospacePanel(pEditCounts, buildListOfEditorsText(primitives)); 101 91 } 102 92 }); -
trunk/src/org/openstreetmap/josm/gui/dialogs/LatLonDialog.java
r10300 r10611 22 22 import javax.swing.JTabbedPane; 23 23 import javax.swing.UIManager; 24 import javax.swing.event.ChangeEvent;25 import javax.swing.event.ChangeListener;26 24 import javax.swing.event.DocumentEvent; 27 25 import javax.swing.event.DocumentListener; … … 167 165 tabs.addTab(tr("Lat/Lon"), buildLatLon()); 168 166 tabs.addTab(tr("East/North"), buildEastNorth()); 169 tabs.getModel().addChangeListener(new ChangeListener() { 170 @Override 171 public void stateChanged(ChangeEvent e) { 172 switch (tabs.getModel().getSelectedIndex()) { 173 case 0: parseLatLonUserInput(); break; 174 case 1: parseEastNorthUserInput(); break; 175 default: throw new AssertionError(); 176 } 167 tabs.getModel().addChangeListener(e -> { 168 switch (tabs.getModel().getSelectedIndex()) { 169 case 0: parseLatLonUserInput(); break; 170 case 1: parseEastNorthUserInput(); break; 171 default: throw new AssertionError(); 177 172 } 178 173 }); -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r10605 r10611 37 37 import javax.swing.event.ListDataEvent; 38 38 import javax.swing.event.ListSelectionEvent; 39 import javax.swing.event.ListSelectionListener;40 import javax.swing.event.TableModelEvent;41 import javax.swing.event.TableModelListener;42 39 import javax.swing.table.AbstractTableModel; 43 40 import javax.swing.table.DefaultTableCellRenderer; … … 362 359 */ 363 360 protected void adaptTo(final IEnabledStateUpdating listener, ListSelectionModel listSelectionModel) { 364 listSelectionModel.addListSelectionListener( 365 new ListSelectionListener() { 366 @Override 367 public void valueChanged(ListSelectionEvent e) { 368 listener.updateEnabledState(); 369 } 370 } 371 ); 361 listSelectionModel.addListSelectionListener(e -> listener.updateEnabledState()); 372 362 } 373 363 … … 381 371 */ 382 372 protected void adaptTo(final IEnabledStateUpdating listener, LayerListModel listModel) { 383 listModel.addTableModelListener( 384 new TableModelListener() { 385 @Override 386 public void tableChanged(TableModelEvent e) { 387 listener.updateEnabledState(); 388 } 389 } 390 ); 373 listModel.addTableModelListener(e -> listener.updateEnabledState()); 391 374 } 392 375 -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r10465 r10611 13 13 import java.awt.Rectangle; 14 14 import java.awt.event.ActionEvent; 15 import java.awt.event.ActionListener;16 15 import java.awt.event.KeyEvent; 17 16 import java.awt.event.MouseEvent; … … 50 49 import javax.swing.UIManager; 51 50 import javax.swing.border.EmptyBorder; 52 import javax.swing.event.ChangeEvent;53 import javax.swing.event.ChangeListener;54 51 import javax.swing.event.ListSelectionEvent; 55 52 import javax.swing.event.ListSelectionListener; … … 139 136 } 140 137 }); 141 cbWireframe.addActionListener(new ActionListener() { 142 @Override 143 public void actionPerformed(ActionEvent e) { 144 Main.main.menu.wireFrameToggleAction.actionPerformed(null); 145 } 146 }); 138 cbWireframe.addActionListener(e -> Main.main.menu.wireFrameToggleAction.actionPerformed(null)); 147 139 cbWireframe.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1))); 148 140 … … 441 433 final int[] rows = tblStyles.getSelectedRows(); 442 434 MapPaintStyles.reloadStyles(rows); 443 Main.worker.submit(new Runnable() { 444 @Override 445 public void run() { 446 SwingUtilities.invokeLater(new Runnable() { 447 @Override 448 public void run() { 449 selectionModel.clearSelection(); 450 for (int r: rows) { 451 selectionModel.addSelectionInterval(r, r); 452 } 453 } 454 }); 435 Main.worker.submit(() -> SwingUtilities.invokeLater(() -> { 436 selectionModel.clearSelection(); 437 for (int r: rows) { 438 selectionModel.addSelectionInterval(r, r); 455 439 } 456 }) ;440 })); 457 441 } 458 442 } … … 531 515 @Override 532 516 protected void finish() { 533 SwingUtilities.invokeLater(new Runnable() { 534 @Override 535 public void run() { 536 if (!error && !canceled) { 537 SourceEntry se = new SourceEntry(s); 538 se.url = file.getPath(); 539 MapPaintStyles.addStyle(se); 540 tblStyles.getSelectionModel().setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); 541 model.ensureSelectedIsVisible(); 542 } 517 SwingUtilities.invokeLater(() -> { 518 if (!error && !canceled) { 519 SourceEntry se = new SourceEntry(s); 520 se.url = file.getPath(); 521 MapPaintStyles.addStyle(se); 522 tblStyles.getSelectionModel().setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); 523 model.ensureSelectedIsVisible(); 543 524 } 544 525 }); … … 594 575 tabs.setTabComponentAt(3, lblSource); 595 576 596 tabs.getModel().addChangeListener(new ChangeListener() { 597 @Override 598 public void stateChanged(ChangeEvent e) { 599 if (!errorsTabLoaded && ((SingleSelectionModel) e.getSource()).getSelectedIndex() == 1) { 600 errorsTabLoaded = true; 601 buildErrorsOrWarningPanel(s.getErrors(), pErrors); 602 } 603 if (!warningsTabLoaded && ((SingleSelectionModel) e.getSource()).getSelectedIndex() == 2) { 604 warningsTabLoaded = true; 605 buildErrorsOrWarningPanel(s.getWarnings(), pWarnings); 606 } 607 if (!sourceTabLoaded && ((SingleSelectionModel) e.getSource()).getSelectedIndex() == 3) { 608 sourceTabLoaded = true; 609 buildSourcePanel(s, pSource); 610 } 577 tabs.getModel().addChangeListener(e1 -> { 578 if (!errorsTabLoaded && ((SingleSelectionModel) e1.getSource()).getSelectedIndex() == 1) { 579 errorsTabLoaded = true; 580 buildErrorsOrWarningPanel(s.getErrors(), pErrors); 581 } 582 if (!warningsTabLoaded && ((SingleSelectionModel) e1.getSource()).getSelectedIndex() == 2) { 583 warningsTabLoaded = true; 584 buildErrorsOrWarningPanel(s.getWarnings(), pWarnings); 585 } 586 if (!sourceTabLoaded && ((SingleSelectionModel) e1.getSource()).getSelectedIndex() == 3) { 587 sourceTabLoaded = true; 588 buildSourcePanel(s, pSource); 611 589 } 612 590 }); -
trunk/src/org/openstreetmap/josm/gui/dialogs/MenuItemSearchDialog.java
r9410 r10611 7 7 import java.awt.Dimension; 8 8 import java.awt.event.ActionEvent; 9 import java.awt.event.ActionListener;10 9 import java.awt.event.KeyEvent; 11 10 … … 31 30 super(Main.parent, tr("Search menu items"), new String[]{tr("Select"), tr("Cancel")}); 32 31 this.selector = new Selector(menu); 33 this.selector.setDblClickListener(new ActionListener() { 34 @Override 35 public void actionPerformed(ActionEvent e) { 36 buttonAction(0, null); 37 } 38 }); 32 this.selector.setDblClickListener(e -> buttonAction(0, null)); 39 33 setContent(selector, false); 40 34 setPreferredSize(new Dimension(600, 300)); -
trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
r10428 r10611 27 27 import javax.swing.ListSelectionModel; 28 28 import javax.swing.SwingUtilities; 29 import javax.swing.event.ListSelectionEvent;30 import javax.swing.event.ListSelectionListener;31 29 32 30 import org.openstreetmap.josm.Main; … … 87 85 displayList.setCellRenderer(new NoteRenderer()); 88 86 displayList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 89 displayList.addListSelectionListener(new ListSelectionListener() { 90 @Override 91 public void valueChanged(ListSelectionEvent e) { 92 if (noteData != null) { //happens when layer is deleted while note selected 93 noteData.setSelectedNote(displayList.getSelectedValue()); 94 } 95 updateButtonStates(); 96 } 87 displayList.addListSelectionListener(e -> { 88 if (noteData != null) { //happens when layer is deleted while note selected 89 noteData.setSelectedNote(displayList.getSelectedValue()); 90 } 91 updateButtonStates(); 97 92 }); 98 93 displayList.addMouseListener(new MouseAdapter() { -
trunk/src/org/openstreetmap/josm/gui/dialogs/OsmIdSelectionDialog.java
r10604 r10611 7 7 import java.awt.Component; 8 8 import java.awt.Dimension; 9 import java.awt.event.ItemEvent;10 import java.awt.event.ItemListener;11 9 import java.awt.event.KeyEvent; 12 10 import java.awt.event.WindowEvent; … … 41 39 import org.openstreetmap.josm.gui.widgets.OsmPrimitiveTypesComboBox; 42 40 import org.openstreetmap.josm.tools.Utils; 41 import org.openstreetmap.josm.tools.Utils.Function; 43 42 44 43 /** … … 105 104 help.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); 106 105 107 cbType.addItemListener(new ItemListener() { 108 @Override 109 public void itemStateChanged(ItemEvent e) { 110 tfId.setType(cbType.getType()); 111 tfId.performValidation(); 112 } 106 cbType.addItemListener(e -> { 107 tfId.setType(cbType.getType()); 108 tfId.performValidation(); 113 109 }); 114 110 … … 208 204 final List<SimplePrimitiveId> ids = SimplePrimitiveId.fuzzyParse(buf); 209 205 if (!ids.isEmpty()) { 210 final String parsedText = Utils.join(", ", Utils.transform(ids, new Utils.Function<SimplePrimitiveId, String>() { 211 @Override 212 public String apply(SimplePrimitiveId x) { 213 return x.getType().getAPIName().charAt(0) + String.valueOf(x.getUniqueId()); 214 } 215 })); 206 final String parsedText = Utils.join(", ", Utils.transform(ids, 207 (Function<SimplePrimitiveId, String>) x -> x.getType().getAPIName().charAt(0) + String.valueOf(x.getUniqueId()))); 216 208 tfId.tryToPasteFrom(parsedText); 217 final Set<OsmPrimitiveType> types = EnumSet.copyOf(Utils.transform(ids, new Utils.Function<SimplePrimitiveId, OsmPrimitiveType>() { 218 @Override 219 public OsmPrimitiveType apply(SimplePrimitiveId x) { 220 return x.getType(); 221 } 222 })); 209 final Set<OsmPrimitiveType> types = EnumSet.copyOf(Utils.transform(ids, 210 (Function<SimplePrimitiveId, OsmPrimitiveType>) x -> x.getType())); 223 211 if (types.size() == 1) { 224 212 // select corresponding type -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r10453 r10611 9 9 import java.awt.event.KeyEvent; 10 10 import java.awt.event.MouseEvent; 11 import java.beans.PropertyChangeEvent;12 import java.beans.PropertyChangeListener;13 11 import java.util.ArrayList; 14 12 import java.util.Arrays; … … 31 29 import javax.swing.KeyStroke; 32 30 import javax.swing.ListSelectionModel; 33 import javax.swing.event.ListSelectionEvent;34 import javax.swing.event.ListSelectionListener;35 31 36 32 import org.openstreetmap.josm.Main; … … 83 79 import org.openstreetmap.josm.tools.ImageProvider; 84 80 import org.openstreetmap.josm.tools.InputMapUtils; 85 import org.openstreetmap.josm.tools.Predicate;86 81 import org.openstreetmap.josm.tools.Shortcut; 87 82 import org.openstreetmap.josm.tools.Utils; … … 162 157 filter = setupFilter(); 163 158 164 displaylist.addListSelectionListener(new ListSelectionListener() { 165 @Override 166 public void valueChanged(ListSelectionEvent e) { 167 updateActionsRelationLists(); 168 } 169 }); 159 displaylist.addListSelectionListener(e -> updateActionsRelationLists()); 170 160 171 161 // Setup popup menu handler … … 309 299 f.setToolTipText(tr("Relation list filter")); 310 300 final CompileSearchTextDecorator decorator = CompileSearchTextDecorator.decorate(f); 311 f.addPropertyChangeListener("filter", new PropertyChangeListener() { 312 @Override 313 public void propertyChange(PropertyChangeEvent evt) { 314 model.setFilter(decorator.getMatch()); 315 } 316 }); 301 f.addPropertyChangeListener("filter", evt -> model.setFilter(decorator.getMatch())); 317 302 return f; 318 303 } … … 506 491 private void updateFilteredRelations() { 507 492 if (filter != null) { 508 filteredRelations = new ArrayList<>(Utils.filter(relations, new Predicate<Relation>() { 509 @Override 510 public boolean evaluate(Relation r) { 511 return filter.match(r); 512 } 513 })); 493 filteredRelations = new ArrayList<>(Utils.filter(relations, filter::match)); 514 494 } else if (filteredRelations != null) { 515 495 filteredRelations = null; -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r10604 r10611 125 125 // the select action 126 126 final SideButton selectButton = new SideButton(actSelect); 127 selectButton.createArrow(new ActionListener() { 128 @Override 129 public void actionPerformed(ActionEvent e) { 130 SelectionHistoryPopup.launch(selectButton, model.getSelectionHistory()); 131 } 132 }); 127 selectButton.createArrow(e -> SelectionHistoryPopup.launch(selectButton, model.getSelectionHistory())); 133 128 134 129 // the search button 135 130 final SideButton searchButton = new SideButton(actSearch); 136 searchButton.createArrow(new ActionListener() { 137 @Override 138 public void actionPerformed(ActionEvent e) { 139 SearchPopupMenu.launch(searchButton); 140 } 141 }); 131 searchButton.createArrow(e -> SearchPopupMenu.launch(searchButton)); 142 132 143 133 createLayout(lstPrimitives, true, Arrays.asList(new SideButton[] { … … 164 154 popupMenuHandler = setupPopupMenuHandler(); 165 155 166 lstPrimitives.addListSelectionListener(new ListSelectionListener() { 167 @Override 168 public void valueChanged(ListSelectionEvent e) { 169 actZoomToListSelection.valueChanged(e); 170 popupMenuHandler.setPrimitives(model.getSelected()); 171 } 156 lstPrimitives.addListSelectionListener(e -> { 157 actZoomToListSelection.valueChanged(e); 158 popupMenuHandler.setPrimitives(model.getSelected()); 172 159 }); 173 160 -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r10491 r10611 18 18 import java.awt.event.AWTEventListener; 19 19 import java.awt.event.ActionEvent; 20 import java.awt.event.ActionListener;21 20 import java.awt.event.ComponentAdapter; 22 21 import java.awt.event.ComponentEvent; … … 513 512 private DialogPopupMenu popupMenu; 514 513 514 @SuppressWarnings("unchecked") 515 515 public TitleBar(String toggleDialogName, String iconName) { 516 516 setLayout(new GridBagLayout()); … … 544 544 buttonsHide.setToolTipText(tr("Toggle dynamic buttons")); 545 545 buttonsHide.setBorder(BorderFactory.createEmptyBorder()); 546 buttonsHide.addActionListener( 547 new ActionListener() { 548 @Override 549 public void actionPerformed(ActionEvent e) { 550 JRadioButtonMenuItem item = (buttonHiding == ButtonHidingType.DYNAMIC) ? alwaysShown : dynamic; 551 item.setSelected(true); 552 item.getAction().actionPerformed(null); 553 } 554 } 555 ); 546 buttonsHide.addActionListener(e -> { 547 JRadioButtonMenuItem item = (buttonHiding == ButtonHidingType.DYNAMIC) ? alwaysShown : dynamic; 548 item.setSelected(true); 549 item.getAction().actionPerformed(null); 550 }); 556 551 add(buttonsHide); 557 552 … … 561 556 pref.setToolTipText(tr("Open preferences for this panel")); 562 557 pref.setBorder(BorderFactory.createEmptyBorder()); 563 pref.addActionListener( 564 new ActionListener() { 565 @Override 566 @SuppressWarnings("unchecked") 567 public void actionPerformed(ActionEvent e) { 568 final PreferenceDialog p = new PreferenceDialog(Main.parent); 569 if (TabPreferenceSetting.class.isAssignableFrom(preferenceClass)) { 570 p.selectPreferencesTabByClass((Class<? extends TabPreferenceSetting>) preferenceClass); 571 } else if (SubPreferenceSetting.class.isAssignableFrom(preferenceClass)) { 572 p.selectSubPreferencesTabByClass((Class<? extends SubPreferenceSetting>) preferenceClass); 573 } 574 p.setVisible(true); 575 } 576 } 577 ); 558 pref.addActionListener(e -> { 559 final PreferenceDialog p = new PreferenceDialog(Main.parent); 560 if (TabPreferenceSetting.class.isAssignableFrom(preferenceClass)) { 561 p.selectPreferencesTabByClass((Class<? extends TabPreferenceSetting>) preferenceClass); 562 } else if (SubPreferenceSetting.class.isAssignableFrom(preferenceClass)) { 563 p.selectSubPreferencesTabByClass((Class<? extends SubPreferenceSetting>) preferenceClass); 564 } 565 p.setVisible(true); 566 }); 578 567 add(pref); 579 568 } … … 583 572 sticky.setToolTipText(tr("Undock the panel")); 584 573 sticky.setBorder(BorderFactory.createEmptyBorder()); 585 sticky.addActionListener( 586 new ActionListener() { 587 @Override 588 public void actionPerformed(ActionEvent e) { 589 detach(); 590 dialogsPanel.reconstruct(Action.ELEMENT_SHRINKS, null); 591 } 592 } 593 ); 574 sticky.addActionListener(e -> { 575 detach(); 576 dialogsPanel.reconstruct(Action.ELEMENT_SHRINKS, null); 577 }); 594 578 add(sticky); 595 579 … … 598 582 close.setToolTipText(tr("Close this panel. You can reopen it with the buttons in the left toolbar.")); 599 583 close.setBorder(BorderFactory.createEmptyBorder()); 600 close.addActionListener( 601 new ActionListener() { 602 @Override 603 public void actionPerformed(ActionEvent e) { 604 hideDialog(); 605 dialogsPanel.reconstruct(Action.ELEMENT_SHRINKS, null); 606 hideNotify(); 607 } 608 } 609 ); 584 close.addActionListener(e -> { 585 hideDialog(); 586 dialogsPanel.reconstruct(Action.ELEMENT_SHRINKS, null); 587 hideNotify(); 588 }); 610 589 add(close); 611 590 setToolTipText(tr("Click to minimize/maximize the panel content")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r10446 r10611 129 129 public void refresh(Collection<? extends OsmPrimitive> fromPrimitives) { 130 130 model.populate(fromPrimitives); 131 GuiHelper.runInEDT(new Runnable() { 132 @Override 133 public void run() { 134 if (model.getRowCount() != 0) { 135 setTitle(trn("{0} Author", "{0} Authors", model.getRowCount(), model.getRowCount())); 136 } else { 137 setTitle(tr("Authors")); 138 } 131 GuiHelper.runInEDT(() -> { 132 if (model.getRowCount() != 0) { 133 setTitle(trn("{0} Author", "{0} Authors", model.getRowCount(), model.getRowCount())); 134 } else { 135 setTitle(tr("Authors")); 139 136 } 140 137 }); … … 320 317 } 321 318 Collections.sort(data); 322 GuiHelper.runInEDTAndWait(new Runnable() { 323 @Override 324 public void run() { 325 fireTableDataChanged(); 326 } 327 }); 319 GuiHelper.runInEDTAndWait(this::fireTableDataChanged); 328 320 } 329 321 -
trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
r10593 r10611 593 593 final Command fixCommand = error.getFix(); 594 594 if (fixCommand != null) { 595 SwingUtilities.invokeAndWait(new Runnable() { 596 @Override 597 public void run() { 598 Main.main.undoRedo.addNoRedraw(fixCommand); 599 } 600 }); 595 SwingUtilities.invokeAndWait(() -> Main.main.undoRedo.addNoRedraw(fixCommand)); 601 596 } 602 597 // It is wanted to ignore an error if it said fixable, even if fixCommand was null … … 614 609 final DataSet ds = Main.getLayerManager().getEditDataSet(); 615 610 int i = 0; 616 SwingUtilities.invokeAndWait(new Runnable() { 617 @Override 618 public void run() { 619 ds.beginUpdate(); 620 } 621 }); 611 SwingUtilities.invokeAndWait(ds::beginUpdate); 622 612 try { 623 613 for (TestError error: testErrors) { … … 630 620 } 631 621 } finally { 632 SwingUtilities.invokeAndWait(new Runnable() { 633 @Override 634 public void run() { 635 ds.endUpdate(); 636 } 637 }); 622 SwingUtilities.invokeAndWait(ds::endUpdate); 638 623 } 639 624 monitor.subTask(tr("Updating map ...")); 640 SwingUtilities.invokeAndWait(new Runnable() { 641 @Override 642 public void run() { 643 Main.main.undoRedo.afterAdd(); 644 Main.map.repaint(); 645 tree.resetErrors(); 646 ds.fireSelectionChanged(); 647 } 625 SwingUtilities.invokeAndWait(() -> { 626 Main.main.undoRedo.afterAdd(); 627 Main.map.repaint(); 628 tree.resetErrors(); 629 ds.fireSelectionChanged(); 648 630 }); 649 631 } catch (InterruptedException | InvocationTargetException e) { 650 // FIXME: signature of realRun should have a generic checked exception we 651 // could throw here 632 // FIXME: signature of realRun should have a generic checked exception we could throw here 652 633 throw new RuntimeException(e); 653 634 } finally { -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java
r10447 r10611 653 653 if (idx < 0) 654 654 return; 655 GuiHelper.runInEDTAndWait(new Runnable() { 656 @Override 657 public void run() { 658 tblChangesets.scrollRectToVisible(tblChangesets.getCellRect(idx, 0, true)); 659 } 660 }); 655 GuiHelper.runInEDTAndWait(() -> tblChangesets.scrollRectToVisible(tblChangesets.getCellRect(idx, 0, true))); 661 656 repaint(); 662 657 } … … 702 697 public void runDownloadTask(final AbstractChangesetDownloadTask task) { 703 698 Main.worker.submit(new PostDownloadHandler(task, task.download())); 704 Main.worker.submit(new Runnable() { 705 @Override 706 public void run() { 707 if (task.isCanceled() || task.isFailed()) 708 return; 709 setSelectedChangesets(task.getDownloadedData()); 710 } 699 Main.worker.submit(() -> { 700 if (task.isCanceled() || task.isFailed()) 701 return; 702 setSelectedChangesets(task.getDownloadedData()); 711 703 }); 712 704 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerModel.java
r9078 r10611 7 7 import java.util.Collection; 8 8 import java.util.Collections; 9 import java.util.Comparator;10 9 import java.util.HashSet; 11 10 import java.util.List; … … 105 104 */ 106 105 public void setSelectedChangesets(Collection<Changeset> selected) { 107 GuiHelper.runInEDTAndWait(new Runnable() { 108 @Override public void run() { 109 selectionModel.clearSelection(); 110 } 111 }); 106 GuiHelper.runInEDTAndWait(selectionModel::clearSelection); 112 107 if (selected == null || selected.isEmpty()) 113 108 return; … … 115 110 final int idx = data.indexOf(cs); 116 111 if (idx >= 0) { 117 GuiHelper.runInEDTAndWait(new Runnable() { 118 @Override public void run() { 119 selectionModel.addSelectionInterval(idx, idx); 120 } 121 }); 112 GuiHelper.runInEDTAndWait(() -> selectionModel.addSelectionInterval(idx, idx)); 122 113 } 123 114 } … … 162 153 Collections.sort( 163 154 this.data, 164 new Comparator<Changeset>() { 165 @Override public int compare(Changeset o1, Changeset o2) { 166 if (o1.getId() < o2.getId()) return 1; 167 if (o1.getId() == o2.getId()) return 0; 168 return -1; 169 } 155 (o1, o2) -> { 156 if (o1.getId() < o2.getId()) return 1; 157 if (o1.getId() == o2.getId()) return 0; 158 return -1; 170 159 } 171 160 ); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java
r10490 r10611 54 54 import org.openstreetmap.josm.tools.ImageProvider; 55 55 import org.openstreetmap.josm.tools.Utils; 56 import org.openstreetmap.josm.tools.Utils.Function; 56 57 import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler; 57 58 … … 233 234 continue; 234 235 } 235 GuiHelper.runInEDT(new Runnable() { 236 @Override 237 public void run() { 238 HistoryBrowserDialogManager.getInstance().show(h); 239 } 240 }); 236 GuiHelper.runInEDT(() -> HistoryBrowserDialogManager.getInstance().show(h)); 241 237 } 242 238 } catch (final RuntimeException e) { 243 GuiHelper.runInEDT(new Runnable() { 244 @Override 245 public void run() { 246 BugReportExceptionHandler.handleException(e); 247 } 248 }); 239 GuiHelper.runInEDT(() -> BugReportExceptionHandler.handleException(e)); 249 240 } 250 241 } … … 311 302 public void actionPerformed(ActionEvent arg0) { 312 303 final List<PrimitiveId> primitiveIds = new ArrayList<>(Utils.transform( 313 model.getSelectedPrimitives(), new Utils.Function<HistoryOsmPrimitive, PrimitiveId>() { 314 @Override 315 public PrimitiveId apply(HistoryOsmPrimitive x) { 316 return x.getPrimitiveId(); 317 } 318 })); 304 model.getSelectedPrimitives(), (Function<HistoryOsmPrimitive, PrimitiveId>) x -> x.getPrimitiveId())); 319 305 Main.worker.submit(new DownloadPrimitivesWithReferrersTask(false, primitiveIds, true, true, null, null)); 320 306 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java
r9078 r10611 4 4 import java.util.ArrayList; 5 5 import java.util.Collections; 6 import java.util.Comparator;7 6 import java.util.HashSet; 8 7 import java.util.Iterator; … … 83 82 Collections.sort( 84 83 data, 85 new Comparator<ChangesetDataSetEntry>() { 86 @Override 87 public int compare(ChangesetDataSetEntry c1, ChangesetDataSetEntry c2) { 88 if (c1.getModificationType().equals(c2.getModificationType())) { 89 long id1 = c1.getPrimitive().getId(); 90 long id2 = c2.getPrimitive().getId(); 84 (c1, c2) -> { 85 if (c1.getModificationType().equals(c2.getModificationType())) { 86 long id1 = c1.getPrimitive().getId(); 87 long id2 = c2.getPrimitive().getId(); 91 88 92 if (id1 == id2) 93 return 0; 94 else if (id1 < id2) 95 return -1; 96 return 1; 89 if (id1 == id2) 90 return 0; 91 else if (id1 < id2) 92 return -1; 93 return 1; 94 } 95 switch(c1.getModificationType()) { 96 case CREATED: return -1; 97 case UPDATED: 98 switch(c2.getModificationType()) { 99 case CREATED: return 1; 100 default: return -1; 97 101 } 98 switch(c1.getModificationType()) { 99 case CREATED: return -1; 100 case UPDATED: 101 switch(c2.getModificationType()) { 102 case CREATED: return 1; 103 default: return -1; 104 } 105 case DELETED: 106 return 1; 107 } 108 // should not happen 109 return 0; 102 case DELETED: 103 return 1; 110 104 } 105 // should not happen 106 return 0; 111 107 } 112 108 ); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDiscussionPanel.java
r10438 r10611 116 116 JPanel pnl = new JPanel(new BorderLayout()); 117 117 table = new JTable(model, new ChangesetDiscussionTableColumnModel()); 118 table.getColumnModel().getColumn(2).addPropertyChangeListener(new PropertyChangeListener() { 119 @Override 120 public void propertyChange(PropertyChangeEvent evt) { 121 if ("width".equals(evt.getPropertyName())) { 122 updateRowHeights(); 123 } 118 table.getColumnModel().getColumn(2).addPropertyChangeListener(evt -> { 119 if ("width".equals(evt.getPropertyName())) { 120 updateRowHeights(); 124 121 } 125 122 }); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetListModel.java
r9078 r10611 5 5 import java.util.Collection; 6 6 import java.util.Collections; 7 import java.util.Comparator;8 7 import java.util.HashSet; 9 8 import java.util.List; … … 143 142 Collections.sort( 144 143 data, 145 new Comparator<Changeset>() { 146 @Override 147 public int compare(Changeset cs1, Changeset cs2) { 148 if (cs1.getId() > cs2.getId()) return -1; 149 if (cs1.getId() == cs2.getId()) return 0; 150 return 1; 151 } 144 (cs1, cs2) -> { 145 if (cs1.getId() > cs2.getId()) return -1; 146 if (cs1.getId() == cs2.getId()) return 0; 147 return 1; 152 148 } 153 149 ); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/UrlBasedQueryPanel.java
r10378 r10611 19 19 import javax.swing.event.DocumentListener; 20 20 import javax.swing.event.HyperlinkEvent; 21 import javax.swing.event.HyperlinkListener;22 21 23 22 import org.openstreetmap.josm.Main; … … 86 85 + "</body></html>" 87 86 ); 88 pnl.getEditorPane().addHyperlinkListener( 89 new HyperlinkListener() { 90 @Override 91 public void hyperlinkUpdate(HyperlinkEvent e) { 92 if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { 93 tfUrl.setText(e.getDescription()); 94 tfUrl.requestFocusInWindow(); 95 } 96 } 87 pnl.getEditorPane().addHyperlinkListener(e -> { 88 if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { 89 tfUrl.setText(e.getDescription()); 90 tfUrl.requestFocusInWindow(); 97 91 } 98 );92 }); 99 93 return pnl; 100 94 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/ActivateLayerAction.java
r10600 r10611 88 88 @Override 89 89 public void updateEnabledState() { 90 GuiHelper.runInEDTAndWait(new Runnable() { 91 @Override 92 public void run() { 93 if (layer == null) { 94 if (model.getSelectedLayers().size() != 1) { 95 setEnabled(false); 96 return; 97 } 98 setEnabled(!isActiveLayer(model.getSelectedLayers().get(0))); 99 } else { 100 setEnabled(!isActiveLayer(layer)); 90 GuiHelper.runInEDTAndWait(() -> { 91 if (layer == null) { 92 if (model.getSelectedLayers().size() != 1) { 93 setEnabled(false); 94 return; 101 95 } 96 setEnabled(!isActiveLayer(model.getSelectedLayers().get(0))); 97 } else { 98 setEnabled(!isActiveLayer(layer)); 102 99 } 103 100 }); -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityAction.java
r10600 r10611 20 20 import javax.swing.JPopupMenu; 21 21 import javax.swing.JSlider; 22 import javax.swing.event.ChangeEvent;23 import javax.swing.event.ChangeListener;24 22 25 23 import org.openstreetmap.josm.Main; … … 69 67 70 68 visibilityCheckbox = new JCheckBox(tr("Show layer")); 71 visibilityCheckbox.addChangeListener(new ChangeListener() { 72 @Override 73 public void stateChanged(ChangeEvent e) { 74 setVisibleFlag(visibilityCheckbox.isSelected()); 75 } 76 }); 69 visibilityCheckbox.addChangeListener(e -> setVisibleFlag(visibilityCheckbox.isSelected())); 77 70 content.add(visibilityCheckbox, GBC.eop()); 78 71 … … 178 171 setPaintTicks(true); 179 172 180 addChangeListener(new ChangeListener() { 181 @Override 182 public void stateChanged(ChangeEvent e) { 183 onStateChanged(); 184 } 185 }); 173 addChangeListener(e -> onStateChanged()); 186 174 } 187 175 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r10604 r10611 14 14 import java.awt.event.MouseAdapter; 15 15 import java.awt.event.MouseEvent; 16 import java.beans.PropertyChangeEvent;17 import java.beans.PropertyChangeListener;18 16 import java.io.IOException; 19 17 import java.net.URI; … … 23 21 import java.util.Collection; 24 22 import java.util.Collections; 25 import java.util.Comparator;26 23 import java.util.EnumSet; 27 24 import java.util.HashMap; … … 319 316 tagRowSorter.addRowSorterListener(removeHiddenSelection); 320 317 tagRowSorter.setComparator(0, AlphanumComparator.getInstance()); 321 tagRowSorter.setComparator(1, new Comparator<Object>() { 322 @Override 323 public int compare(Object o1, Object o2) { 324 if (o1 instanceof Map && o2 instanceof Map) { 325 final String v1 = ((Map) o1).size() == 1 ? (String) ((Map) o1).keySet().iterator().next() : tr("<different>"); 326 final String v2 = ((Map) o2).size() == 1 ? (String) ((Map) o2).keySet().iterator().next() : tr("<different>"); 327 return AlphanumComparator.getInstance().compare(v1, v2); 328 } else { 329 return AlphanumComparator.getInstance().compare(String.valueOf(o1), String.valueOf(o2)); 330 } 318 tagRowSorter.setComparator(1, (o1, o2) -> { 319 if (o1 instanceof Map && o2 instanceof Map) { 320 final String v1 = ((Map) o1).size() == 1 ? (String) ((Map) o1).keySet().iterator().next() : tr("<different>"); 321 final String v2 = ((Map) o2).size() == 1 ? (String) ((Map) o2).keySet().iterator().next() : tr("<different>"); 322 return AlphanumComparator.getInstance().compare(v1, v2); 323 } else { 324 return AlphanumComparator.getInstance().compare(String.valueOf(o1), String.valueOf(o2)); 331 325 } 332 326 }); … … 545 539 f.setToolTipText(tr("Tag filter")); 546 540 final CompileSearchTextDecorator decorator = CompileSearchTextDecorator.decorate(f); 547 f.addPropertyChangeListener("filter", new PropertyChangeListener() { 548 @Override 549 public void propertyChange(PropertyChangeEvent evt) { 550 setFilter(decorator.getMatch()); 551 } 552 }); 541 f.addPropertyChangeListener("filter", evt -> setFilter(decorator.getMatch())); 553 542 return f; 554 543 } … … 713 702 714 703 List<Relation> sortedRelations = new ArrayList<>(roles.keySet()); 715 Collections.sort(sortedRelations, new Comparator<Relation>() { 716 @Override 717 public int compare(Relation o1, Relation o2) { 718 int comp = Boolean.compare(o1.isDisabledAndHidden(), o2.isDisabledAndHidden()); 719 return comp != 0 ? comp : DefaultNameFormatter.getInstance().getRelationComparator().compare(o1, o2); 720 } 704 Collections.sort(sortedRelations, (o1, o2) -> { 705 int comp = Boolean.compare(o1.isDisabledAndHidden(), o2.isDisabledAndHidden()); 706 return comp != 0 ? comp : DefaultNameFormatter.getInstance().getRelationComparator().compare(o1, o2); 721 707 }); 722 708 … … 1175 1161 } 1176 1162 1177 Main.worker.execute(new Runnable() { 1178 @Override public void run() { 1179 try { 1180 // find a page that actually exists in the wiki 1181 HttpClient.Response conn; 1182 for (URI u : uris) { 1183 conn = HttpClient.create(u.toURL(), "HEAD").connect(); 1184 1185 if (conn.getResponseCode() != 200) { 1163 Main.worker.execute(() -> { 1164 try { 1165 // find a page that actually exists in the wiki 1166 HttpClient.Response conn; 1167 for (URI u : uris) { 1168 conn = HttpClient.create(u.toURL(), "HEAD").connect(); 1169 1170 if (conn.getResponseCode() != 200) { 1171 conn.disconnect(); 1172 } else { 1173 long osize = conn.getContentLength(); 1174 if (osize > -1) { 1175 conn.disconnect(); 1176 1177 final URI newURI = new URI(u.toString() 1178 .replace("=", "%3D") /* do not URLencode whole string! */ 1179 .replaceFirst("/wiki/", "/w/index.php?redirect=no&title=") 1180 ); 1181 conn = HttpClient.create(newURI.toURL(), "HEAD").connect(); 1182 } 1183 1184 /* redirect pages have different content length, but retrieving a "nonredirect" 1185 * page using index.php and the direct-link method gives slightly different 1186 * content lengths, so we have to be fuzzy.. (this is UGLY, recode if u know better) 1187 */ 1188 if (conn.getContentLength() != -1 && osize > -1 && Math.abs(conn.getContentLength() - osize) > 200) { 1189 Main.info("{0} is a mediawiki redirect", u); 1186 1190 conn.disconnect(); 1187 1191 } else { 1188 long osize = conn.getContentLength(); 1189 if (osize > -1) { 1190 conn.disconnect(); 1191 1192 final URI newURI = new URI(u.toString() 1193 .replace("=", "%3D") /* do not URLencode whole string! */ 1194 .replaceFirst("/wiki/", "/w/index.php?redirect=no&title=") 1195 ); 1196 conn = HttpClient.create(newURI.toURL(), "HEAD").connect(); 1197 } 1198 1199 /* redirect pages have different content length, but retrieving a "nonredirect" 1200 * page using index.php and the direct-link method gives slightly different 1201 * content lengths, so we have to be fuzzy.. (this is UGLY, recode if u know better) 1202 */ 1203 if (conn.getContentLength() != -1 && osize > -1 && Math.abs(conn.getContentLength() - osize) > 200) { 1204 Main.info("{0} is a mediawiki redirect", u); 1205 conn.disconnect(); 1206 } else { 1207 conn.disconnect(); 1208 1209 OpenBrowser.displayUrl(u.toString()); 1210 break; 1211 } 1192 conn.disconnect(); 1193 1194 OpenBrowser.displayUrl(u.toString()); 1195 break; 1212 1196 } 1213 1197 } 1214 } catch (URISyntaxException | IOException e) {1215 Main.error(e);1216 1198 } 1199 } catch (URISyntaxException | IOException e1) { 1200 Main.error(e1); 1217 1201 } 1218 1202 }); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r10604 r10611 17 17 import java.awt.datatransfer.Transferable; 18 18 import java.awt.event.ActionEvent; 19 import java.awt.event.ActionListener;20 19 import java.awt.event.FocusAdapter; 21 20 import java.awt.event.FocusEvent; … … 108 107 private String objKey; 109 108 110 private final Comparator<AutoCompletionListItem> defaultACItemComparator = new Comparator<AutoCompletionListItem>() { 111 @Override 112 public int compare(AutoCompletionListItem o1, AutoCompletionListItem o2) { 113 return String.CASE_INSENSITIVE_ORDER.compare(o1.getValue(), o2.getValue()); 114 } 115 }; 109 private final Comparator<AutoCompletionListItem> defaultACItemComparator = 110 (o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getValue(), o2.getValue()); 116 111 117 112 private String lastAddKey; … … 365 360 private final String key; 366 361 private final transient Map<String, Integer> m; 367 368 private final transient Comparator<AutoCompletionListItem> usedValuesAwareComparator = new Comparator<AutoCompletionListItem>() { 369 @Override 370 public int compare(AutoCompletionListItem o1, AutoCompletionListItem o2) { 371 boolean c1 = m.containsKey(o1.getValue()); 372 boolean c2 = m.containsKey(o2.getValue()); 373 if (c1 == c2) 374 return String.CASE_INSENSITIVE_ORDER.compare(o1.getValue(), o2.getValue()); 375 else if (c1) 376 return -1; 377 else 378 return +1; 379 } 380 }; 362 private final transient Comparator<AutoCompletionListItem> usedValuesAwareComparator; 381 363 382 364 private final transient ListCellRenderer<AutoCompletionListItem> cellRenderer = new ListCellRenderer<AutoCompletionListItem>() { … … 409 391 this.m = map; 410 392 393 usedValuesAwareComparator = (o1, o2) -> { 394 boolean c1 = m.containsKey(o1.getValue()); 395 boolean c2 = m.containsKey(o2.getValue()); 396 if (c1 == c2) 397 return String.CASE_INSENSITIVE_ORDER.compare(o1.getValue(), o2.getValue()); 398 else if (c1) 399 return -1; 400 else 401 return +1; 402 }; 403 411 404 JPanel mainPanel = new JPanel(new BorderLayout()); 412 405 … … 450 443 p.add(Box.createHorizontalStrut(10), GBC.std()); 451 444 p.add(values, GBC.eol().fill(GBC.HORIZONTAL)); 452 values.getEditor().addActionListener(new ActionListener() { 453 @Override 454 public void actionPerformed(ActionEvent e) { 455 buttonAction(0, null); // emulate OK button click 456 } 457 }); 445 values.getEditor().addActionListener(e -> buttonAction(0, null)); 458 446 addFocusAdapter(autocomplete, usedValuesAwareComparator); 459 447 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
r10378 r10611 420 420 refreshView(r); 421 421 } 422 SwingUtilities.invokeLater(new Runnable() { 423 @Override 424 public void run() { 425 Main.map.repaint(); 426 } 427 }); 422 SwingUtilities.invokeLater(() -> Main.map.repaint()); 428 423 } catch (OsmTransferException e) { 429 424 if (canceled) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java
r10212 r10611 133 133 } 134 134 135 SwingUtilities.invokeLater( 136 new Runnable() { 137 @Override 138 public void run() { 139 curLayer.mergeFrom(dataSet); 140 curLayer.onPostDownloadFromServer(); 141 } 142 } 143 ); 144 135 SwingUtilities.invokeLater(() -> { 136 curLayer.mergeFrom(dataSet); 137 curLayer.onPostDownloadFromServer(); 138 }); 145 139 } catch (OsmTransferException e) { 146 140 if (canceled) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationTask.java
r10212 r10611 98 98 } 99 99 100 SwingUtilities.invokeAndWait( 101 new Runnable() { 102 @Override 103 public void run() { 104 layer.mergeFrom(allDownloads); 105 layer.onPostDownloadFromServer(); 106 Main.map.repaint(); 107 } 108 } 109 ); 100 SwingUtilities.invokeAndWait(() -> { 101 layer.mergeFrom(allDownloads); 102 layer.onPostDownloadFromServer(); 103 Main.map.repaint(); 104 }); 110 105 } catch (OsmTransferException | InvocationTargetException | InterruptedException e) { 111 106 if (canceled) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r10604 r10611 47 47 import javax.swing.JToolBar; 48 48 import javax.swing.KeyStroke; 49 import javax.swing.event.ChangeEvent;50 import javax.swing.event.ChangeListener;51 import javax.swing.event.ListSelectionEvent;52 import javax.swing.event.ListSelectionListener;53 49 54 50 import org.openstreetmap.josm.Main; … … 232 228 tabbedPane.add(tr("Parent Relations"), referrerBrowser); 233 229 tabbedPane.add(tr("Child Relations"), new ChildRelationBrowser(getLayer(), relation)); 234 tabbedPane.addChangeListener( 235 new ChangeListener() { 236 @Override 237 public void stateChanged(ChangeEvent e) { 238 JTabbedPane sourceTabbedPane = (JTabbedPane) e.getSource(); 239 int index = sourceTabbedPane.getSelectedIndex(); 240 String title = sourceTabbedPane.getTitleAt(index); 241 if (title.equals(tr("Parent Relations"))) { 242 referrerBrowser.init(); 243 } 244 } 245 } 246 ); 230 tabbedPane.addChangeListener(e -> { 231 JTabbedPane sourceTabbedPane = (JTabbedPane) e.getSource(); 232 int index = sourceTabbedPane.getSelectedIndex(); 233 String title = sourceTabbedPane.getTitleAt(index); 234 if (title.equals(tr("Parent Relations"))) { 235 referrerBrowser.init(); 236 } 237 }); 247 238 248 239 refreshAction = new RefreshAction(memberTable, memberTableModel, tagEditorPanel.getModel(), getLayer(), this); … … 487 478 tfRole.addActionListener(setRoleAction); 488 479 memberTableModel.getSelectionModel().addListSelectionListener( 489 new ListSelectionListener() { 490 @Override 491 public void valueChanged(ListSelectionEvent e) { 492 tfRole.setEnabled(memberTable.getSelectedRowCount() > 0); 493 } 494 } 480 e -> tfRole.setEnabled(memberTable.getSelectedRowCount() > 0) 495 481 ); 496 482 tfRole.setEnabled(memberTable.getSelectedRowCount() > 0); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r10604 r10611 105 105 } 106 106 107 private transient ListSelectionListener highlighterListener = new ListSelectionListener() { 108 @Override 109 public void valueChanged(ListSelectionEvent lse) { 110 if (Main.isDisplayingMapView()) { 111 Collection<RelationMember> sel = getMemberTableModel().getSelectedMembers(); 112 final List<OsmPrimitive> toHighlight = new ArrayList<>(); 113 for (RelationMember r: sel) { 114 if (r.getMember().isUsable()) { 115 toHighlight.add(r.getMember()); 116 } 107 private transient ListSelectionListener highlighterListener = lse -> { 108 if (Main.isDisplayingMapView()) { 109 Collection<RelationMember> sel = getMemberTableModel().getSelectedMembers(); 110 final List<OsmPrimitive> toHighlight = new ArrayList<>(); 111 for (RelationMember r: sel) { 112 if (r.getMember().isUsable()) { 113 toHighlight.add(r.getMember()); 117 114 } 118 SwingUtilities.invokeLater(new Runnable() { 119 @Override 120 public void run() { 121 if (Main.isDisplayingMapView() && highlightHelper.highlightOnly(toHighlight)) { 122 Main.map.mapView.repaint(); 123 } 124 } 125 }); 126 } 115 } 116 SwingUtilities.invokeLater(() -> { 117 if (Main.isDisplayingMapView() && highlightHelper.highlightOnly(toHighlight)) { 118 Main.map.mapView.repaint(); 119 } 120 }); 127 121 } 128 122 }; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r10604 r10611 122 122 // just trigger a repaint - the display name of the relation members may have changed 123 123 Collection<RelationMember> sel = getSelectedMembers(); 124 GuiHelper.runInEDT(new Runnable() { 125 @Override 126 public void run() { 127 fireTableDataChanged(); 128 } 129 }); 124 GuiHelper.runInEDT(() -> fireTableDataChanged()); 130 125 setSelectedMembers(sel); 131 126 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java
r10413 r10611 165 165 // copy the merged layer's data source info 166 166 getLayer().data.dataSources.addAll(referrers.dataSources); 167 // FIXME: this is necessary because there are 167 // FIXME: this is necessary because there are dialogs listening 168 168 // for DataChangeEvents which manipulate Swing components on this thread. 169 // 170 SwingUtilities.invokeLater( 171 new Runnable() { 172 @Override 173 public void run() { 174 getLayer().onPostDownloadFromServer(); 175 } 176 } 177 ); 169 SwingUtilities.invokeLater(() -> getLayer().onPostDownloadFromServer()); 178 170 179 171 if (visitor.getConflicts().isEmpty()) -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowser.java
r10424 r10611 110 110 new PleaseWaitProgressMonitor(tr("Loading parent relations")) 111 111 ); 112 task.setContinuation( 113 new Runnable() { 114 @Override 115 public void run() { 116 if (task.isCanceled() || task.hasError()) 117 return; 118 model.populate(task.getParents()); 119 } 120 } 121 ); 112 task.setContinuation(() -> { 113 if (task.isCanceled() || task.hasError()) 114 return; 115 model.populate(task.getParents()); 116 }); 122 117 Main.worker.submit(task); 123 118 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationTree.java
r10413 r10611 141 141 } 142 142 final RelationTreeModel model = (RelationTreeModel) getModel(); 143 SwingUtilities.invokeLater( 144 new Runnable() { 145 @Override 146 public void run() { 147 model.refreshNode(path); 148 } 149 } 150 ); 143 SwingUtilities.invokeLater(() -> model.refreshNode(path)); 151 144 } 152 145 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SavingAction.java
r9665 r10611 21 21 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 22 22 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 23 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor; 23 24 import org.openstreetmap.josm.gui.dialogs.relation.MemberTable; 24 25 import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel; 25 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor;26 26 import org.openstreetmap.josm.gui.dialogs.relation.RelationDialogManager; 27 27 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; … … 81 81 layer, editor.getRelation(), (RelationEditor) editor); 82 82 } 83 SwingUtilities.invokeLater(new Runnable() { 84 @Override 85 public void run() { 86 // Relation list gets update in EDT so selecting my be postponed to following EDT run 87 Main.map.relationListDialog.selectRelation(newRelation); 88 } 89 }); 83 // Relation list gets update in EDT so selecting my be postponed to following EDT run 84 SwingUtilities.invokeLater(() -> Main.map.relationListDialog.selectRelation(newRelation)); 90 85 } 91 86 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorter.java
r10179 r10611 5 5 import java.util.Collection; 6 6 import java.util.Collections; 7 import java.util.Comparator;8 7 import java.util.HashMap; 9 8 import java.util.LinkedHashMap; … … 66 65 @Override 67 66 public List<RelationMember> sortMembers(List<RelationMember> list) { 68 Collections.sort(list, new Comparator<RelationMember>() { 69 @Override 70 public int compare(RelationMember a, RelationMember b) { 71 final int houseNumber = AlphanumComparator.getInstance().compare( 72 a.getMember().get("addr:housenumber"), 73 b.getMember().get("addr:housenumber")); 74 if (houseNumber != 0) { 75 return houseNumber; 76 } 77 final String aDisplayName = a.getMember().getDisplayName(DefaultNameFormatter.getInstance()); 78 final String bDisplayName = b.getMember().getDisplayName(DefaultNameFormatter.getInstance()); 79 return AlphanumComparator.getInstance().compare(aDisplayName, bDisplayName); 80 } 67 Collections.sort(list, (a, b) -> { 68 final int houseNumber = AlphanumComparator.getInstance().compare( 69 a.getMember().get("addr:housenumber"), 70 b.getMember().get("addr:housenumber")); 71 if (houseNumber != 0) { 72 return houseNumber; 73 } 74 final String aDisplayName = a.getMember().getDisplayName(DefaultNameFormatter.getInstance()); 75 final String bDisplayName = b.getMember().getDisplayName(DefaultNameFormatter.getInstance()); 76 return AlphanumComparator.getInstance().compare(aDisplayName, bDisplayName); 81 77 }); 82 78 return list; -
trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
r10446 r10611 147 147 148 148 if (errors == null || errors.isEmpty()) { 149 GuiHelper.runInEDTAndWait(new Runnable() { 150 @Override 151 public void run() { 152 valTreeModel.setRoot(rootNode); 153 } 154 }); 149 GuiHelper.runInEDTAndWait(() -> valTreeModel.setRoot(rootNode)); 155 150 return; 156 151 } -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
r10378 r10611 110 110 111 111 bookmarks = new BookmarkList(); 112 bookmarks.getSelectionModel().addListSelectionListener(new ListSelectionListener() { 113 @Override 114 public void valueChanged(ListSelectionEvent e) { 115 Bookmark b = bookmarks.getSelectedValue(); 116 if (b != null && gui != null) { 117 gui.boundingBoxChanged(b.getArea(), BookmarkSelection.this); 118 } 112 bookmarks.getSelectionModel().addListSelectionListener(e -> { 113 Bookmark b = bookmarks.getSelectedValue(); 114 if (b != null && gui != null) { 115 gui.boundingBoxChanged(b.getArea(), BookmarkSelection.this); 119 116 } 120 117 }); -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r10604 r10611 14 14 import java.awt.GridBagLayout; 15 15 import java.awt.event.ActionEvent; 16 import java.awt.event.ActionListener;17 16 import java.awt.event.InputEvent; 18 17 import java.awt.event.KeyEvent; … … 32 31 import javax.swing.JTabbedPane; 33 32 import javax.swing.KeyStroke; 34 import javax.swing.event.ChangeEvent;35 33 import javax.swing.event.ChangeListener; 36 34 … … 94 92 JPanel pnl = new JPanel(new GridBagLayout()); 95 93 96 final ChangeListener checkboxChangeListener = new ChangeListener() { 97 @Override 98 public void stateChanged(ChangeEvent e) { 99 // size check depends on selected data source 100 updateSizeCheck(); 101 } 102 }; 94 // size check depends on selected data source 95 final ChangeListener checkboxChangeListener = e -> updateSizeCheck(); 103 96 104 97 // adding the download tasks … … 159 152 tr("<html>Autostart ''Download from OSM'' dialog every time JOSM is started.<br>" + 160 153 "You can open it manually from File menu or toolbar.</html>")); 161 cbStartup.addActionListener(new ActionListener() { 162 @Override 163 public void actionPerformed(ActionEvent e) { 164 Main.pref.put("download.autorun", cbStartup.isSelected()); 165 } 166 }); 154 cbStartup.addActionListener(e -> Main.pref.put("download.autorun", cbStartup.isSelected())); 167 155 168 156 pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5)); -
trunk/src/org/openstreetmap/josm/gui/download/DownloadObjectDialog.java
r10378 r10611 5 5 6 6 import java.awt.Component; 7 import java.awt.event.ItemEvent;8 import java.awt.event.ItemListener;9 7 import java.awt.event.WindowEvent; 10 8 import java.util.Arrays; … … 70 68 fullRel.setSelected(Main.pref.getBoolean("downloadprimitive.full", true)); 71 69 72 cbType.addItemListener(new ItemListener() { 73 @Override 74 public void itemStateChanged(ItemEvent e) { 75 referrers.setText(cbType.getType() == OsmPrimitiveType.NODE 76 ? tr("Download referrers (parent relations and ways)") 77 : tr("Download referrers (parent relations)")); 78 } 79 }); 70 cbType.addItemListener(e -> referrers.setText(cbType.getType() == OsmPrimitiveType.NODE 71 ? tr("Download referrers (parent relations and ways)") 72 : tr("Download referrers (parent relations)"))); 80 73 81 74 return Arrays.<Component>asList(referrers, fullRel, newLayer); -
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r10217 r10611 384 384 if (!canceled) { 385 385 // Nominatim sometimes returns garbage, see #5934, #10643 386 Main.warn(tr("Error occured with query ''{0}'': ''{1}''", urlString, e.getMessage())); 387 GuiHelper.runInEDTAndWait(new Runnable() { 388 @Override 389 public void run() { 390 HelpAwareOptionPane.showOptionDialog( 391 Main.parent, 392 tr("Name server returned invalid data. Please try again."), 393 tr("Bad response"), 394 JOptionPane.WARNING_MESSAGE, null 395 ); 396 } 397 }); 386 Main.warn(e, tr("Error occured with query ''{0}'': ''{1}''", urlString, e.getMessage())); 387 GuiHelper.runInEDTAndWait(() -> HelpAwareOptionPane.showOptionDialog( 388 Main.parent, 389 tr("Name server returned invalid data. Please try again."), 390 tr("Bad response"), 391 JOptionPane.WARNING_MESSAGE, null 392 )); 398 393 } 399 394 } catch (IOException | ParserConfigurationException e) { -
trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java
r10212 r10611 114 114 public static void setUrlForHelpTopic(final String helpTopic) { 115 115 final HelpBrowser browser = getInstance(); 116 Runnable r = new Runnable() { 117 @Override 118 public void run() { 119 browser.openHelpTopic(helpTopic); 120 browser.setVisible(true); 121 browser.toFront(); 122 } 123 }; 124 SwingUtilities.invokeLater(r); 116 SwingUtilities.invokeLater(() -> { 117 browser.openHelpTopic(helpTopic); 118 browser.setVisible(true); 119 browser.toFront(); 120 }); 125 121 } 126 122 -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowser.java
r10179 r10611 11 11 import javax.swing.JSplitPane; 12 12 import javax.swing.JTabbedPane; 13 import javax.swing.event.ChangeEvent;14 import javax.swing.event.ChangeListener;15 13 16 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 80 78 pnl.add(tpViewers, BorderLayout.CENTER); 81 79 82 tpViewers.addChangeListener(new ChangeListener() { 83 @Override 84 public void stateChanged(ChangeEvent e) { 85 if (tpViewers.getSelectedComponent() == coordinateInfoViewer) { 86 // while building the component size is not yet known, thus panning does not give reasonable results 87 coordinateInfoViewer.setDisplayToFitMapMarkers(); 88 } 80 tpViewers.addChangeListener(e -> { 81 if (tpViewers.getSelectedComponent() == coordinateInfoViewer) { 82 // while building the component size is not yet known, thus panning does not give reasonable results 83 coordinateInfoViewer.setDisplayToFitMapMarkers(); 89 84 } 90 85 }); -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
r10345 r10611 196 196 } 197 197 198 Runnable r = new Runnable() { 199 200 @Override 201 public void run() { 202 try { 203 for (PrimitiveId p : notNewPrimitives) { 204 final History h = HistoryDataSet.getInstance().getHistory(p); 205 if (h == null) { 206 continue; 207 } 208 SwingUtilities.invokeLater(new Runnable() { 209 @Override 210 public void run() { 211 show(h); 212 } 213 }); 198 Runnable r = () -> { 199 try { 200 for (PrimitiveId p : notNewPrimitives) { 201 final History h = HistoryDataSet.getInstance().getHistory(p); 202 if (h == null) { 203 continue; 214 204 } 215 } catch (final RuntimeException e) { 216 BugReportExceptionHandler.handleException(e); 205 SwingUtilities.invokeLater(() -> show(h)); 217 206 } 207 } catch (final RuntimeException e) { 208 BugReportExceptionHandler.handleException(e); 218 209 } 219 210 }; … … 237 228 }; 238 229 239 private final Predicate<PrimitiveId> notNewPredicate = new Predicate<PrimitiveId>() { 240 241 @Override 242 public boolean evaluate(PrimitiveId p) { 243 return !p.isNew(); 244 } 245 }; 230 private final Predicate<PrimitiveId> notNewPredicate = p -> !p.isNew(); 246 231 } -
trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java
r10453 r10611 298 298 Main.worker.submit(new HistoryLoadTask().add(primitiveId)); 299 299 } 300 Runnable r = new Runnable() { 301 @Override 302 public void run() { 303 final History h = HistoryDataSet.getInstance().getHistory(primitiveId); 304 if (h == null) 305 return; 306 GuiHelper.runInEDT(new Runnable() { 307 @Override public void run() { 308 HistoryBrowserDialogManager.getInstance().show(h); 309 } 310 }); 311 } 312 }; 313 Main.worker.submit(r); 300 Main.worker.submit(() -> { 301 final History h = HistoryDataSet.getInstance().getHistory(primitiveId); 302 if (h == null) 303 return; 304 GuiHelper.runInEDT(() -> HistoryBrowserDialogManager.getInstance().show(h)); 305 }); 314 306 } 315 307 -
trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java
r10210 r10611 25 25 import javax.swing.event.ChangeEvent; 26 26 import javax.swing.event.ChangeListener; 27 import javax.swing.event.TableModelEvent;28 import javax.swing.event.TableModelListener;29 27 import javax.swing.table.TableCellRenderer; 30 28 … … 93 91 } 94 92 }); 95 getModel().addTableModelListener(new TableModelListener() { 96 @Override 97 public void tableChanged(TableModelEvent e) { 98 adjustColumnWidth(VersionTable.this, 0, 0); 99 adjustColumnWidth(VersionTable.this, 1, -8); 100 adjustColumnWidth(VersionTable.this, 2, -8); 101 adjustColumnWidth(VersionTable.this, 3, 0); 102 adjustColumnWidth(VersionTable.this, 4, 0); 103 } 93 getModel().addTableModelListener(e -> { 94 adjustColumnWidth(VersionTable.this, 0, 0); 95 adjustColumnWidth(VersionTable.this, 1, -8); 96 adjustColumnWidth(VersionTable.this, 2, -8); 97 adjustColumnWidth(VersionTable.this, 3, 0); 98 adjustColumnWidth(VersionTable.this, 4, 0); 104 99 }); 105 100 } -
trunk/src/org/openstreetmap/josm/gui/io/AbstractPrimitiveTask.java
r10212 r10611 184 184 return; 185 185 } 186 GuiHelper.runInEDTAndWait(new Runnable() { 187 @Override 188 public void run() { 189 layer.mergeFrom(ds); 190 if (zoom && Main.map != null) 191 AutoScaleAction.zoomTo(ds.allPrimitives()); 192 layer.onPostDownloadFromServer(); 193 } 186 GuiHelper.runInEDTAndWait(() -> { 187 layer.mergeFrom(ds); 188 if (zoom && Main.map != null) 189 AutoScaleAction.zoomTo(ds.allPrimitives()); 190 layer.onPostDownloadFromServer(); 194 191 }); 195 192 } -
trunk/src/org/openstreetmap/josm/gui/io/ActionFlagsTableCell.java
r10305 r10611 40 40 private final transient CellEditorSupport cellEditorSupport = new CellEditorSupport(this); 41 41 42 private final transient ActionListener al = new ActionListener() { 43 @Override 44 public void actionPerformed(ActionEvent e) { 45 cellEditorSupport.fireEditingStopped(); 46 } 47 }; 42 private final transient ActionListener al = e -> cellEditorSupport.fireEditingStopped(); 48 43 49 44 /** -
trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
r10210 r10611 24 24 import javax.swing.event.ChangeListener; 25 25 import javax.swing.event.HyperlinkEvent; 26 import javax.swing.event.HyperlinkListener;27 26 28 27 import org.openstreetmap.josm.Main; … … 70 69 JEditorPane sourceLabel = new JMultilineLabel("<html><b>" + tr("Specify the data source for the changes") 71 70 + "</b> (<a href=\"urn:changeset-source\">" + tr("obtain from current layers") + "</a>)<b>:</b>"); 72 sourceLabel.addHyperlinkListener(new HyperlinkListener() { 73 @Override 74 public void hyperlinkUpdate(HyperlinkEvent e) { 75 if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { 76 final String source = Main.map.mapView.getLayerInformationForSourceTag(); 77 hcbUploadSource.setText(Utils.shortenString(source, Changeset.MAX_CHANGESET_TAG_LENGTH)); 78 // Fix #9965 79 changesetSourceModel.setComment(hcbUploadSource.getText()); 80 } 71 sourceLabel.addHyperlinkListener(e -> { 72 if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { 73 final String source = Main.map.mapView.getLayerInformationForSourceTag(); 74 hcbUploadSource.setText(Utils.shortenString(source, Changeset.MAX_CHANGESET_TAG_LENGTH)); 75 // Fix #9965 76 changesetSourceModel.setComment(hcbUploadSource.getText()); 81 77 } 82 78 }); -
trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetTask.java
r10212 r10611 58 58 ExceptionDialogUtil.explainException(lastException); 59 59 } 60 SwingUtilities.invokeLater( 61 new Runnable() { 62 @Override 63 public void run() { 64 ChangesetCache.getInstance().update(closedChangesets); 65 } 66 } 67 ); 60 SwingUtilities.invokeLater(() -> ChangesetCache.getInstance().update(closedChangesets)); 68 61 } 69 62 -
trunk/src/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTask.java
r10212 r10611 85 85 return; 86 86 } 87 SwingUtilities.invokeLater( 88 new Runnable() { 89 @Override public void run() { 90 ChangesetCache.getInstance().update(changesets); 91 } 92 } 93 ); 87 SwingUtilities.invokeLater(() -> ChangesetCache.getInstance().update(changesets)); 94 88 } 95 89 96 90 /** 97 * Refreshes the user info from the server. This is necessary if we don't know 98 * the users id yet. 99 * 91 * Refreshes the user info from the server. This is necessary if we don't know the users id yet. 100 92 */ 101 93 protected void refreshUserIdentity() { -
trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesWithReferrersTask.java
r10446 r10611 138 138 final Set<PrimitiveId> errs = mainTask.getMissingPrimitives(); 139 139 if (errs != null && !errs.isEmpty()) 140 GuiHelper.runInEDTAndWait(new Runnable() { 141 @Override 142 public void run() { 143 reportProblemDialog(errs, 144 trn("Object could not be downloaded", "Some objects could not be downloaded", errs.size()), 145 trn("One object could not be downloaded.<br>", 146 "{0} objects could not be downloaded.<br>", 147 errs.size(), 148 errs.size()) 149 + tr("The server replied with response code 404.<br>" 150 + "This usually means, the server does not know an object with the requested id."), 151 tr("missing objects:"), 152 JOptionPane.ERROR_MESSAGE 153 ).showDialog(); 154 } 155 }); 140 GuiHelper.runInEDTAndWait(() -> reportProblemDialog(errs, 141 trn("Object could not be downloaded", "Some objects could not be downloaded", errs.size()), 142 trn("One object could not be downloaded.<br>", 143 "{0} objects could not be downloaded.<br>", 144 errs.size(), 145 errs.size()) 146 + tr("The server replied with response code 404.<br>" 147 + "This usually means, the server does not know an object with the requested id."), 148 tr("missing objects:"), 149 JOptionPane.ERROR_MESSAGE 150 ).showDialog()); 156 151 157 152 // Warm about deleted primitives … … 165 160 } 166 161 if (!del.isEmpty()) 167 GuiHelper.runInEDTAndWait(new Runnable() { 168 @Override 169 public void run() { 170 reportProblemDialog(del, 171 trn("Object deleted", "Objects deleted", del.size()), 172 trn( 173 "One downloaded object is deleted.", 174 "{0} downloaded objects are deleted.", 175 del.size(), 176 del.size()), 177 null, 178 JOptionPane.WARNING_MESSAGE 179 ).showDialog(); 180 } 181 }); 162 GuiHelper.runInEDTAndWait(() -> reportProblemDialog(del, 163 trn("Object deleted", "Objects deleted", del.size()), 164 trn( 165 "One downloaded object is deleted.", 166 "{0} downloaded objects are deleted.", 167 del.size(), 168 del.size()), 169 null, 170 JOptionPane.WARNING_MESSAGE 171 ).showDialog()); 182 172 } 183 173 -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r10428 r10611 579 579 @Override 580 580 public void run() { 581 GuiHelper.runInEDTAndWait(new Runnable() { 582 @Override 583 public void run() { 584 model.setMode(SaveLayersModel.Mode.UPLOADING_AND_SAVING); 585 List<SaveLayerInfo> toUpload = model.getLayersToUpload(); 586 if (!toUpload.isEmpty()) { 587 uploadLayers(toUpload); 588 } 589 List<SaveLayerInfo> toSave = model.getLayersToSave(); 590 if (!toSave.isEmpty()) { 591 saveLayers(toSave); 592 } 593 model.setMode(SaveLayersModel.Mode.EDITING_DATA); 594 if (model.hasUnsavedData()) { 595 warnBecauseOfUnsavedData(); 596 model.setMode(Mode.EDITING_DATA); 597 if (canceled) { 598 setUserAction(UserAction.CANCEL); 599 closeDialog(); 600 } 601 } else { 602 setUserAction(UserAction.PROCEED); 581 GuiHelper.runInEDTAndWait(() -> { 582 model.setMode(SaveLayersModel.Mode.UPLOADING_AND_SAVING); 583 List<SaveLayerInfo> toUpload = model.getLayersToUpload(); 584 if (!toUpload.isEmpty()) { 585 uploadLayers(toUpload); 586 } 587 List<SaveLayerInfo> toSave = model.getLayersToSave(); 588 if (!toSave.isEmpty()) { 589 saveLayers(toSave); 590 } 591 model.setMode(SaveLayersModel.Mode.EDITING_DATA); 592 if (model.hasUnsavedData()) { 593 warnBecauseOfUnsavedData(); 594 model.setMode(Mode.EDITING_DATA); 595 if (canceled) { 596 setUserAction(UserAction.CANCEL); 603 597 closeDialog(); 604 598 } 599 } else { 600 setUserAction(UserAction.PROCEED); 601 closeDialog(); 605 602 } 606 603 }); -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersModel.java
r10217 r10611 7 7 import java.util.ArrayList; 8 8 import java.util.Collections; 9 import java.util.Comparator;10 9 import java.util.List; 11 10 … … 72 71 layerInfo.add(new SaveLayerInfo(layer)); 73 72 } 74 Collections.sort( 75 layerInfo, 76 new Comparator<SaveLayerInfo>() { 77 @Override 78 public int compare(SaveLayerInfo o1, SaveLayerInfo o2) { 79 return o1.compareTo(o2); 80 } 81 } 82 ); 73 Collections.sort(layerInfo, (o1, o2) -> o1.compareTo(o2)); 83 74 fireTableDataChanged(); 84 75 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java
r10378 r10611 219 219 // we always clean up the data, even in case of errors. It's possible the data was 220 220 // partially uploaded. Better run on EDT. 221 // 222 Runnable r = new Runnable() { 223 @Override 224 public void run() { 225 layer.cleanupAfterUpload(processedPrimitives); 226 layer.onPostUploadToServer(); 227 ChangesetCache.getInstance().update(changeset); 228 } 221 Runnable r = () -> { 222 layer.cleanupAfterUpload(processedPrimitives); 223 layer.onPostUploadToServer(); 224 ChangesetCache.getInstance().update(changeset); 229 225 }; 230 226 … … 320 316 // - to the Upload Dialog 321 317 // - to map editing 322 GuiHelper.runInEDT(new Runnable() { 323 @Override 324 public void run() { 325 // if the changeset is still open after this upload we want it to 326 // be selected on the next upload 327 // 328 ChangesetCache.getInstance().update(changeset); 329 if (changeset != null && changeset.isOpen()) { 330 UploadDialog.getUploadDialog().setSelectedChangesetForNextUpload(changeset); 331 } 332 if (uploadCanceled) return; 333 if (lastException == null) { 334 new Notification( 335 "<h3>" + tr("Upload successful!") + "</h3>") 336 .setIcon(ImageProvider.get("misc", "check_large")) 337 .show(); 318 GuiHelper.runInEDT(() -> { 319 // if the changeset is still open after this upload we want it to be selected on the next upload 320 ChangesetCache.getInstance().update(changeset); 321 if (changeset != null && changeset.isOpen()) { 322 UploadDialog.getUploadDialog().setSelectedChangesetForNextUpload(changeset); 323 } 324 if (uploadCanceled) return; 325 if (lastException == null) { 326 new Notification( 327 "<h3>" + tr("Upload successful!") + "</h3>") 328 .setIcon(ImageProvider.get("misc", "check_large")) 329 .show(); 330 return; 331 } 332 if (lastException instanceof ChangesetClosedException) { 333 ChangesetClosedException e = (ChangesetClosedException) lastException; 334 if (e.getSource().equals(ChangesetClosedException.Source.UPDATE_CHANGESET)) { 335 handleFailedUpload(lastException); 338 336 return; 339 337 } 340 if (lastException instanceof ChangesetClosedException) { 341 ChangesetClosedException e = (ChangesetClosedException) lastException; 342 if (e.getSource().equals(ChangesetClosedException.Source.UPDATE_CHANGESET)) { 343 handleFailedUpload(lastException); 344 return; 345 } 346 if (strategy.getPolicy() == null) 347 /* do nothing if unknown policy */ 348 return; 349 if (e.getSource().equals(ChangesetClosedException.Source.UPLOAD_DATA)) { 350 switch(strategy.getPolicy()) { 351 case ABORT: 352 break; /* do nothing - we return to map editing */ 353 case AUTOMATICALLY_OPEN_NEW_CHANGESETS: 354 break; /* do nothing - we return to map editing */ 355 case FILL_ONE_CHANGESET_AND_RETURN_TO_UPLOAD_DIALOG: 356 // return to the upload dialog 357 // 358 toUpload.removeProcessed(processedPrimitives); 359 UploadDialog.getUploadDialog().setUploadedPrimitives(toUpload); 360 UploadDialog.getUploadDialog().setVisible(true); 361 break; 362 } 363 } else { 364 handleFailedUpload(lastException); 338 if (strategy.getPolicy() == null) 339 /* do nothing if unknown policy */ 340 return; 341 if (e.getSource().equals(ChangesetClosedException.Source.UPLOAD_DATA)) { 342 switch(strategy.getPolicy()) { 343 case ABORT: 344 break; /* do nothing - we return to map editing */ 345 case AUTOMATICALLY_OPEN_NEW_CHANGESETS: 346 break; /* do nothing - we return to map editing */ 347 case FILL_ONE_CHANGESET_AND_RETURN_TO_UPLOAD_DIALOG: 348 // return to the upload dialog 349 // 350 toUpload.removeProcessed(processedPrimitives); 351 UploadDialog.getUploadDialog().setUploadedPrimitives(toUpload); 352 UploadDialog.getUploadDialog().setVisible(true); 353 break; 365 354 } 366 355 } else { 367 356 handleFailedUpload(lastException); 368 357 } 358 } else { 359 handleFailedUpload(lastException); 369 360 } 370 361 }); -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r10596 r10611 1880 1880 double bufferX, double bufferY) { 1881 1881 PrecacheTask precacheTask = new PrecacheTask(progressMonitor); 1882 final Set<Tile> requestedTiles = new ConcurrentSkipListSet<>(new Comparator<Tile>() { 1883 @Override 1884 public int compare(Tile o1, Tile o2) { 1885 return String.CASE_INSENSITIVE_ORDER.compare(o1.getKey(), o2.getKey()); 1886 } 1887 }); 1882 final Set<Tile> requestedTiles = new ConcurrentSkipListSet<>( 1883 (o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getKey(), o2.getKey())); 1888 1884 for (LatLon point: points) { 1889 1885 -
trunk/src/org/openstreetmap/josm/gui/layer/AlignImageryPanel.java
r10000 r10611 7 7 import java.awt.Font; 8 8 import java.awt.GridBagLayout; 9 import java.awt.event.ActionEvent;10 import java.awt.event.ActionListener;11 9 12 10 import javax.swing.JButton; … … 55 53 closeButton.setBorderPainted(false); 56 54 closeButton.setToolTipText(tr("Hide this message and never show it again")); 57 closeButton.addActionListener(new ActionListener() { 58 @Override 59 public void actionPerformed(ActionEvent e) { 60 if (Main.isDisplayingMapView()) { 61 Main.map.removeTopPanel(AlignImageryPanel.class); 62 if (doNotShowAgain.isSelected()) { 63 showAgain.put(Boolean.FALSE); 64 } 55 closeButton.addActionListener(e -> { 56 if (Main.isDisplayingMapView()) { 57 Main.map.removeTopPanel(AlignImageryPanel.class); 58 if (doNotShowAgain.isSelected()) { 59 showAgain.put(Boolean.FALSE); 65 60 } 66 61 } -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r10364 r10611 183 183 final JScrollPane sp = new JScrollPane(new HtmlPanel(info.toString())); 184 184 sp.setPreferredSize(new Dimension(sp.getPreferredSize().width+20, 370)); 185 SwingUtilities.invokeLater(new Runnable() { 186 @Override 187 public void run() { 188 sp.getVerticalScrollBar().setValue(0); 189 } 190 }); 185 SwingUtilities.invokeLater(() -> sp.getVerticalScrollBar().setValue(0)); 191 186 return sp; 192 187 } -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r10571 r10611 301 301 */ 302 302 public static ImageProcessor createImageProcessor(final BufferedImageOp op, final boolean inPlace) { 303 return new ImageProcessor() { 304 @Override 305 public BufferedImage process(BufferedImage image) { 306 return op.filter(image, inPlace ? image : null); 307 } 308 }; 303 return image -> op.filter(image, inPlace ? image : null); 309 304 } 310 305 -
trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r10600 r10611 516 516 517 517 // run later to not block loading the UI. 518 SwingUtilities.invokeLater(new Runnable() { 519 @Override 520 public void run() { 521 JOptionPane.showMessageDialog(Main.parent, 522 message, 523 tr("Warning"), 524 JOptionPane.WARNING_MESSAGE); 525 } 526 }); 518 SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(Main.parent, 519 message, 520 tr("Warning"), 521 JOptionPane.WARNING_MESSAGE)); 527 522 } 528 523 } -
trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java
r10598 r10611 178 178 // we force this on to the EDT Thread to make events fire from there. 179 179 // The synchronization lock needs to be held by the EDT. 180 GuiHelper.runInEDTAndWaitWithException(new Runnable() { 181 @Override 182 public void run() { 183 realAddLayer(layer); 184 } 185 }); 180 GuiHelper.runInEDTAndWaitWithException(() -> realAddLayer(layer)); 186 181 } 187 182 … … 208 203 // we force this on to the EDT Thread to make events fire from there. 209 204 // The synchronization lock needs to be held by the EDT. 210 GuiHelper.runInEDTAndWaitWithException(new Runnable() { 211 @Override 212 public void run() { 213 realRemoveLayer(layer); 214 } 215 }); 205 GuiHelper.runInEDTAndWaitWithException(() -> realRemoveLayer(layer)); 216 206 } 217 207 … … 247 237 // we force this on to the EDT Thread to make events fire from there. 248 238 // The synchronization lock needs to be held by the EDT. 249 GuiHelper.runInEDTAndWaitWithException(new Runnable() { 250 @Override 251 public void run() { 252 realMoveLayer(layer, position); 253 } 254 }); 239 GuiHelper.runInEDTAndWaitWithException(() -> realMoveLayer(layer, position)); 255 240 } 256 241 -
trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java
r10600 r10611 228 228 // we force this on to the EDT Thread to make events fire from there. 229 229 // The synchronization lock needs to be held by the EDT. 230 GuiHelper.runInEDTAndWaitWithException(new Runnable() { 231 @Override 232 public void run() { 233 realSetActiveLayer(layer); 234 } 235 }); 230 GuiHelper.runInEDTAndWaitWithException(() -> realSetActiveLayer(layer)); 236 231 } 237 232 -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r10600 r10611 30 30 import java.util.Map; 31 31 import java.util.Set; 32 import java.util.concurrent.Callable;33 32 import java.util.concurrent.CopyOnWriteArrayList; 34 33 import java.util.regex.Pattern; … … 994 993 @Override 995 994 public boolean checkSaveConditions() { 996 if (isDataSetEmpty() && 1 != GuiHelper.runInEDTAndWaitAndReturn(new Callable<Integer>() { 997 @Override 998 public Integer call() { 999 if (GraphicsEnvironment.isHeadless()) { 1000 return 2; 1001 } 1002 ExtendedDialog dialog = new ExtendedDialog( 1003 Main.parent, 1004 tr("Empty document"), 1005 new String[] {tr("Save anyway"), tr("Cancel")} 1006 ); 1007 dialog.setContent(tr("The document contains no data.")); 1008 dialog.setButtonIcons(new String[] {"save", "cancel"}); 1009 return dialog.showDialog().getValue(); 1010 } 995 if (isDataSetEmpty() && 1 != GuiHelper.runInEDTAndWaitAndReturn(() -> { 996 if (GraphicsEnvironment.isHeadless()) { 997 return 2; 998 } 999 ExtendedDialog dialog = new ExtendedDialog( 1000 Main.parent, 1001 tr("Empty document"), 1002 new String[] {tr("Save anyway"), tr("Cancel")} 1003 ); 1004 dialog.setContent(tr("The document contains no data.")); 1005 dialog.setButtonIcons(new String[] {"save", "cancel"}); 1006 return dialog.showDialog().getValue(); 1011 1007 })) { 1012 1008 return false; … … 1014 1010 1015 1011 ConflictCollection conflictsCol = getConflicts(); 1016 if (conflictsCol != null && !conflictsCol.isEmpty() && 1 != GuiHelper.runInEDTAndWaitAndReturn(new Callable<Integer>() { 1017 @Override 1018 public Integer call() { 1019 ExtendedDialog dialog = new ExtendedDialog( 1020 Main.parent, 1021 /* I18N: Display title of the window showing conflicts */ 1022 tr("Conflicts"), 1023 new String[] {tr("Reject Conflicts and Save"), tr("Cancel")} 1024 ); 1025 dialog.setContent( 1026 tr("There are unresolved conflicts. Conflicts will not be saved and handled as if you rejected all. Continue?")); 1027 dialog.setButtonIcons(new String[] {"save", "cancel"}); 1028 return dialog.showDialog().getValue(); 1029 } 1012 if (conflictsCol != null && !conflictsCol.isEmpty() && 1 != GuiHelper.runInEDTAndWaitAndReturn(() -> { 1013 ExtendedDialog dialog = new ExtendedDialog( 1014 Main.parent, 1015 /* I18N: Display title of the window showing conflicts */ 1016 tr("Conflicts"), 1017 new String[] {tr("Reject Conflicts and Save"), tr("Cancel")} 1018 ); 1019 dialog.setContent( 1020 tr("There are unresolved conflicts. Conflicts will not be saved and handled as if you rejected all. Continue?")); 1021 dialog.setButtonIcons(new String[] {"save", "cancel"}); 1022 return dialog.showDialog().getValue(); 1030 1023 })) { 1031 1024 return false; -
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r10184 r10611 73 73 @Override 74 74 protected TMSTileSource getTileSource(ImageryInfo info) { 75 return getTileSourceStatic(info, new Runnable() { 76 @Override 77 public void run() { 78 Main.debug("Attribution loaded, running loadAllErrorTiles"); 79 TMSLayer.this.loadAllErrorTiles(false); 80 } 75 return getTileSourceStatic(info, () -> { 76 Main.debug("Attribution loaded, running loadAllErrorTiles"); 77 TMSLayer.this.loadAllErrorTiles(false); 81 78 }); 82 79 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r10420 r10611 30 30 import java.util.Collection; 31 31 import java.util.Collections; 32 import java.util.Comparator;33 32 import java.util.Date; 34 33 import java.util.Dictionary; … … 60 59 import javax.swing.event.DocumentEvent; 61 60 import javax.swing.event.DocumentListener; 62 import javax.swing.event.ListSelectionEvent;63 import javax.swing.event.ListSelectionListener;64 61 import javax.swing.filechooser.FileFilter; 65 62 … … 460 457 }); 461 458 imgList.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 462 imgList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { 463 464 @Override 465 public void valueChanged(ListSelectionEvent arg0) { 466 int index = imgList.getSelectedIndex(); 467 Integer orientation = ExifReader.readOrientation(yLayer.data.get(index).getFile()); 468 imgDisp.setImage(yLayer.data.get(index).getFile(), orientation); 469 Date date = yLayer.data.get(index).getExifTime(); 470 if (date != null) { 471 DateFormat df = DateUtils.getDateTimeFormat(DateFormat.SHORT, DateFormat.MEDIUM); 472 lbExifTime.setText(df.format(date)); 473 tfGpsTime.setText(df.format(date)); 474 tfGpsTime.setCaretPosition(tfGpsTime.getText().length()); 475 tfGpsTime.setEnabled(true); 476 tfGpsTime.requestFocus(); 477 } else { 478 lbExifTime.setText(tr("No date")); 479 tfGpsTime.setText(""); 480 tfGpsTime.setEnabled(false); 481 } 459 imgList.getSelectionModel().addListSelectionListener(evt -> { 460 int index = imgList.getSelectedIndex(); 461 Integer orientation = ExifReader.readOrientation(yLayer.data.get(index).getFile()); 462 imgDisp.setImage(yLayer.data.get(index).getFile(), orientation); 463 Date date = yLayer.data.get(index).getExifTime(); 464 if (date != null) { 465 DateFormat df = DateUtils.getDateTimeFormat(DateFormat.SHORT, DateFormat.MEDIUM); 466 lbExifTime.setText(df.format(date)); 467 tfGpsTime.setText(df.format(date)); 468 tfGpsTime.setCaretPosition(tfGpsTime.getText().length()); 469 tfGpsTime.setEnabled(true); 470 tfGpsTime.requestFocus(); 471 } else { 472 lbExifTime.setText(tr("No date")); 473 tfGpsTime.setText(""); 474 tfGpsTime.setEnabled(false); 482 475 } 483 476 }); … … 485 478 486 479 JButton openButton = new JButton(tr("Open another photo")); 487 openButton.addActionListener(new ActionListener() { 488 489 @Override 490 public void actionPerformed(ActionEvent ae) { 491 AbstractFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true, false, null, 492 JpgImporter.FILE_FILTER_WITH_FOLDERS, JFileChooser.FILES_ONLY, "geoimage.lastdirectory"); 493 if (fc == null) 494 return; 495 File sel = fc.getSelectedFile(); 496 497 Integer orientation = ExifReader.readOrientation(sel); 498 imgDisp.setImage(sel, orientation); 499 500 Date date = ExifReader.readTime(sel); 501 if (date != null) { 502 lbExifTime.setText(DateUtils.getDateTimeFormat(DateFormat.SHORT, DateFormat.MEDIUM).format(date)); 503 tfGpsTime.setText(DateUtils.getDateFormat(DateFormat.SHORT).format(date)+' '); 504 tfGpsTime.setEnabled(true); 505 } else { 506 lbExifTime.setText(tr("No date")); 507 tfGpsTime.setText(""); 508 tfGpsTime.setEnabled(false); 509 } 480 openButton.addActionListener(ae -> { 481 AbstractFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true, false, null, 482 JpgImporter.FILE_FILTER_WITH_FOLDERS, JFileChooser.FILES_ONLY, "geoimage.lastdirectory"); 483 if (fc == null) 484 return; 485 File sel = fc.getSelectedFile(); 486 487 Integer orientation = ExifReader.readOrientation(sel); 488 imgDisp.setImage(sel, orientation); 489 490 Date date = ExifReader.readTime(sel); 491 if (date != null) { 492 lbExifTime.setText(DateUtils.getDateTimeFormat(DateFormat.SHORT, DateFormat.MEDIUM).format(date)); 493 tfGpsTime.setText(DateUtils.getDateFormat(DateFormat.SHORT).format(date)+' '); 494 tfGpsTime.setEnabled(true); 495 } else { 496 lbExifTime.setText(tr("No date")); 497 tfGpsTime.setText(""); 498 tfGpsTime.setEnabled(false); 510 499 } 511 500 }); … … 1092 1081 } 1093 1082 1094 Collections.sort(dateImgLst, new Comparator<ImageEntry>() { 1095 @Override 1096 public int compare(ImageEntry arg0, ImageEntry arg1) { 1097 return arg0.getExifTime().compareTo(arg1.getExifTime()); 1098 } 1099 }); 1083 Collections.sort(dateImgLst, (o1, o2) -> o1.getExifTime().compareTo(o2.getExifTime())); 1100 1084 1101 1085 return dateImgLst; -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r10604 r10611 66 66 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 67 67 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 68 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;69 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;70 68 import org.openstreetmap.josm.gui.util.GuiHelper; 71 69 import org.openstreetmap.josm.io.JpgImporter; … … 431 429 432 430 if (selected != null && !data.isEmpty()) { 433 GuiHelper.runInEDTAndWait(new Runnable() { 434 @Override 435 public void run() { 436 for (int i = 0; i < data.size(); i++) { 437 if (selected.equals(data.get(i))) { 438 currentPhoto = i; 439 ImageViewerDialog.showImage(GeoImageLayer.this, data.get(i)); 440 break; 441 } 431 GuiHelper.runInEDTAndWait(() -> { 432 for (int i = 0; i < data.size(); i++) { 433 if (selected.equals(data.get(i))) { 434 currentPhoto = i; 435 ImageViewerDialog.showImage(GeoImageLayer.this, data.get(i)); 436 break; 442 437 } 443 438 } … … 881 876 }; 882 877 883 mapModeListener = new MapModeChangeListener() { 884 @Override 885 public void mapModeChange(MapMode oldMapMode, MapMode newMapMode) { 886 if (newMapMode == null || isSupportedMapMode(newMapMode)) { 887 Main.map.mapView.addMouseListener(mouseAdapter); 888 } else { 889 Main.map.mapView.removeMouseListener(mouseAdapter); 890 } 878 mapModeListener = (oldMapMode, newMapMode) -> { 879 if (newMapMode == null || isSupportedMapMode(newMapMode)) { 880 Main.map.mapView.addMouseListener(mouseAdapter); 881 } else { 882 Main.map.mapView.removeMouseListener(mouseAdapter); 891 883 } 892 884 }; … … 895 887 mapModeListener.mapModeChange(null, Main.map.mapMode); 896 888 897 Main.getLayerManager().addActiveLayerChangeListener(new ActiveLayerChangeListener() { 898 @Override 899 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 900 if (Main.getLayerManager().getActiveLayer() == GeoImageLayer.this) { 901 // only in select mode it is possible to click the images 902 Main.map.selectSelectTool(false); 903 } 889 Main.getLayerManager().addActiveLayerChangeListener(e -> { 890 if (Main.getLayerManager().getActiveLayer() == GeoImageLayer.this) { 891 // only in select mode it is possible to click the images 892 Main.map.selectSelectTool(false); 904 893 } 905 894 }); -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java
r9880 r10611 10 10 import java.awt.GridBagLayout; 11 11 import java.awt.event.ActionEvent; 12 import java.awt.event.ActionListener;13 12 import java.awt.event.MouseAdapter; 14 13 import java.awt.event.MouseEvent; … … 27 26 import javax.swing.JToggleButton; 28 27 import javax.swing.ListSelectionModel; 29 import javax.swing.event.ListSelectionEvent;30 import javax.swing.event.ListSelectionListener;31 28 import javax.swing.table.DefaultTableModel; 32 29 import javax.swing.table.TableCellRenderer; … … 205 202 /** listens to selection changes in the table and redraws the map */ 206 203 private void listenToSelectionChanges() { 207 table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { 208 @Override 209 public void valueChanged(ListSelectionEvent e) { 210 if (noUpdates || !(e.getSource() instanceof ListSelectionModel)) { 211 return; 212 } 213 updateVisibilityFromTable(); 214 } 204 table.getSelectionModel().addListSelectionListener(e -> { 205 if (noUpdates || !(e.getSource() instanceof ListSelectionModel)) { 206 return; 207 } 208 updateVisibilityFromTable(); 215 209 }); 216 210 } … … 230 224 231 225 dateFilter = new DateFilterPanel(layer, "gpx.traces", false); 232 dateFilter.setFilterAppliedListener(new ActionListener() { 233 @Override public void actionPerformed(ActionEvent e) { 234 noUpdates = true; 235 selectVisibleTracksInTable(); 236 noUpdates = false; 237 Main.map.mapView.preferenceChanged(null); 238 Main.map.repaint(100); 239 } 226 dateFilter.setFilterAppliedListener(e -> { 227 noUpdates = true; 228 selectVisibleTracksInTable(); 229 noUpdates = false; 230 Main.map.mapView.preferenceChanged(null); 231 Main.map.repaint(100); 240 232 }); 241 233 dateFilter.loadFromPrefs(); -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DateFilterPanel.java
r10378 r10611 6 6 import java.awt.Component; 7 7 import java.awt.GridBagLayout; 8 import java.awt.event.ActionEvent;9 8 import java.awt.event.ActionListener; 10 9 import java.util.Date; … … 14 13 import javax.swing.JPanel; 15 14 import javax.swing.Timer; 16 import javax.swing.event.ChangeEvent;17 15 import javax.swing.event.ChangeListener; 18 16 … … 70 68 } 71 69 72 private final transient ChangeListener changeListener = new ChangeListener() { 73 @Override public void stateChanged(ChangeEvent e) { 74 if (isEnabled()) applyFilterWithDelay(); 75 } 70 private final transient ChangeListener changeListener = e -> { 71 if (isEnabled()) applyFilterWithDelay(); 76 72 }; 77 73 78 private final Timer t = new Timer(200, new ActionListener() { 79 @Override public void actionPerformed(ActionEvent e) { 80 applyFilter(); 81 } 82 }); 74 private final Timer t = new Timer(200, e -> applyFilter()); 83 75 84 76 /** -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongPanel.java
r9917 r10611 14 14 import javax.swing.JSpinner; 15 15 import javax.swing.SpinnerNumberModel; 16 import javax.swing.event.ChangeEvent;17 16 import javax.swing.event.ChangeListener; 18 17 … … 179 178 }; 180 179 181 addChangeListener(new ChangeListener() { 182 @Override public void stateChanged(ChangeEvent e) { 183 options[0].setEnabled(isDownloadOsmData() || isDownloadGpxData()); 184 } 185 }); 180 addChangeListener(e -> options[0].setEnabled(isDownloadOsmData() || isDownloadGpxData())); 186 181 187 182 int ret = HelpAwareOptionPane.showOptionDialog(Main.parent, this, title, -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
r10436 r10611 12 12 import java.util.Collection; 13 13 import java.util.Collections; 14 import java.util.Comparator;15 14 16 15 import javax.swing.AbstractAction; … … 89 88 // long as they don't overlap, that's fine) 90 89 if (sel.length > 1) { 91 Arrays.sort(sel, new Comparator<File>() { 92 @Override 93 public int compare(File a, File b) { 94 return a.lastModified() <= b.lastModified() ? -1 : 1; 95 } 96 }); 90 Arrays.sort(sel, (a, b) -> a.lastModified() <= b.lastModified() ? -1 : 1); 97 91 } 98 92 StringBuilder names = new StringBuilder(); … … 284 278 /* we must have got at least one waypoint now */ 285 279 286 Collections.sort((ArrayList<WayPoint>) waypoints, new Comparator<WayPoint>() { 287 @Override 288 public int compare(WayPoint a, WayPoint b) { 289 return a.time <= b.time ? -1 : 1; 290 } 291 }); 280 Collections.sort((ArrayList<WayPoint>) waypoints, (a, b) -> a.time <= b.time ? -1 : 1); 292 281 293 282 firstTime = -1.0; /* this time of the first waypoint, not first trackpoint */ … … 299 288 AudioMarker am = new AudioMarker(w.getCoor(), w, url, ml, w.time, offset); 300 289 /* 301 * timeFromAudio intended for future use to shift markers of this type on 302 * synchronization 290 * timeFromAudio intended for future use to shift markers of this type on synchronization 303 291 */ 304 292 if (w == wayPointFromTimeStamp) { -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarker.java
r9779 r10611 7 7 import java.awt.Image; 8 8 import java.awt.event.ActionEvent; 9 import java.awt.event.ActionListener;10 9 import java.net.URL; 11 10 import java.util.Collections; … … 55 54 p2.add(scale); 56 55 p.add(p2, BorderLayout.SOUTH); 57 scale.addActionListener(new ActionListener() { 58 @Override 59 public void actionPerformed(ActionEvent ev) { 60 p.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 61 if (scale.getModel().isSelected()) { 62 ((JLabel) vp.getView()).setIcon(loadScaledImage(imageUrl, Math.max(vp.getWidth(), vp.getHeight()))); 63 } else { 64 ((JLabel) vp.getView()).setIcon(new ImageIcon(imageUrl)); 65 } 66 p.setCursor(Cursor.getDefaultCursor()); 56 scale.addActionListener(ev1 -> { 57 p.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 58 if (scale.getModel().isSelected()) { 59 ((JLabel) vp.getView()).setIcon(loadScaledImage(imageUrl, Math.max(vp.getWidth(), vp.getHeight()))); 60 } else { 61 ((JLabel) vp.getView()).setIcon(new ImageIcon(imageUrl)); 67 62 } 63 p.setCursor(Cursor.getDefaultCursor()); 68 64 }); 69 65 scale.setSelected(true); -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
r10173 r10611 183 183 // Add one Marker specifying the default behaviour. 184 184 static { 185 Marker.markerProducers.add(new MarkerProducers() { 186 @Override 187 public Collection<Marker> createMarkers(WayPoint wpt, File relativePath, MarkerLayer parentLayer, double time, double offset) { 188 String uri = null; 189 // cheapest way to check whether "link" object exists and is a non-empty collection of GpxLink objects... 190 Collection<GpxLink> links = wpt.<GpxLink>getCollection(GpxConstants.META_LINKS); 191 if (links != null) { 192 for (GpxLink oneLink : links) { 193 uri = oneLink.uri; 194 break; 185 Marker.markerProducers.add((wpt, relativePath, parentLayer, time, offset) -> { 186 String uri = null; 187 // cheapest way to check whether "link" object exists and is a non-empty collection of GpxLink objects... 188 Collection<GpxLink> links = wpt.<GpxLink>getCollection(GpxConstants.META_LINKS); 189 if (links != null) { 190 for (GpxLink oneLink : links) { 191 uri = oneLink.uri; 192 break; 193 } 194 } 195 196 URL url = uriToUrl(uri, relativePath); 197 198 String urlStr = url == null ? "" : url.toString(); 199 String symbolName = wpt.getString("symbol"); 200 if (symbolName == null) { 201 symbolName = wpt.getString(GpxConstants.PT_SYM); 202 } 203 // text marker is returned in every case, see #10208 204 final Marker marker = new Marker(wpt.getCoor(), wpt, symbolName, parentLayer, time, offset); 205 if (url == null) { 206 return Collections.singleton(marker); 207 } else if (urlStr.endsWith(".wav")) { 208 final AudioMarker audioMarker = new AudioMarker(wpt.getCoor(), wpt, url, parentLayer, time, offset); 209 Extensions exts = (Extensions) wpt.get(GpxConstants.META_EXTENSIONS); 210 if (exts != null && exts.containsKey("offset")) { 211 try { 212 audioMarker.syncOffset = Double.parseDouble(exts.get("sync-offset")); 213 } catch (NumberFormatException nfe) { 214 Main.warn(nfe); 195 215 } 196 216 } 197 198 URL url = uriToUrl(uri, relativePath); 199 200 String urlStr = url == null ? "" : url.toString(); 201 String symbolName = wpt.getString("symbol"); 202 if (symbolName == null) { 203 symbolName = wpt.getString(GpxConstants.PT_SYM); 204 } 205 // text marker is returned in every case, see #10208 206 final Marker marker = new Marker(wpt.getCoor(), wpt, symbolName, parentLayer, time, offset); 207 if (url == null) { 208 return Collections.singleton(marker); 209 } else if (urlStr.endsWith(".wav")) { 210 final AudioMarker audioMarker = new AudioMarker(wpt.getCoor(), wpt, url, parentLayer, time, offset); 211 Extensions exts = (Extensions) wpt.get(GpxConstants.META_EXTENSIONS); 212 if (exts != null && exts.containsKey("offset")) { 213 try { 214 audioMarker.syncOffset = Double.parseDouble(exts.get("sync-offset")); 215 } catch (NumberFormatException nfe) { 216 Main.warn(nfe); 217 } 218 } 219 return Arrays.asList(marker, audioMarker); 220 } else if (urlStr.endsWith(".png") || urlStr.endsWith(".jpg") || urlStr.endsWith(".jpeg") || urlStr.endsWith(".gif")) { 221 return Arrays.asList(marker, new ImageMarker(wpt.getCoor(), url, parentLayer, time, offset)); 222 } else { 223 return Arrays.asList(marker, new WebMarker(wpt.getCoor(), url, parentLayer, time, offset)); 224 } 217 return Arrays.asList(marker, audioMarker); 218 } else if (urlStr.endsWith(".png") || urlStr.endsWith(".jpg") || urlStr.endsWith(".jpeg") || urlStr.endsWith(".gif")) { 219 return Arrays.asList(marker, new ImageMarker(wpt.getCoor(), url, parentLayer, time, offset)); 220 } else { 221 return Arrays.asList(marker, new WebMarker(wpt.getCoor(), url, parentLayer, time, offset)); 225 222 } 226 223 }); -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r10458 r10611 20 20 import java.util.Collection; 21 21 import java.util.Collections; 22 import java.util.Comparator;23 22 import java.util.List; 24 23 … … 235 234 if (from instanceof MarkerLayer) { 236 235 data.addAll(((MarkerLayer) from).data); 237 Collections.sort(data, new Comparator<Marker>() { 238 @Override 239 public int compare(Marker o1, Marker o2) { 240 return Double.compare(o1.time, o2.time); 241 } 242 }); 236 Collections.sort(data, (o1, o2) -> Double.compare(o1.time, o2.time)); 243 237 } 244 238 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r10212 r10611 7 7 import java.awt.Point; 8 8 import java.awt.Rectangle; 9 import java.awt.event.ActionEvent;10 import java.awt.event.ActionListener;11 9 import java.awt.event.MouseAdapter; 12 10 import java.awt.event.MouseEvent; … … 290 288 if (timer == null) { 291 289 animationInterval = Main.pref.getDouble("marker.audioanimationinterval", 1.0); //milliseconds 292 timer = new Timer((int) (animationInterval * 1000.0), new ActionListener() { 293 @Override 294 public void actionPerformed(ActionEvent e) { 295 timerAction(); 296 } 297 }); 290 timer = new Timer((int) (animationInterval * 1000.0), e -> timerAction()); 298 291 timer.setInitialDelay(0); 299 292 } else { -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r10378 r10611 59 59 public void clearCached() { 60 60 // run in EDT to make sure this isn't called during rendering run 61 GuiHelper.runInEDT(new Runnable() { 62 @Override 63 public void run() { 64 cacheIdx++; 65 preferenceCache.clear(); 66 } 61 GuiHelper.runInEDT(() -> { 62 cacheIdx++; 63 preferenceCache.clear(); 67 64 }); 68 65 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r10567 r10611 365 365 @Override 366 366 protected void finish() { 367 SwingUtilities.invokeLater(new Runnable() { 368 @Override 369 public void run() { 370 fireMapPaintSylesUpdated(); 371 styles.clearCached(); 372 if (Main.isDisplayingMapView()) { 373 Main.map.mapView.preferenceChanged(null); 374 Main.map.mapView.repaint(); 375 } 367 SwingUtilities.invokeLater(() -> { 368 fireMapPaintSylesUpdated(); 369 styles.clearCached(); 370 if (Main.isDisplayingMapView()) { 371 Main.map.mapView.preferenceChanged(null); 372 Main.map.mapView.repaint(); 376 373 } 377 374 }); -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r10045 r10611 39 39 import org.openstreetmap.josm.tools.RightAndLefthandTraffic; 40 40 import org.openstreetmap.josm.tools.Utils; 41 import org.openstreetmap.josm.tools.Utils.Function; 41 42 42 43 /** … … 1127 1128 1128 1129 public Float aggregateList(List<?> lst) { 1129 final List<Float> floats = Utils.transform(lst, new Utils.Function<Object, Float>() { 1130 @Override 1131 public Float apply(Object x) { 1132 return Cascade.convertTo(x, float.class); 1133 } 1134 }); 1130 final List<Float> floats = Utils.transform(lst, (Function<Object, Float>) x -> Cascade.convertTo(x, float.class)); 1135 1131 final Collection<Float> nonNullList = Utils.filter(floats, Predicates.not(Predicates.isNull())); 1136 1132 return nonNullList.isEmpty() ? (Float) Float.NaN : computeMax ? Collections.max(nonNullList) : Collections.min(nonNullList); … … 1141 1137 List<?> l = Cascade.convertTo(args.get(0).evaluate(env), List.class); 1142 1138 if (args.size() != 1 || l == null) 1143 l = Utils.transform(args, new Utils.Function<Expression, Object>() { 1144 @Override 1145 public Object apply(Expression x) { 1146 return x.evaluate(env); 1147 } 1148 }); 1139 l = Utils.transform(args, (Function<Expression, Object>) x -> x.evaluate(env)); 1149 1140 return aggregateList(l); 1150 1141 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java
r10378 r10611 99 99 .setHeight(height) 100 100 .setOptional(true) 101 .getInBackground(new ImageCallback() { 102 @Override 103 public void finished(ImageIcon result) { 104 synchronized (MapImage.this) { 105 if (result == null) { 106 source.logWarning(tr("Failed to locate image ''{0}''", name)); 107 ImageIcon noIcon = MapPaintStyles.getNoIcon_Icon(source); 108 img = noIcon == null ? null : (BufferedImage) noIcon.getImage(); 109 } else { 110 img = (BufferedImage) rescale(result.getImage()); 111 } 112 if (temporary) { 113 disabledImgCache = null; 114 Main.map.mapView.preferenceChanged(null); // otherwise repaint is ignored, because layer hasn't changed 115 Main.map.mapView.repaint(); 116 } 117 temporary = false; 101 .getInBackground((ImageCallback) result -> { 102 synchronized (MapImage.this) { 103 if (result == null) { 104 source.logWarning(tr("Failed to locate image ''{0}''", name)); 105 ImageIcon noIcon = MapPaintStyles.getNoIcon_Icon(source); 106 img = noIcon == null ? null : (BufferedImage) noIcon.getImage(); 107 } else { 108 img = (BufferedImage) rescale(result.getImage()); 118 109 } 110 if (temporary) { 111 disabledImgCache = null; 112 Main.map.mapView.preferenceChanged(null); // otherwise repaint is ignored, because layer hasn't changed 113 Main.map.mapView.repaint(); 114 } 115 temporary = false; 119 116 } 120 117 } -
trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java
r10369 r10611 465 465 466 466 protected void handleException(final OsmOAuthAuthorizationException e) { 467 Runnable r = new Runnable() { 468 @Override 469 public void run() { 470 if (e instanceof OsmLoginFailedException) { 471 alertLoginFailed((OsmLoginFailedException) e); 472 } else { 473 alertAuthorisationFailed(e); 474 } 467 Runnable r = () -> { 468 if (e instanceof OsmLoginFailedException) { 469 alertLoginFailed((OsmLoginFailedException) e); 470 } else { 471 alertAuthorisationFailed(e); 475 472 } 476 473 }; … … 505 502 getProgressMonitor().worked(1); 506 503 if (canceled) return; 507 GuiHelper.runInEDT(new Runnable() { 508 @Override 509 public void run() { 510 prepareUIForResultDisplay(); 511 setAccessToken(accessToken); 512 } 504 GuiHelper.runInEDT(() -> { 505 prepareUIForResultDisplay(); 506 setAccessToken(accessToken); 513 507 }); 514 508 } catch (final OsmOAuthAuthorizationException e) { -
trunk/src/org/openstreetmap/josm/gui/oauth/RetrieveAccessTokenTask.java
r9256 r10611 90 90 } catch (final OsmOAuthAuthorizationException e) { 91 91 Main.error(e); 92 GuiHelper.runInEDT(new Runnable() { 93 @Override 94 public void run() { 95 alertRetrievingAccessTokenFailed(e); 96 } 97 }); 92 GuiHelper.runInEDT(() -> alertRetrievingAccessTokenFailed(e)); 98 93 accessToken = null; 99 94 } finally { -
trunk/src/org/openstreetmap/josm/gui/oauth/RetrieveRequestTokenTask.java
r9354 r10611 84 84 } catch (final OsmOAuthAuthorizationException e) { 85 85 Main.error(e); 86 GuiHelper.runInEDT(new Runnable() { 87 @Override 88 public void run() { 89 alertRetrievingRequestTokenFailed(e); 90 } 91 }); 86 GuiHelper.runInEDT(() -> alertRetrievingRequestTokenFailed(e)); 92 87 requestToken = null; 93 88 } finally { -
trunk/src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java
r10378 r10611 13 13 import java.awt.event.ActionEvent; 14 14 import java.awt.event.ItemEvent; 15 import java.awt.event.ItemListener;16 15 import java.util.concurrent.Executor; 17 16 … … 143 142 cbShowAdvancedParameters.setSelected(false); 144 143 cbShowAdvancedParameters.addItemListener( 145 new ItemListener() { 146 @Override 147 public void itemStateChanged(ItemEvent evt) { 148 getAdvancedPropertiesPanel().setVisible(evt.getStateChange() == ItemEvent.SELECTED); 149 } 150 } 144 evt -> getAdvancedPropertiesPanel().setVisible(evt.getStateChange() == ItemEvent.SELECTED) 151 145 ); 152 146 … … 400 394 ); 401 395 executor.execute(task); 402 Runnable r = new Runnable() { 403 @Override 404 public void run() { 405 if (task.isCanceled()) return; 406 if (task.getRequestToken() == null) return; 407 requestToken = task.getRequestToken(); 408 GuiHelper.runInEDT(new Runnable() { 409 @Override 410 public void run() { 411 transitionToRetrieveAccessToken(); 412 } 413 }); 414 } 396 Runnable r = () -> { 397 if (task.isCanceled()) return; 398 if (task.getRequestToken() == null) return; 399 requestToken = task.getRequestToken(); 400 GuiHelper.runInEDT(SemiAutomaticAuthorizationUI.this::transitionToRetrieveAccessToken); 415 401 }; 416 402 executor.execute(r); … … 437 423 ); 438 424 executor.execute(task); 439 Runnable r = new Runnable() { 440 @Override 441 public void run() { 442 if (task.isCanceled()) return; 443 if (task.getAccessToken() == null) return; 444 GuiHelper.runInEDT(new Runnable() { 445 @Override 446 public void run() { 447 setAccessToken(task.getAccessToken()); 448 transitionToShowAccessToken(); 449 } 450 }); 451 } 425 Runnable r = () -> { 426 if (task.isCanceled()) return; 427 if (task.getAccessToken() == null) return; 428 GuiHelper.runInEDT(() -> { 429 setAccessToken(task.getAccessToken()); 430 transitionToShowAccessToken(); 431 }); 452 432 }; 453 433 executor.execute(r); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r10369 r10611 12 12 import java.awt.Insets; 13 13 import java.awt.event.ActionEvent; 14 import java.awt.event.ActionListener;15 14 import java.awt.event.KeyEvent; 16 15 import java.awt.event.WindowAdapter; … … 19 18 import javax.swing.AbstractAction; 20 19 import javax.swing.BorderFactory; 20 import javax.swing.JButton; 21 21 import javax.swing.JCheckBox; 22 22 import javax.swing.JComponent; 23 import javax.swing.JButton;24 23 import javax.swing.JDialog; 25 24 import javax.swing.JPanel; … … 58 57 JCheckBox expert = new JCheckBox(tr("Expert mode")); 59 58 expert.setSelected(ExpertToggleAction.isExpert()); 60 expert.addActionListener(new ActionListener() { 61 @Override 62 public void actionPerformed(ActionEvent e) { 63 ExpertToggleAction.getInstance().actionPerformed(null); 64 } 65 }); 59 expert.addActionListener(e -> ExpertToggleAction.getInstance().actionPerformed(null)); 66 60 67 61 JPanel btns = new JPanel(new FlowLayout(FlowLayout.CENTER)); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r10600 r10611 322 322 323 323 public void selectTabByName(String name) { 324 selectTabBy(new TabIdentifier() { 325 @Override 326 public boolean identify(TabPreferenceSetting tps, Object name) { 327 return name != null && tps != null && tps.getIconName() != null && name.equals(tps.getIconName()); 328 } 329 }, name); 324 selectTabBy((tps, name1) -> name1 != null && tps != null && tps.getIconName() != null && name1.equals(tps.getIconName()), name); 330 325 } 331 326 332 327 public void selectTabByPref(Class<? extends TabPreferenceSetting> clazz) { 333 selectTabBy(new TabIdentifier() { 334 @Override 335 public boolean identify(TabPreferenceSetting tps, Object clazz) { 336 return tps.getClass().isAssignableFrom((Class<?>) clazz); 337 } 338 }, clazz); 328 selectTabBy((tps, clazz1) -> tps.getClass().isAssignableFrom((Class<?>) clazz1), clazz); 339 329 } 340 330 … … 344 334 final SubPreferenceSetting sub = (SubPreferenceSetting) setting; 345 335 final TabPreferenceSetting tab = sub.getTabPreferenceSetting(this); 346 selectTabBy(new TabIdentifier() { 347 @Override 348 public boolean identify(TabPreferenceSetting tps, Object unused) { 349 return tps.equals(tab); 350 } 351 }, null); 336 selectTabBy((tps, unused) -> tps.equals(tab), null); 352 337 return tab.selectSubTab(sub); 353 338 } … … 419 404 public void savePreferences() { 420 405 // create a task for downloading plugins if the user has activated, yet not downloaded, new plugins 421 //422 406 final PluginPreference preference = getPluginPreference(); 423 407 final Set<PluginInformation> toDownload = preference.getPluginsScheduledForUpdateOrDownload(); … … 430 414 431 415 // this is the task which will run *after* the plugins are downloaded 432 //433 416 final Runnable continuation = new PluginDownloadAfterTask(preference, task, toDownload); 434 417 … … 436 419 // if we have to launch a plugin download task we do it asynchronously, followed 437 420 // by the remaining "save preferences" activites run on the Swing EDT. 438 //439 421 Main.worker.submit(task); 440 Main.worker.submit( 441 new Runnable() { 442 @Override 443 public void run() { 444 SwingUtilities.invokeLater(continuation); 445 } 446 } 447 ); 422 Main.worker.submit(() -> SwingUtilities.invokeLater(continuation)); 448 423 } else { 449 424 // no need for asynchronous activities. Simply run the remaining "save preference" 450 425 // activities on this thread (we are already on the Swing EDT 451 //452 426 continuation.run(); 453 427 } -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r10482 r10611 18 18 import java.awt.event.MouseAdapter; 19 19 import java.awt.event.MouseEvent; 20 import java.beans.PropertyChangeEvent;21 import java.beans.PropertyChangeListener;22 20 import java.io.BufferedReader; 23 21 import java.io.File; … … 29 27 import java.util.Collection; 30 28 import java.util.Collections; 31 import java.util.Comparator;32 29 import java.util.EventObject; 33 30 import java.util.HashMap; … … 66 63 import javax.swing.event.CellEditorListener; 67 64 import javax.swing.event.ChangeEvent; 68 import javax.swing.event.ChangeListener;69 65 import javax.swing.event.DocumentEvent; 70 66 import javax.swing.event.DocumentListener; … … 165 161 } 166 162 167 activeSourcesModel.addTableModelListener(new TableModelListener() { 168 @Override 169 public void tableChanged(TableModelEvent e) { 170 listCellRenderer.updateSources(activeSourcesModel.getSources()); 171 lstAvailableSources.repaint(); 172 } 163 activeSourcesModel.addTableModelListener(e -> { 164 listCellRenderer.updateSources(activeSourcesModel.getSources()); 165 lstAvailableSources.repaint(); 173 166 }); 174 tblActiveSources.addPropertyChangeListener(new PropertyChangeListener() { 175 @Override 176 public void propertyChange(PropertyChangeEvent evt) { 177 listCellRenderer.updateSources(activeSourcesModel.getSources()); 178 lstAvailableSources.repaint(); 179 } 167 tblActiveSources.addPropertyChangeListener(evt -> { 168 listCellRenderer.updateSources(activeSourcesModel.getSources()); 169 lstAvailableSources.repaint(); 180 170 }); 181 activeSourcesModel.addTableModelListener(new TableModelListener() { 182 // Force swing to show horizontal scrollbars for the JTable 183 // Yes, this is a little ugly, but should work 184 @Override 185 public void tableChanged(TableModelEvent e) { 186 TableHelper.adjustColumnWidth(tblActiveSources, canEnable ? 1 : 0, 800); 187 } 188 }); 171 // Force Swing to show horizontal scrollbars for the JTable 172 // Yes, this is a little ugly, but should work 173 activeSourcesModel.addTableModelListener(e -> TableHelper.adjustColumnWidth(tblActiveSources, canEnable ? 1 : 0, 800)); 189 174 activeSourcesModel.setActiveSources(getInitialSourcesList()); 190 175 … … 1238 1223 1239 1224 protected void sort() { 1240 Collections.sort( 1241 data, 1242 new Comparator<String>() { 1243 @Override 1244 public int compare(String o1, String o2) { 1245 if (o1.isEmpty() && o2.isEmpty()) 1246 return 0; 1247 if (o1.isEmpty()) return 1; 1248 if (o2.isEmpty()) return -1; 1249 return o1.compareTo(o2); 1250 } 1251 } 1252 ); 1225 Collections.sort(data, 1226 (o1, o2) -> { 1227 if (o1.isEmpty() && o2.isEmpty()) 1228 return 0; 1229 if (o1.isEmpty()) return 1; 1230 if (o2.isEmpty()) return -1; 1231 return o1.compareTo(o2); 1232 }); 1253 1233 } 1254 1234 … … 1380 1360 final String msg = tr(getStr(I18nString.FAILED_TO_LOAD_SOURCES_FROM), url, emsg); 1381 1361 1382 GuiHelper.runInEDT(new Runnable() { 1383 @Override 1384 public void run() { 1385 HelpAwareOptionPane.showOptionDialog( 1386 Main.parent, 1387 msg, 1388 tr("Error"), 1389 JOptionPane.ERROR_MESSAGE, 1390 ht(getStr(I18nString.FAILED_TO_LOAD_SOURCES_FROM_HELP_TOPIC)) 1391 ); 1392 } 1393 }); 1362 GuiHelper.runInEDT(() -> HelpAwareOptionPane.showOptionDialog( 1363 Main.parent, 1364 msg, 1365 tr("Error"), 1366 JOptionPane.ERROR_MESSAGE, 1367 ht(getStr(I18nString.FAILED_TO_LOAD_SOURCES_FROM_HELP_TOPIC)) 1368 )); 1394 1369 } 1395 1370 … … 1746 1721 */ 1747 1722 public final void deferLoading(final DefaultTabPreferenceSetting tab, final Component component) { 1748 tab.getTabPane().addChangeListener( 1749 new ChangeListener() { 1750 @Override 1751 public void stateChanged(ChangeEvent e) { 1752 if (tab.getTabPane().getSelectedComponent() == component) { 1753 SourceEditor.this.initiallyLoadAvailableSources(); 1754 } 1755 } 1756 } 1757 ); 1723 tab.getTabPane().addChangeListener(e -> { 1724 if (tab.getTabPane().getSelectedComponent() == component) { 1725 SourceEditor.this.initiallyLoadAvailableSources(); 1726 } 1727 }); 1758 1728 } 1759 1729 -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r10378 r10611 18 18 import java.awt.event.InputEvent; 19 19 import java.awt.event.KeyEvent; 20 import java.beans.PropertyChangeEvent;21 import java.beans.PropertyChangeListener;22 20 import java.io.IOException; 23 21 import java.util.ArrayList; … … 51 49 import javax.swing.MenuElement; 52 50 import javax.swing.TransferHandler; 53 import javax.swing.event.ListSelectionEvent;54 import javax.swing.event.ListSelectionListener;55 51 import javax.swing.event.PopupMenuEvent; 56 52 import javax.swing.event.PopupMenuListener; 57 import javax.swing.event.TreeSelectionEvent;58 import javax.swing.event.TreeSelectionListener;59 53 import javax.swing.table.AbstractTableModel; 60 54 import javax.swing.tree.DefaultMutableTreeNode; … … 69 63 import org.openstreetmap.josm.actions.ParameterizedAction; 70 64 import org.openstreetmap.josm.actions.ParameterizedActionDecorator; 71 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;72 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;73 65 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 74 66 import org.openstreetmap.josm.tools.GBC; … … 762 754 }; 763 755 selectedList.setCellRenderer(renderer); 764 selectedList.addListSelectionListener(new ListSelectionListener() { 765 @Override 766 public void valueChanged(ListSelectionEvent e) { 767 boolean sel = selectedList.getSelectedIndex() != -1; 768 if (sel) { 769 actionsTr