- 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 actionsTree.clearSelection(); 770 ActionDefinition action = selected.get(selectedList.getSelectedIndex()); 771 actionParametersModel.setCurrentAction(action); 772 actionParametersPanel.setVisible(actionParametersModel.getRowCount() > 0); 773 } 774 updateEnabledState(); 775 } 756 selectedList.addListSelectionListener(e -> { 757 boolean sel = selectedList.getSelectedIndex() != -1; 758 if (sel) { 759 actionsTree.clearSelection(); 760 ActionDefinition action = selected.get(selectedList.getSelectedIndex()); 761 actionParametersModel.setCurrentAction(action); 762 actionParametersPanel.setVisible(actionParametersModel.getRowCount() > 0); 763 } 764 updateEnabledState(); 776 765 }); 777 766 … … 804 793 }); 805 794 actionsTree.setDragEnabled(true); 806 actionsTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { 807 @Override public void valueChanged(TreeSelectionEvent e) { 808 updateEnabledState(); 809 } 810 }); 795 actionsTree.getSelectionModel().addTreeSelectionListener(e -> updateEnabledState()); 811 796 812 797 final JPanel left = new JPanel(new GridBagLayout()); … … 914 899 control.setFloatable(false); 915 900 control.setComponentPopupMenu(popupMenu); 916 Main.pref.addPreferenceChangeListener(new PreferenceChangedListener() { 917 @Override 918 public void preferenceChanged(PreferenceChangeEvent e) { 919 if ("toolbar.visible".equals(e.getKey())) { 920 refreshToolbarControl(); 921 } 901 Main.pref.addPreferenceChangeListener(e -> { 902 if ("toolbar.visible".equals(e.getKey())) { 903 refreshToolbarControl(); 922 904 } 923 905 }); … … 1078 1060 } else { 1079 1061 // hide action text if an icon is set later (necessary for delayed/background image loading) 1080 action.getParametrizedAction().addPropertyChangeListener(new PropertyChangeListener() { 1081 1082 @Override 1083 public void propertyChange(PropertyChangeEvent evt) { 1084 if (Action.SMALL_ICON.equals(evt.getPropertyName())) { 1085 b.setHideActionText(evt.getNewValue() != null); 1086 } 1062 action.getParametrizedAction().addPropertyChangeListener(evt -> { 1063 if (Action.SMALL_ICON.equals(evt.getPropertyName())) { 1064 b.setHideActionText(evt.getNewValue() != null); 1087 1065 } 1088 1066 }); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r9759 r10611 75 75 private final Map<String, String> profileTypes = new LinkedHashMap<>(); 76 76 77 private final Comparator<PrefEntry> customComparator = new Comparator<PrefEntry>() { 78 @Override 79 public int compare(PrefEntry o1, PrefEntry o2) { 80 if (o1.isChanged() && !o2.isChanged()) 81 return -1; 82 if (o2.isChanged() && !o1.isChanged()) 83 return 1; 84 if (!(o1.isDefault()) && o2.isDefault()) 85 return -1; 86 if (!(o2.isDefault()) && o1.isDefault()) 87 return 1; 88 return o1.compareTo(o2); 89 } 77 private final Comparator<PrefEntry> customComparator = (o1, o2) -> { 78 if (o1.isChanged() && !o2.isChanged()) 79 return -1; 80 if (o2.isChanged() && !o1.isChanged()) 81 return 1; 82 if (!(o1.isDefault()) && o2.isDefault()) 83 return -1; 84 if (!(o2.isDefault()) && o1.isDefault()) 85 return 1; 86 return o1.compareTo(o2); 90 87 }; 91 88 … … 139 136 p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 140 137 p.add(add, GBC.std().insets(0, 5, 0, 0)); 141 add.addActionListener(new ActionListener() { 142 @Override public void actionPerformed(ActionEvent e) { 143 PrefEntry pe = table.addPreference(gui); 144 if (pe != null) { 145 allData.add(pe); 146 Collections.sort(allData); 147 applyFilter(); 148 } 138 add.addActionListener(e -> { 139 PrefEntry pe = table.addPreference(gui); 140 if (pe != null) { 141 allData.add(pe); 142 Collections.sort(allData); 143 applyFilter(); 149 144 } 150 145 }); … … 152 147 JButton edit = new JButton(tr("Edit")); 153 148 p.add(edit, GBC.std().insets(5, 5, 5, 0)); 154 edit.addActionListener(new ActionListener() { 155 @Override public void actionPerformed(ActionEvent e) { 156 if (table.editPreference(gui)) 157 applyFilter(); 158 } 149 edit.addActionListener(e -> { 150 if (table.editPreference(gui)) 151 applyFilter(); 159 152 }); 160 153 161 154 JButton reset = new JButton(tr("Reset")); 162 155 p.add(reset, GBC.std().insets(0, 5, 0, 0)); 163 reset.addActionListener(new ActionListener() { 164 @Override public void actionPerformed(ActionEvent e) { 165 table.resetPreferences(gui); 166 } 167 }); 156 reset.addActionListener(e -> table.resetPreferences(gui)); 168 157 169 158 JButton read = new JButton(tr("Read from file")); 170 159 p.add(read, GBC.std().insets(5, 5, 0, 0)); 171 read.addActionListener(new ActionListener() { 172 @Override public void actionPerformed(ActionEvent e) { 173 readPreferencesFromXML(); 174 } 175 }); 160 read.addActionListener(e -> readPreferencesFromXML()); 176 161 177 162 JButton export = new JButton(tr("Export selected items")); 178 163 p.add(export, GBC.std().insets(5, 5, 0, 0)); 179 export.addActionListener(new ActionListener() { 180 @Override public void actionPerformed(ActionEvent e) { 181 exportSelectedToXML(); 182 } 183 }); 164 export.addActionListener(e -> exportSelectedToXML()); 184 165 185 166 final JButton more = new JButton(tr("More...")); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ListEditor.java
r10047 r10611 19 19 import org.openstreetmap.josm.gui.widgets.JosmTextField; 20 20 import org.openstreetmap.josm.tools.GBC; 21 import org.openstreetmap.josm.tools.Predicate;22 21 import org.openstreetmap.josm.tools.Utils; 23 22 … … 44 43 @Override 45 44 public List<String> getData() { 46 return new ArrayList<>(Utils.filter(model.getData(), new Predicate<String>() { 47 @Override 48 public boolean evaluate(String object) { 49 return object != null && !object.isEmpty(); 50 } 51 })); 45 return new ArrayList<>(Utils.filter(model.getData(), object -> object != null && !object.isEmpty())); 52 46 } 53 47 -
trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java
r10001 r10611 5 5 6 6 import java.awt.Color; 7 import java.awt.Component;8 7 import java.awt.Dimension; 9 8 import java.awt.GridBagLayout; 10 import java.awt.event.ActionEvent;11 import java.awt.event.ActionListener;12 9 import java.awt.event.MouseAdapter; 13 10 import java.awt.event.MouseEvent; … … 156 153 157 154 colorEdit = new JButton(tr("Choose")); 158 colorEdit.addActionListener(new ActionListener() { 159 @Override 160 public void actionPerformed(ActionEvent e) { 161 int sel = colors.getSelectedRow(); 162 JColorChooser chooser = new JColorChooser((Color) colors.getValueAt(sel, 1)); 163 int answer = JOptionPane.showConfirmDialog( 164 gui, chooser, 165 tr("Choose a color for {0}", getName((String) colors.getValueAt(sel, 0))), 166 JOptionPane.OK_CANCEL_OPTION, 167 JOptionPane.PLAIN_MESSAGE); 168 if (answer == JOptionPane.OK_OPTION) { 169 colors.setValueAt(chooser.getColor(), sel, 1); 170 } 155 colorEdit.addActionListener(e -> { 156 int sel = colors.getSelectedRow(); 157 JColorChooser chooser = new JColorChooser((Color) colors.getValueAt(sel, 1)); 158 int answer = JOptionPane.showConfirmDialog( 159 gui, chooser, 160 tr("Choose a color for {0}", getName((String) colors.getValueAt(sel, 0))), 161 JOptionPane.OK_CANCEL_OPTION, 162 JOptionPane.PLAIN_MESSAGE); 163 if (answer == JOptionPane.OK_OPTION) { 164 colors.setValueAt(chooser.getColor(), sel, 1); 171 165 } 172 166 }); 173 167 defaultSet = new JButton(tr("Set to default")); 174 defaultSet.addActionListener(new ActionListener() { 175 @Override 176 public void actionPerformed(ActionEvent e) { 177 int sel = colors.getSelectedRow(); 178 String name = (String) colors.getValueAt(sel, 0); 168 defaultSet.addActionListener(e -> { 169 int sel = colors.getSelectedRow(); 170 String name = (String) colors.getValueAt(sel, 0); 171 Color c = Main.pref.getDefaultColor(name); 172 if (c != null) { 173 colors.setValueAt(c, sel, 1); 174 } 175 }); 176 JButton defaultAll = new JButton(tr("Set all to default")); 177 defaultAll.addActionListener(e -> { 178 for (int i = 0; i < colors.getRowCount(); ++i) { 179 String name = (String) colors.getValueAt(i, 0); 179 180 Color c = Main.pref.getDefaultColor(name); 180 181 if (c != null) { 181 colors.setValueAt(c, sel, 1);182 colors.setValueAt(c, i, 1); 182 183 } 183 184 } 184 185 }); 185 JButton defaultAll = new JButton(tr("Set all to default"));186 defaultAll.addActionListener(new ActionListener() {187 @Override188 public void actionPerformed(ActionEvent e) {189 for (int i = 0; i < colors.getRowCount(); ++i) {190 String name = (String) colors.getValueAt(i, 0);191 Color c = Main.pref.getDefaultColor(name);192 if (c != null) {193 colors.setValueAt(c, i, 1);194 }195 }196 }197 });198 186 remove = new JButton(tr("Remove")); 199 remove.addActionListener(new ActionListener() { 200 @Override 201 public void actionPerformed(ActionEvent e) { 202 int sel = colors.getSelectedRow(); 203 del.add((String) colors.getValueAt(sel, 0)); 204 tableModel.removeRow(sel); 205 } 187 remove.addActionListener(e -> { 188 int sel = colors.getSelectedRow(); 189 del.add((String) colors.getValueAt(sel, 0)); 190 tableModel.removeRow(sel); 206 191 }); 207 192 remove.setEnabled(false); … … 233 218 colors.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 234 219 final TableCellRenderer oldColorsRenderer = colors.getDefaultRenderer(Object.class); 235 colors.setDefaultRenderer(Object.class, new TableCellRenderer() { 236 @Override 237 public Component getTableCellRendererComponent(JTable t, Object o, boolean selected, boolean focus, int row, int column) { 238 if (o == null) 239 return new JLabel(); 240 if (column == 1) { 241 Color c = (Color) o; 242 JLabel l = new JLabel(ColorHelper.color2html(c)); 243 GuiHelper.setBackgroundReadable(l, c); 244 l.setOpaque(true); 245 return l; 246 } 247 return oldColorsRenderer.getTableCellRendererComponent(t, getName(o.toString()), selected, focus, row, column); 248 } 220 colors.setDefaultRenderer(Object.class, (t, o, selected, focus, row, column) -> { 221 if (o == null) 222 return new JLabel(); 223 if (column == 1) { 224 Color c = (Color) o; 225 JLabel l = new JLabel(ColorHelper.color2html(c)); 226 GuiHelper.setBackgroundReadable(l, c); 227 l.setOpaque(true); 228 return l; 229 } 230 return oldColorsRenderer.getTableCellRendererComponent(t, getName(o.toString()), selected, focus, row, column); 249 231 }); 250 232 colors.getColumnModel().getColumn(1).setWidth(100); -
trunk/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java
r9778 r10611 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.event.ActionEvent;8 import java.awt.event.ActionListener;9 7 10 8 import javax.swing.BorderFactory; … … 71 69 72 70 // directionHint 73 directionHint.addActionListener(new ActionListener() { 74 @Override 75 public void actionPerformed(ActionEvent e) { 76 if (directionHint.isSelected()) { 77 headArrow.setSelected(Main.pref.getBoolean("draw.segment.head_only", false)); 78 } else { 79 headArrow.setSelected(false); 80 } 81 headArrow.setEnabled(directionHint.isSelected()); 71 directionHint.addActionListener(e -> { 72 if (directionHint.isSelected()) { 73 headArrow.setSelected(Main.pref.getBoolean("draw.segment.head_only", false)); 74 } else { 75 headArrow.setSelected(false); 82 76 } 77 headArrow.setEnabled(directionHint.isSelected()); 83 78 }); 84 79 directionHint.setToolTipText(tr("Draw direction hints for way segments.")); -
trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java
r10378 r10611 7 7 import java.awt.Component; 8 8 import java.awt.GridBagLayout; 9 import java.awt.event.ActionEvent;10 9 import java.awt.event.ActionListener; 11 10 … … 18 17 import javax.swing.JPanel; 19 18 import javax.swing.JRadioButton; 20 import javax.swing.event.ChangeEvent;21 import javax.swing.event.ChangeListener;22 19 23 20 import org.openstreetmap.josm.Main; … … 140 137 ExpertToggleAction.addVisibilitySwitcher(drawRawGpsLinesAll); 141 138 142 drawRawGpsLinesActionListener = new ActionListener() { 143 @Override 144 public void actionPerformed(ActionEvent e) { 145 boolean f = drawRawGpsLinesNone.isSelected() || drawRawGpsLinesGlobal.isSelected(); 146 forceRawGpsLines.setEnabled(!f); 147 drawRawGpsMaxLineLength.setEnabled(!(f || drawRawGpsLinesLocal.isSelected())); 148 drawRawGpsMaxLineLengthLocal.setEnabled(!f); 149 drawGpsArrows.setEnabled(!f); 150 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 151 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 152 } 139 drawRawGpsLinesActionListener = e -> { 140 boolean f = drawRawGpsLinesNone.isSelected() || drawRawGpsLinesGlobal.isSelected(); 141 forceRawGpsLines.setEnabled(!f); 142 drawRawGpsMaxLineLength.setEnabled(!(f || drawRawGpsLinesLocal.isSelected())); 143 drawRawGpsMaxLineLengthLocal.setEnabled(!f); 144 drawGpsArrows.setEnabled(!f); 145 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 146 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 153 147 }; 154 148 … … 181 175 182 176 // drawGpsArrows 183 drawGpsArrows.addActionListener(new ActionListener() { 184 @Override 185 public void actionPerformed(ActionEvent e) { 186 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 187 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 188 } 177 drawGpsArrows.addActionListener(e -> { 178 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 179 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 189 180 }); 190 181 drawGpsArrows.setToolTipText(tr("Draw direction arrows for lines, connecting GPS points.")); … … 231 222 colorGroup.add(colorTypeTime); 232 223 233 colorTypeVelocity.addChangeListener(new ChangeListener() { 234 @Override 235 public void stateChanged(ChangeEvent e) { 236 colorTypeVelocityTune.setEnabled(colorTypeVelocity.isSelected()); 237 colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected()); 238 } 224 colorTypeVelocity.addChangeListener(e -> { 225 colorTypeVelocityTune.setEnabled(colorTypeVelocity.isSelected()); 226 colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected()); 239 227 }); 240 colorTypeDilution.addChangeListener(new ChangeListener() { 241 @Override 242 public void stateChanged(ChangeEvent e) { 243 colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected()); 244 } 245 }); 228 colorTypeDilution.addChangeListener(e -> colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected())); 246 229 247 230 colorTypeNone.setToolTipText(tr("All points and track segments will have the same color. Can be customized in Layer Manager.")); … … 283 266 label.setLabelFor(waypointLabel); 284 267 add(waypointLabel, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5)); 285 waypointLabel.addActionListener(new ActionListener() { 286 @Override 287 public void actionPerformed(ActionEvent e) { 288 updateWaypointPattern(waypointLabel, waypointLabelPattern); 289 } 290 }); 268 waypointLabel.addActionListener(e -> updateWaypointPattern(waypointLabel, waypointLabelPattern)); 291 269 updateWaypointLabelCombobox(waypointLabel, waypointLabelPattern, TemplateEntryProperty.forMarker(layerName)); 292 270 add(waypointLabelPattern, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 0, 0, 5)); … … 304 282 label.setLabelFor(audioWaypointLabel); 305 283 add(audioWaypointLabel, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5)); 306 audioWaypointLabel.addActionListener(new ActionListener() { 307 @Override 308 public void actionPerformed(ActionEvent e) { 309 updateWaypointPattern(audioWaypointLabel, audioWaypointLabelPattern); 310 } 311 }); 284 audioWaypointLabel.addActionListener(e -> updateWaypointPattern(audioWaypointLabel, audioWaypointLabelPattern)); 312 285 updateWaypointLabelCombobox(audioWaypointLabel, audioWaypointLabelPattern, TemplateEntryProperty.forAudioMarker(layerName)); 313 286 add(audioWaypointLabelPattern, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 0, 0, 5)); -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddImageryPanel.java
r10600 r10611 9 9 import javax.swing.AbstractButton; 10 10 import javax.swing.JPanel; 11 import javax.swing.event.ChangeEvent;12 import javax.swing.event.ChangeListener;13 11 import javax.swing.event.DocumentEvent; 14 12 import javax.swing.event.DocumentListener; … … 56 54 57 55 protected final void registerValidableComponent(AbstractButton component) { 58 component.addChangeListener(new ChangeListener() { 59 @Override 60 public void stateChanged(ChangeEvent e) { 61 notifyListeners(); 62 } 63 }); 56 component.addChangeListener(e -> notifyListeners()); 64 57 } 65 58 -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java
r10520 r10611 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.event.ActionEvent;7 import java.awt.event.ActionListener;8 import java.awt.event.ItemEvent;9 import java.awt.event.ItemListener;10 import java.beans.PropertyChangeEvent;11 import java.beans.PropertyChangeListener;12 6 import java.io.IOException; 13 7 import java.net.MalformedURLException; … … 75 69 add(name, GBC.eop().fill()); 76 70 77 getLayers.addActionListener(new ActionListener() { 78 @Override 79 public void actionPerformed(ActionEvent e) { 80 try { 81 wms.attemptGetCapabilities(rawUrl.getText()); 82 tree.updateTree(wms); 83 formats.setModel(new DefaultComboBoxModel<>(wms.getFormats().toArray(new String[0]))); 84 formats.setSelectedItem(wms.getPreferredFormats()); 85 } catch (MalformedURLException ex) { 86 Main.error(ex, false); 87 JOptionPane.showMessageDialog(getParent(), tr("Invalid service URL."), 88 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 89 } catch (IOException ex) { 90 Main.error(ex, false); 91 JOptionPane.showMessageDialog(getParent(), tr("Could not retrieve WMS layer list."), 92 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 93 } catch (WMSImagery.WMSGetCapabilitiesException ex) { 94 String incomingData = ex.getIncomingData().trim(); 95 String title = tr("WMS Error"); 96 String message = tr("Could not parse WMS layer list."); 97 Main.error(ex, "Could not parse WMS layer list. Incoming data:\n"+incomingData); 98 if ((incomingData.startsWith("<html>") || incomingData.startsWith("<HTML>")) 99 && (incomingData.endsWith("</html>") || incomingData.endsWith("</HTML>"))) { 100 GuiHelper.notifyUserHtmlError(AddWMSLayerPanel.this, title, message, incomingData); 101 } else { 102 if (ex.getMessage() != null) { 103 message += '\n' + ex.getMessage(); 104 } 105 JOptionPane.showMessageDialog(getParent(), message, title, JOptionPane.ERROR_MESSAGE); 71 getLayers.addActionListener(e -> { 72 try { 73 wms.attemptGetCapabilities(rawUrl.getText()); 74 tree.updateTree(wms); 75 formats.setModel(new DefaultComboBoxModel<>(wms.getFormats().toArray(new String[0]))); 76 formats.setSelectedItem(wms.getPreferredFormats()); 77 } catch (MalformedURLException ex1) { 78 Main.error(ex1, false); 79 JOptionPane.showMessageDialog(getParent(), tr("Invalid service URL."), 80 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 81 } catch (IOException ex2) { 82 Main.error(ex2, false); 83 JOptionPane.showMessageDialog(getParent(), tr("Could not retrieve WMS layer list."), 84 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 85 } catch (WMSImagery.WMSGetCapabilitiesException ex3) { 86 String incomingData = ex3.getIncomingData().trim(); 87 String title = tr("WMS Error"); 88 String message = tr("Could not parse WMS layer list."); 89 Main.error(ex3, "Could not parse WMS layer list. Incoming data:\n"+incomingData); 90 if ((incomingData.startsWith("<html>") || incomingData.startsWith("<HTML>")) 91 && (incomingData.endsWith("</html>") || incomingData.endsWith("</HTML>"))) { 92 GuiHelper.notifyUserHtmlError(AddWMSLayerPanel.this, title, message, incomingData); 93 } else { 94 if (ex3.getMessage() != null) { 95 message += '\n' + ex3.getMessage(); 106 96 } 97 JOptionPane.showMessageDialog(getParent(), message, title, JOptionPane.ERROR_MESSAGE); 107 98 } 108 99 } 109 100 }); 110 101 111 endpoint.addItemListener(new ItemListener() { 112 @Override 113 public void itemStateChanged(ItemEvent e) { 114 tree.getLayerTree().setEnabled(!endpoint.isSelected()); 115 showBounds.setEnabled(!endpoint.isSelected()); 116 wmsInstruction.setEnabled(!endpoint.isSelected()); 117 formats.setEnabled(!endpoint.isSelected()); 118 wmsUrl.setEnabled(!endpoint.isSelected()); 119 if (endpoint.isSelected()) { 120 URL url = wms.getServiceUrl(); 121 if (url != null) { 122 name.setText(url.getHost()); 123 } 124 } else { 125 onLayerSelectionChanged(); 102 endpoint.addItemListener(e -> { 103 tree.getLayerTree().setEnabled(!endpoint.isSelected()); 104 showBounds.setEnabled(!endpoint.isSelected()); 105 wmsInstruction.setEnabled(!endpoint.isSelected()); 106 formats.setEnabled(!endpoint.isSelected()); 107 wmsUrl.setEnabled(!endpoint.isSelected()); 108 if (endpoint.isSelected()) { 109 URL url = wms.getServiceUrl(); 110 if (url != null) { 111 name.setText(url.getHost()); 126 112 } 127 } 128 }); 129 130 tree.getLayerTree().addPropertyChangeListener("selectedLayers", new PropertyChangeListener() { 131 @Override 132 public void propertyChange(PropertyChangeEvent evt) { 113 } else { 133 114 onLayerSelectionChanged(); 134 115 } 135 116 }); 136 117 137 formats.addActionListener(new ActionListener() { 138 @Override 139 public void actionPerformed(ActionEvent e) { 140 onLayerSelectionChanged(); 141 } 142 }); 118 tree.getLayerTree().addPropertyChangeListener("selectedLayers", evt -> onLayerSelectionChanged()); 143 119 144 showBounds.addActionListener(new ActionListener() { 145 @Override 146 public void actionPerformed(ActionEvent e) { 147 if (tree.getSelectedLayers().get(0).bounds != null) { 148 SlippyMapBBoxChooser mapPanel = new SlippyMapBBoxChooser(); 149 mapPanel.setBoundingBox(tree.getSelectedLayers().get(0).bounds); 150 JOptionPane.showMessageDialog(null, mapPanel, tr("Show Bounds"), JOptionPane.PLAIN_MESSAGE); 151 } else { 152 JOptionPane.showMessageDialog(null, tr("No bounding box was found for this layer."), 153 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 154 } 120 formats.addActionListener(e -> onLayerSelectionChanged()); 121 122 showBounds.addActionListener(e -> { 123 if (tree.getSelectedLayers().get(0).bounds != null) { 124 SlippyMapBBoxChooser mapPanel = new SlippyMapBBoxChooser(); 125 mapPanel.setBoundingBox(tree.getSelectedLayers().get(0).bounds); 126 JOptionPane.showMessageDialog(null, mapPanel, tr("Show Bounds"), JOptionPane.PLAIN_MESSAGE); 127 } else { 128 JOptionPane.showMessageDialog(null, tr("No bounding box was found for this layer."), 129 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); 155 130 } 156 131 }); -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CacheContentsPanel.java
r10541 r10611 8 8 import java.util.ArrayList; 9 9 import java.util.Collections; 10 import java.util.Comparator;11 10 import java.util.List; 12 11 import java.util.Map; … … 51 50 public CacheContentsPanel() { 52 51 super(new GridBagLayout()); 53 Main.worker.submit(new Runnable() { 54 @Override 55 public void run() { 56 addToPanel(TMSLayer.getCache(), "TMS"); 57 addToPanel(WMSLayer.getCache(), "WMS"); 58 addToPanel(WMTSLayer.getCache(), "WMTS"); 59 } 52 Main.worker.submit(() -> { 53 addToPanel(TMSLayer.getCache(), "TMS"); 54 addToPanel(WMSLayer.getCache(), "WMS"); 55 addToPanel(WMTSLayer.getCache(), "WMTS"); 60 56 }); 61 57 } … … 65 61 final TableModel tableModel = getTableModel(cache); 66 62 67 GuiHelper.runInEDT(new Runnable() { 68 @Override 69 public void run() { 70 add( 71 new JLabel(tr("{0} cache, total cache size: {1} bytes", name, cacheSize)), 72 GBC.eol().insets(5, 5, 0, 0)); 73 74 add( 75 new JScrollPane(getTableForCache(cache, tableModel)), 76 GBC.eol().fill(GBC.BOTH)); 77 } 63 GuiHelper.runInEDT(() -> { 64 add(new JLabel(tr("{0} cache, total cache size: {1} bytes", name, cacheSize)), 65 GBC.eol().insets(5, 5, 0, 0)); 66 add(new JScrollPane(getTableForCache(cache, tableModel)), 67 GBC.eol().fill(GBC.BOTH)); 78 68 }); 79 69 } … … 88 78 return (Long) val; 89 79 } 90 91 80 } 92 81 } … … 116 105 sortedStats.add(new Pair<>(e.getKey(), e.getValue()[0])); 117 106 } 118 Collections.sort(sortedStats, new Comparator<Pair<String, Integer>>() { 119 @Override 120 public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) { 121 return -1 * o1.b.compareTo(o2.b); 122 } 123 }); 107 Collections.sort(sortedStats, (o1, o2) -> -1 * o1.b.compareTo(o2.b)); 124 108 String[][] ret = new String[sortedStats.size()][3]; 125 109 int index = 0; -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CommonSettingsPanel.java
r10418 r10611 6 6 import java.awt.Color; 7 7 import java.awt.GridBagLayout; 8 import java.awt.event.ActionEvent;9 import java.awt.event.ActionListener;10 8 import java.io.File; 11 9 import java.io.FilenameFilter; … … 55 53 AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.get().intValue(), 0, Integer.MAX_VALUE, 1)); 56 54 57 58 55 this.btnFadeColor = new JButton(); 59 60 this.btnFadeColor.addActionListener(new ActionListener() { 61 @Override 62 public void actionPerformed(ActionEvent e) { 63 JColorChooser chooser = new JColorChooser(btnFadeColor.getBackground()); 64 int answer = JOptionPane.showConfirmDialog( 65 CommonSettingsPanel.this, chooser, 66 tr("Choose a color for {0}", tr("imagery fade")), 67 JOptionPane.OK_CANCEL_OPTION, 68 JOptionPane.PLAIN_MESSAGE); 69 if (answer == JOptionPane.OK_OPTION) { 70 Color colFadeColor = chooser.getColor(); 71 btnFadeColor.setBackground(colFadeColor); 72 btnFadeColor.setText(ColorHelper.color2html(colFadeColor)); 73 } 56 this.btnFadeColor.addActionListener(e -> { 57 JColorChooser chooser = new JColorChooser(btnFadeColor.getBackground()); 58 int answer = JOptionPane.showConfirmDialog( 59 CommonSettingsPanel.this, chooser, 60 tr("Choose a color for {0}", tr("imagery fade")), 61 JOptionPane.OK_CANCEL_OPTION, 62 JOptionPane.PLAIN_MESSAGE); 63 if (answer == JOptionPane.OK_OPTION) { 64 Color colFadeColor = chooser.getColor(); 65 btnFadeColor.setBackground(colFadeColor); 66 btnFadeColor.setText(ColorHelper.color2html(colFadeColor)); 74 67 } 75 68 }); … … 159 152 private void removeCacheFiles(String path) { 160 153 File directory = new File(path); 161 File[] cacheFiles = directory.listFiles(new FilenameFilter() { 162 @Override 163 public boolean accept(File dir, String name) { 164 return name.endsWith(".data") || name.endsWith(".key"); 165 } 166 167 }); 154 File[] cacheFiles = directory.listFiles((FilenameFilter) (dir, name) -> name.endsWith(".data") || name.endsWith(".key")); 168 155 JCSCacheManager.shutdown(); // shutdown Cache - so files can by safely deleted 169 156 for (File cacheFile: cacheFiles) { -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r10179 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.MouseEvent; 18 17 import java.io.IOException; … … 41 40 import javax.swing.event.ListSelectionEvent; 42 41 import javax.swing.event.ListSelectionListener; 43 import javax.swing.event.TableModelEvent;44 import javax.swing.event.TableModelListener;45 42 import javax.swing.table.DefaultTableCellRenderer; 46 43 import javax.swing.table.DefaultTableModel; … … 312 309 defaultTable = new JTable(defaultModel); 313 310 314 defaultModel.addTableModelListener( 315 new TableModelListener() { 316 @Override 317 public void tableChanged(TableModelEvent e) { 318 activeTable.repaint(); 319 } 320 } 321 ); 322 323 activeModel.addTableModelListener( 324 new TableModelListener() { 325 @Override 326 public void tableChanged(TableModelEvent e) { 327 defaultTable.repaint(); 328 } 329 } 330 ); 311 defaultModel.addTableModelListener(e -> activeTable.repaint()); 312 activeModel.addTableModelListener(e -> defaultTable.repaint()); 331 313 332 314 TableColumnModel mod = defaultTable.getColumnModel(); … … 839 821 JButton add = new JButton(tr("Add")); 840 822 buttonPanel.add(add, GBC.std().insets(0, 5, 0, 0)); 841 add.addActionListener(new ActionListener() { 842 @Override 843 public void actionPerformed(ActionEvent e) { 844 OffsetBookmark b = new OffsetBookmark(Main.getProjection().toCode(), "", "", 0, 0); 845 model.addRow(b); 846 } 847 }); 823 add.addActionListener(e -> model.addRow(new OffsetBookmark(Main.getProjection().toCode(), "", "", 0, 0))); 848 824 849 825 JButton delete = new JButton(tr("Delete")); 850 826 buttonPanel.add(delete, GBC.std().insets(0, 5, 0, 0)); 851 delete.addActionListener(new ActionListener() { 852 @Override 853 public void actionPerformed(ActionEvent e) { 854 if (list.getSelectedRow() == -1) { 855 JOptionPane.showMessageDialog(gui, tr("Please select the row to delete.")); 856 } else { 857 Integer i; 858 while ((i = list.getSelectedRow()) != -1) { 859 model.removeRow(i); 860 } 827 delete.addActionListener(e -> { 828 if (list.getSelectedRow() == -1) { 829 JOptionPane.showMessageDialog(gui, tr("Please select the row to delete.")); 830 } else { 831 Integer i; 832 while ((i = list.getSelectedRow()) != -1) { 833 model.removeRow(i); 861 834 } 862 835 } -
trunk/src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java
r9543 r10611 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.event.ActionEvent;8 7 import java.awt.event.ActionListener; 9 8 … … 101 100 panel.add(notification, GBC.eop()); 102 101 103 ActionListener autosaveEnabled = new ActionListener() { 104 @Override 105 public void actionPerformed(ActionEvent e) { 106 boolean enabled = autosave.isSelected(); 107 autosaveIntervalLabel.setEnabled(enabled); 108 autosaveInterval.setEnabled(enabled); 109 backupPerLayerLabel.setEnabled(enabled); 110 backupPerLayer.setEnabled(enabled); 111 } 102 ActionListener autosaveEnabled = e -> { 103 boolean enabled = autosave.isSelected(); 104 autosaveIntervalLabel.setEnabled(enabled); 105 autosaveInterval.setEnabled(enabled); 106 backupPerLayerLabel.setEnabled(enabled); 107 backupPerLayer.setEnabled(enabled); 112 108 }; 113 109 autosave.addActionListener(autosaveEnabled); -
trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java
r10420 r10611 33 33 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 34 34 import org.openstreetmap.josm.tools.GBC; 35 import org.openstreetmap.josm.tools.Predicate;36 35 import org.openstreetmap.josm.tools.Utils; 37 36 … … 233 232 int insertionIdx = 0; 234 233 for (final SourceEntry def : defaults) { 235 int i = Utils.indexOf(list, 236 new Predicate<SourceEntry>() { 237 @Override 238 public boolean evaluate(SourceEntry se) { 239 return Objects.equals(def.url, se.url); 240 } 241 }); 234 int i = Utils.indexOf(list, se -> Objects.equals(def.url, se.url)); 242 235 if (i == -1 && !knownDefaults.contains(def.url)) { 243 236 def.active = false; … … 255 248 256 249 // XML style is not bundled anymore 257 list.remove(Utils.find(list, new Predicate<SourceEntry>() { 258 @Override 259 public boolean evaluate(SourceEntry se) { 260 return "resource://styles/standard/elemstyles.xml".equals(se.url); 261 } 262 })); 250 list.remove(Utils.find(list, se -> "resource://styles/standard/elemstyles.xml".equals(se.url))); 263 251 264 252 return changed; -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java
r10228 r10611 15 15 import javax.swing.SwingConstants; 16 16 import javax.swing.SwingUtilities; 17 import javax.swing.event.HyperlinkEvent;18 17 import javax.swing.event.HyperlinkEvent.EventType; 19 import javax.swing.event.HyperlinkListener;20 18 21 19 import org.openstreetmap.josm.gui.widgets.HtmlPanel; … … 151 149 HtmlPanel description = new HtmlPanel(); 152 150 description.setText(pi.getDescriptionAsHtml()); 153 description.getEditorPane().addHyperlinkListener(new HyperlinkListener() { 154 @Override 155 public void hyperlinkUpdate(HyperlinkEvent e) { 156 if (e.getEventType() == EventType.ACTIVATED) { 157 OpenBrowser.displayUrl(e.getURL().toString()); 158 } 151 description.getEditorPane().addHyperlinkListener(e -> { 152 if (e.getEventType() == EventType.ACTIVATED) { 153 OpenBrowser.displayUrl(e.getURL().toString()); 159 154 } 160 155 }); … … 170 165 repaint(); 171 166 if (visibleRect != null && visibleRect.width > 0 && visibleRect.height > 0) { 172 SwingUtilities.invokeLater(new Runnable() { 173 @Override 174 public void run() { 175 scrollRectToVisible(visibleRect); 176 } 177 }); 167 SwingUtilities.invokeLater(() -> scrollRectToVisible(visibleRect)); 178 168 } 179 169 } -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r10482 r10611 150 150 sb.append("</html>"); 151 151 if (!GraphicsEnvironment.isHeadless()) { 152 GuiHelper.runInEDTAndWait(new Runnable() { 153 @Override 154 public void run() { 155 HelpAwareOptionPane.showOptionDialog( 156 parent, 157 sb.toString(), 158 tr("Update plugins"), 159 !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE, 160 HelpUtil.ht("/Preferences/Plugins") 161 ); 162 } 163 }); 152 GuiHelper.runInEDTAndWait(() -> HelpAwareOptionPane.showOptionDialog( 153 parent, 154 sb.toString(), 155 tr("Update plugins"), 156 !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE, 157 HelpUtil.ht("/Preferences/Plugins") 158 )); 164 159 } 165 160 } … … 318 313 public void readLocalPluginInformation() { 319 314 final ReadLocalPluginInformationTask task = new ReadLocalPluginInformationTask(); 320 Runnable r = new Runnable() { 321 @Override 322 public void run() { 323 if (!task.isCanceled()) { 324 SwingUtilities.invokeLater(new Runnable() { 325 @Override 326 public void run() { 327 model.setAvailablePlugins(task.getAvailablePlugins()); 328 pnlPluginPreferences.refreshView(); 329 } 330 }); 331 } 315 Runnable r = () -> { 316 if (!task.isCanceled()) { 317 SwingUtilities.invokeLater(() -> { 318 model.setAvailablePlugins(task.getAvailablePlugins()); 319 pnlPluginPreferences.refreshView(); 320 }); 332 321 } 333 322 }; … … 357 346 } 358 347 final ReadRemotePluginInformationTask task = new ReadRemotePluginInformationTask(pluginSites); 359 Runnable continuation = new Runnable() { 360 @Override 361 public void run() { 362 if (!task.isCanceled()) { 363 SwingUtilities.invokeLater(new Runnable() { 364 @Override 365 public void run() { 366 model.updateAvailablePlugins(task.getAvailablePlugins()); 367 pnlPluginPreferences.refreshView(); 368 Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion()); // fix #7030 369 } 370 }); 371 } 348 Runnable continuation = () -> { 349 if (!task.isCanceled()) { 350 SwingUtilities.invokeLater(() -> { 351 model.updateAvailablePlugins(task.getAvailablePlugins()); 352 pnlPluginPreferences.refreshView(); 353 Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion()); // fix #7030 354 }); 372 355 } 373 356 }; … … 389 372 protected void alertNothingToUpdate() { 390 373 try { 391 SwingUtilities.invokeAndWait(new Runnable() { 392 @Override 393 public void run() { 394 HelpAwareOptionPane.showOptionDialog( 395 pnlPluginPreferences, 396 tr("All installed plugins are up to date. JOSM does not have to download newer versions."), 397 tr("Plugins up to date"), 398 JOptionPane.INFORMATION_MESSAGE, 399 null // FIXME: provide help context 400 ); 401 } 402 }); 374 SwingUtilities.invokeAndWait(() -> HelpAwareOptionPane.showOptionDialog( 375 pnlPluginPreferences, 376 tr("All installed plugins are up to date. JOSM does not have to download newer versions."), 377 tr("Plugins up to date"), 378 JOptionPane.INFORMATION_MESSAGE, 379 null // FIXME: provide help context 380 )); 403 381 } catch (InterruptedException | InvocationTargetException e) { 404 382 Main.error(e); … … 421 399 // to be run asynchronously after the plugin download 422 400 // 423 final Runnable pluginDownloadContinuation = new Runnable() { 424 @Override 425 public void run() { 426 if (pluginDownloadTask.isCanceled()) 427 return; 428 boolean restartRequired = false; 429 for (PluginInformation pi : pluginDownloadTask.getDownloadedPlugins()) { 430 if (!model.getNewlyActivatedPlugins().contains(pi) || !pi.canloadatruntime) { 431 restartRequired = true; 432 break; 433 } 434 } 435 notifyDownloadResults(pnlPluginPreferences, pluginDownloadTask, restartRequired); 436 model.refreshLocalPluginVersion(pluginDownloadTask.getDownloadedPlugins()); 437 model.clearPendingPlugins(pluginDownloadTask.getDownloadedPlugins()); 438 GuiHelper.runInEDT(new Runnable() { 439 @Override 440 public void run() { 441 pnlPluginPreferences.refreshView(); 442 } 443 }); 444 } 401 final Runnable pluginDownloadContinuation = () -> { 402 if (pluginDownloadTask.isCanceled()) 403 return; 404 boolean restartRequired = false; 405 for (PluginInformation pi : pluginDownloadTask.getDownloadedPlugins()) { 406 if (!model.getNewlyActivatedPlugins().contains(pi) || !pi.canloadatruntime) { 407 restartRequired = true; 408 break; 409 } 410 } 411 notifyDownloadResults(pnlPluginPreferences, pluginDownloadTask, restartRequired); 412 model.refreshLocalPluginVersion(pluginDownloadTask.getDownloadedPlugins()); 413 model.clearPendingPlugins(pluginDownloadTask.getDownloadedPlugins()); 414 GuiHelper.runInEDT(pnlPluginPreferences::refreshView); 445 415 }; 446 416 447 417 // to be run asynchronously after the plugin list download 448 418 // 449 final Runnable pluginInfoDownloadContinuation = new Runnable() { 450 @Override 451 public void run() { 452 if (pluginInfoDownloadTask.isCanceled()) 453 return; 454 model.updateAvailablePlugins(pluginInfoDownloadTask.getAvailablePlugins()); 455 // select plugins which actually have to be updated 456 // 457 Iterator<PluginInformation> it = toUpdate.iterator(); 458 while (it.hasNext()) { 459 PluginInformation pi = it.next(); 460 if (!pi.isUpdateRequired()) { 461 it.remove(); 462 } 463 } 464 if (toUpdate.isEmpty()) { 465 alertNothingToUpdate(); 466 return; 467 } 468 pluginDownloadTask.setPluginsToDownload(toUpdate); 469 Main.worker.submit(pluginDownloadTask); 470 Main.worker.submit(pluginDownloadContinuation); 471 } 419 final Runnable pluginInfoDownloadContinuation = () -> { 420 if (pluginInfoDownloadTask.isCanceled()) 421 return; 422 model.updateAvailablePlugins(pluginInfoDownloadTask.getAvailablePlugins()); 423 // select plugins which actually have to be updated 424 // 425 Iterator<PluginInformation> it = toUpdate.iterator(); 426 while (it.hasNext()) { 427 PluginInformation pi = it.next(); 428 if (!pi.isUpdateRequired()) { 429 it.remove(); 430 } 431 } 432 if (toUpdate.isEmpty()) { 433 alertNothingToUpdate(); 434 return; 435 } 436 pluginDownloadTask.setPluginsToDownload(toUpdate); 437 Main.worker.submit(pluginDownloadTask); 438 Main.worker.submit(pluginDownloadContinuation); 472 439 }; 473 440 … … 476 443 } 477 444 } 478 479 445 480 446 /** … … 509 475 510 476 @Override 511 public void changedUpdate(DocumentEvent arg0) {477 public void changedUpdate(DocumentEvent evt) { 512 478 filter(); 513 479 } 514 480 515 481 @Override 516 public void insertUpdate(DocumentEvent arg0) {482 public void insertUpdate(DocumentEvent evt) { 517 483 filter(); 518 484 } 519 485 520 486 @Override 521 public void removeUpdate(DocumentEvent arg0) {487 public void removeUpdate(DocumentEvent evt) { 522 488 filter(); 523 489 } -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java
r10210 r10611 6 6 import java.util.Collection; 7 7 import java.util.Collections; 8 import java.util.Comparator;9 8 import java.util.HashMap; 10 9 import java.util.HashSet; … … 150 149 Collections.sort( 151 150 availablePlugins, 152 new Comparator<PluginInformation>() { 153 @Override 154 public int compare(PluginInformation o1, PluginInformation o2) { 155 String n1 = o1.getName() == null ? "" : o1.getName().toLowerCase(Locale.ENGLISH); 156 String n2 = o2.getName() == null ? "" : o2.getName().toLowerCase(Locale.ENGLISH); 157 return n1.compareTo(n2); 158 } 151 (o1, o2) -> { 152 String n1 = o1.getName() == null ? "" : o1.getName().toLowerCase(Locale.ENGLISH); 153 String n2 = o2.getName() == null ? "" : o2.getName().toLowerCase(Locale.ENGLISH); 154 return n1.compareTo(n2); 159 155 } 160 156 ); -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/CustomProjectionChoice.java
r10242 r10611 7 7 import java.awt.GridBagLayout; 8 8 import java.awt.Insets; 9 import java.awt.event.ActionEvent;10 9 import java.awt.event.ActionListener; 11 10 import java.util.Arrays; … … 113 112 114 113 JButton btnCheck = new JButton(tr("Validate")); 115 btnCheck.addActionListener(new ActionListener() { 116 @Override 117 public void actionPerformed(ActionEvent e) { 118 val.validate(); 119 } 120 }); 114 btnCheck.addActionListener(e -> val.validate()); 121 115 btnCheck.setLayout(new BorderLayout()); 122 116 btnCheck.setMargin(new Insets(-1, 0, -1, 0)); 123 117 124 118 JButton btnInfo = new JButton(tr("Parameter information...")); 125 btnInfo.addActionListener(new ActionListener() { 126 @Override 127 public void actionPerformed(ActionEvent e) { 128 CustomProjectionChoice.ParameterInfoDialog dlg = new CustomProjectionChoice.ParameterInfoDialog(); 129 dlg.showDialog(); 130 dlg.toFront(); 131 } 119 btnInfo.addActionListener(e -> { 120 CustomProjectionChoice.ParameterInfoDialog dlg = new CustomProjectionChoice.ParameterInfoDialog(); 121 dlg.showDialog(); 122 dlg.toFront(); 132 123 }); 133 124 -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java
r10310 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.ArrayList; … … 449 448 return; 450 449 451 final ActionListener listener = new ActionListener() { 452 @Override 453 public void actionPerformed(ActionEvent e) { 454 updateMeta(pc); 455 } 456 }; 450 final ActionListener listener = e -> updateMeta(pc); 457 451 458 452 // Replace old panel with new one … … 485 479 throw new RuntimeException("Couldn't find the current projection in the list of available projections!"); 486 480 487 projectionCombo.addActionListener(new ActionListener() { 488 @Override 489 public void actionPerformed(ActionEvent e) { 490 ProjectionChoice pc = (ProjectionChoice) projectionCombo.getSelectedItem(); 491 selectedProjectionChanged(pc); 492 } 481 projectionCombo.addActionListener(e -> { 482 ProjectionChoice pc1 = (ProjectionChoice) projectionCombo.getSelectedItem(); 483 selectedProjectionChanged(pc1); 493 484 }); 494 485 return pc; -
trunk/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java
r9778 r10611 7 7 import java.awt.Font; 8 8 import java.awt.GridBagLayout; 9 import java.awt.event.ActionEvent;10 9 import java.awt.event.ActionListener; 11 10 import java.io.IOException; … … 120 119 wrapper.add(installCertificate, GBC.std().insets(5, 5, 0, 0)); 121 120 wrapper.add(uninstallCertificate, GBC.eol().insets(5, 5, 0, 0)); 122 enableHttpsSupport.addActionListener(new ActionListener() { 123 @Override 124 public void actionPerformed(ActionEvent e) { 125 installCertificate.setEnabled(enableHttpsSupport.isSelected()); 121 enableHttpsSupport.addActionListener(e -> installCertificate.setEnabled(enableHttpsSupport.isSelected())); 122 installCertificate.addActionListener(e -> { 123 try { 124 boolean changed = RemoteControlHttpsServer.setupPlatform( 125 RemoteControlHttpsServer.loadJosmKeystore()); 126 String msg = changed ? 127 tr("Certificate has been successfully installed.") : 128 tr("Certificate is already installed. Nothing to do."); 129 Main.info(msg); 130 JOptionPane.showMessageDialog(wrapper, msg); 131 } catch (IOException | GeneralSecurityException ex) { 132 Main.error(ex); 126 133 } 127 134 }); 128 installCertificate.addActionListener(new ActionListener() { 129 @Override 130 public void actionPerformed(ActionEvent e) { 131 try { 132 boolean changed = RemoteControlHttpsServer.setupPlatform( 133 RemoteControlHttpsServer.loadJosmKeystore()); 134 String msg = changed ? 135 tr("Certificate has been successfully installed.") : 136 tr("Certificate is already installed. Nothing to do."); 137 Main.info(msg); 138 JOptionPane.showMessageDialog(wrapper, msg); 139 } catch (IOException | GeneralSecurityException ex) { 140 Main.error(ex); 135 uninstallCertificate.addActionListener(e -> { 136 try { 137 String msg; 138 KeyStore ks = PlatformHookWindows.getRootKeystore(); 139 if (ks.containsAlias(RemoteControlHttpsServer.ENTRY_ALIAS)) { 140 Main.info(tr("Removing certificate {0} from root keystore.", RemoteControlHttpsServer.ENTRY_ALIAS)); 141 ks.deleteEntry(RemoteControlHttpsServer.ENTRY_ALIAS); 142 msg = tr("Certificate has been successfully uninstalled."); 143 } else { 144 msg = tr("Certificate is not installed. Nothing to do."); 141 145 } 142 } 143 }); 144 uninstallCertificate.addActionListener(new ActionListener() { 145 @Override 146 public void actionPerformed(ActionEvent e) { 147 try { 148 String msg; 149 KeyStore ks = PlatformHookWindows.getRootKeystore(); 150 if (ks.containsAlias(RemoteControlHttpsServer.ENTRY_ALIAS)) { 151 Main.info(tr("Removing certificate {0} from root keystore.", RemoteControlHttpsServer.ENTRY_ALIAS)); 152 ks.deleteEntry(RemoteControlHttpsServer.ENTRY_ALIAS); 153 msg = tr("Certificate has been successfully uninstalled."); 154 } else { 155 msg = tr("Certificate is not installed. Nothing to do."); 156 } 157 Main.info(msg); 158 JOptionPane.showMessageDialog(wrapper, msg); 159 } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException ex) { 160 Main.error(ex); 161 } 146 Main.info(msg); 147 JOptionPane.showMessageDialog(wrapper, msg); 148 } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException ex) { 149 Main.error(ex); 162 150 } 163 151 }); … … 181 169 alwaysAskUserConfirm.setSelected(Main.pref.getBoolean(RequestHandler.globalConfirmationKey, RequestHandler.globalConfirmationDefault)); 182 170 183 ActionListener remoteControlEnabled = new ActionListener() { 184 185 @Override 186 public void actionPerformed(ActionEvent e) { 187 GuiHelper.setEnabledRec(wrapper, enableRemoteControl.isSelected()); 188 // 'setEnabled(false)' does not work for JLabel with html text, so do it manually 189 // FIXME: use QuadStateCheckBox to make checkboxes unset when disabled 190 if (installCertificate != null && uninstallCertificate != null) { 191 // Install certificate button is enabled if HTTPS is also enabled 192 installCertificate.setEnabled(enableRemoteControl.isSelected() && enableHttpsSupport.isSelected()); 193 // Uninstall certificate button is always enabled 194 uninstallCertificate.setEnabled(true); 195 } 171 ActionListener remoteControlEnabled = e -> { 172 GuiHelper.setEnabledRec(wrapper, enableRemoteControl.isSelected()); 173 // 'setEnabled(false)' does not work for JLabel with html text, so do it manually 174 // FIXME: use QuadStateCheckBox to make checkboxes unset when disabled 175 if (installCertificate != null && uninstallCertificate != null) { 176 // Install certificate button is enabled if HTTPS is also enabled 177 installCertificate.setEnabled(enableRemoteControl.isSelected() && enableHttpsSupport.isSelected()); 178 // Uninstall certificate button is always enabled 179 uninstallCertificate.setEnabled(true); 196 180 } 197 181 }; -
trunk/src/org/openstreetmap/josm/gui/preferences/server/FeaturesPanel.java
r9073 r10611 10 10 import javax.swing.JLabel; 11 11 import javax.swing.JPanel; 12 import javax.swing.event.ChangeEvent;13 import javax.swing.event.ChangeListener;14 12 15 13 import org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask; … … 44 42 notifier = new JCheckBox(tr("Periodically check for new messages")); 45 43 add(notifier, GBC.eol()); 46 notifier.addChangeListener(new ChangeListener() { 47 @Override 48 public void stateChanged(ChangeEvent e) { 49 updateEnabledState(); 50 } 51 }); 44 notifier.addChangeListener(e -> updateEnabledState()); 52 45 53 46 intervalLabel = new JLabel(tr("Check interval (minutes):")); -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
r10424 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.beans.PropertyChangeEvent; 17 16 import java.beans.PropertyChangeListener; … … 78 77 cbShowAdvancedParameters.setSelected(false); 79 78 cbShowAdvancedParameters.addItemListener( 80 new ItemListener() { 81 @Override 82 public void itemStateChanged(ItemEvent evt) { 83 pnlAdvancedProperties.setVisible(evt.getStateChange() == ItemEvent.SELECTED); 84 } 85 } 79 evt -> pnlAdvancedProperties.setVisible(evt.getStateChange() == ItemEvent.SELECTED) 86 80 ); 87 81 -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java
r10424 r10611 186 186 final ApiUrlTestTask task = new ApiUrlTestTask(OsmApiUrlInputPanel.this, url); 187 187 Main.worker.submit(task); 188 Runnable r = new Runnable() { 189 @Override 190 public void run() { 191 if (task.isCanceled()) 192 return; 193 Runnable r = new Runnable() { 194 @Override 195 public void run() { 196 if (task.isSuccess()) { 197 lblValid.setIcon(ImageProvider.get("dialogs", "valid")); 198 lblValid.setToolTipText(tr("The API URL is valid.")); 199 lastTestedUrl = url; 200 updateEnabledState(); 201 } else { 202 lblValid.setIcon(ImageProvider.get("warning-small")); 203 lblValid.setToolTipText(tr("Validation failed. The API URL seems to be invalid.")); 204 } 205 } 206 }; 207 SwingUtilities.invokeLater(r); 208 } 188 Runnable r = () -> { 189 if (task.isCanceled()) 190 return; 191 Runnable r1 = () -> { 192 if (task.isSuccess()) { 193 lblValid.setIcon(ImageProvider.get("dialogs", "valid")); 194 lblValid.setToolTipText(tr("The API URL is valid.")); 195 lastTestedUrl = url; 196 updateEnabledState(); 197 } else { 198 lblValid.setIcon(ImageProvider.get("warning-small")); 199 lblValid.setToolTipText(tr("Validation failed. The API URL seems to be invalid.")); 200 } 201 }; 202 SwingUtilities.invokeLater(r1); 209 203 }; 210 204 Main.worker.submit(r); -
trunk/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreference.java
r9778 r10611 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.event.ActionEvent;8 7 import java.awt.event.ActionListener; 9 8 import java.util.ArrayList; … … 76 75 testPanel.add(prefOtherUpload, GBC.eol()); 77 76 78 ActionListener otherUploadEnabled = new ActionListener() { 79 @Override 80 public void actionPerformed(ActionEvent e) { 81 prefOtherUpload.setEnabled(prefOther.isSelected()); 82 } 83 }; 77 ActionListener otherUploadEnabled = e -> prefOtherUpload.setEnabled(prefOther.isSelected()); 84 78 prefOther.addActionListener(otherUploadEnabled); 85 79 otherUploadEnabled.actionPerformed(null); -
trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java
r10035 r10611 4 4 import java.awt.Component; 5 5 import java.awt.GraphicsEnvironment; 6 import java.awt.event.ActionEvent;7 6 import java.awt.event.ActionListener; 8 7 import java.awt.event.WindowAdapter; … … 139 138 } 140 139 141 private final ActionListener cancelListener = new ActionListener() { 142 @Override 143 public void actionPerformed(ActionEvent e) { 144 cancel(); 145 } 146 }; 147 148 private final ActionListener inBackgroundListener = new ActionListener() { 149 @Override 150 public void actionPerformed(ActionEvent e) { 151 isInBackground = true; 152 ProgressMonitorDialog dialog = getDialog(); 153 if (dialog != null) { 154 reset(); 155 dialog.setVisible(true); 156 } 140 private final ActionListener cancelListener = e -> cancel(); 141 142 private final ActionListener inBackgroundListener = e -> { 143 isInBackground = true; 144 ProgressMonitorDialog dlg = getDialog(); 145 if (dlg != null) { 146 reset(); 147 dlg.setVisible(true); 157 148 } 158 149 }; … … 174 165 @Override 175 166 public void doBeginTask() { 176 doInEDT(new Runnable() { 177 @Override 178 public void run() { 179 Main.currentProgressMonitor = PleaseWaitProgressMonitor.this; 180 if (GraphicsEnvironment.isHeadless()) { 181 return; 182 } 183 if (dialogParent != null && dialog == null) { 184 dialog = new PleaseWaitDialog(dialogParent); 185 } else 186 throw new ProgressException("PleaseWaitDialog parent must be set"); 187 188 if (windowTitle != null) { 189 dialog.setTitle(windowTitle); 190 } 191 dialog.setCancelEnabled(cancelable); 192 dialog.setCancelCallback(cancelListener); 193 dialog.setInBackgroundCallback(inBackgroundListener); 194 dialog.setCustomText(""); 195 dialog.addWindowListener(windowListener); 196 dialog.progress.setMaximum(PROGRESS_BAR_MAX); 197 dialog.setVisible(true); 198 } 167 doInEDT(() -> { 168 Main.currentProgressMonitor = PleaseWaitProgressMonitor.this; 169 if (GraphicsEnvironment.isHeadless()) { 170 return; 171 } 172 if (dialogParent != null && dialog == null) { 173 dialog = new PleaseWaitDialog(dialogParent); 174 } else 175 throw new ProgressException("PleaseWaitDialog parent must be set"); 176 177 if (windowTitle != null) { 178 dialog.setTitle(windowTitle); 179 } 180 dialog.setCancelEnabled(cancelable); 181 dialog.setCancelCallback(cancelListener); 182 dialog.setInBackgroundCallback(inBackgroundListener); 183 dialog.setCustomText(""); 184 dialog.addWindowListener(windowListener); 185 dialog.progress.setMaximum(PROGRESS_BAR_MAX); 186 dialog.setVisible(true); 199 187 }); 200 188 } … … 210 198 if (newValue != currentProgressValue) { 211 199 currentProgressValue = newValue; 212 doInEDT(new Runnable() { 213 @Override 214 public void run() { 215 ProgressMonitorDialog dialog = getDialog(); 216 if (dialog != null) { 217 dialog.updateProgress(currentProgressValue); 218 } 200 doInEDT(() -> { 201 ProgressMonitorDialog dlg = getDialog(); 202 if (dlg != null) { 203 dlg.updateProgress(currentProgressValue); 219 204 } 220 205 }); … … 226 211 checkState(State.IN_TASK, State.IN_SUBTASK); 227 212 this.customText = title; 228 doInEDT(new Runnable() { 229 @Override 230 public void run() { 231 ProgressMonitorDialog dialog = getDialog(); 232 if (dialog != null) { 233 dialog.setCustomText(title); 234 } 213 doInEDT(() -> { 214 ProgressMonitorDialog dlg = getDialog(); 215 if (dlg != null) { 216 dlg.setCustomText(title); 235 217 } 236 218 }); … … 241 223 checkState(State.IN_TASK, State.IN_SUBTASK); 242 224 this.title = title; 243 doInEDT(new Runnable() { 244 @Override 245 public void run() { 246 ProgressMonitorDialog dialog = getDialog(); 247 if (dialog != null) { 248 dialog.setCurrentAction(title); 249 } 225 doInEDT(() -> { 226 ProgressMonitorDialog dlg = getDialog(); 227 if (dlg != null) { 228 dlg.setCurrentAction(title); 250 229 } 251 230 }); … … 255 234 protected void doSetIntermediate(final boolean value) { 256 235 this.indeterminate = value; 257 doInEDT(new Runnable() { 258 @Override 259 public void run() { 260 // Enable only if progress is at the beginning. Doing intermediate progress in the middle 261 // will hide already reached progress 262 ProgressMonitorDialog dialog = getDialog(); 263 if (dialog != null) { 264 dialog.setIndeterminate(value && currentProgressValue == 0); 265 } 236 doInEDT(() -> { 237 // Enable only if progress is at the beginning. Doing intermediate progress in the middle 238 // will hide already reached progress 239 ProgressMonitorDialog dlg = getDialog(); 240 if (dlg != null) { 241 dlg.setIndeterminate(value && currentProgressValue == 0); 266 242 } 267 243 }); … … 270 246 @Override 271 247 public void appendLogMessage(final String message) { 272 doInEDT(new Runnable() { 273 @Override 274 public void run() { 275 ProgressMonitorDialog dialog = getDialog(); 276 if (dialog != null) { 277 dialog.appendLogMessage(message); 278 } 248 doInEDT(() -> { 249 ProgressMonitorDialog dlg = getDialog(); 250 if (dlg != null) { 251 dlg.appendLogMessage(message); 279 252 } 280 253 }); … … 299 272 backgroundMonitor.setIndeterminate(indeterminate && currentProgressValue == 0); 300 273 } 301 302 274 } 303 275 304 276 public void close() { 305 doInEDT(new Runnable() { 306 @Override 307 public void run() { 308 if (dialog != null) { 309 dialog.setVisible(false); 310 dialog.setCancelCallback(null); 311 dialog.setInBackgroundCallback(null); 312 dialog.removeWindowListener(windowListener); 313 dialog.dispose(); 314 dialog = null; 315 Main.currentProgressMonitor = null; 316 MapFrame map = Main.map; 317 if (map != null) { 318 map.statusLine.progressMonitor.setVisible(false); 319 } 277 doInEDT(() -> { 278 if (dialog != null) { 279 dialog.setVisible(false); 280 dialog.setCancelCallback(null); 281 dialog.setInBackgroundCallback(null); 282 dialog.removeWindowListener(windowListener); 283 dialog.dispose(); 284 dialog = null; 285 Main.currentProgressMonitor = null; 286 MapFrame map = Main.map; 287 if (map != null) { 288 map.statusLine.progressMonitor.setVisible(false); 320 289 } 321 290 } … … 325 294 public void showForegroundDialog() { 326 295 isInBackground = false; 327 doInEDT(new Runnable() { 328 @Override 329 public void run() { 330 if (dialog != null) { 331 dialog.setInBackgroundPossible(PleaseWaitProgressMonitor.this.taskId != null && Main.isDisplayingMapView()); 332 reset(); 333 getDialog(); 334 } 335 } 336 }); 337 296 doInEDT(() -> { 297 if (dialog != null) { 298 dialog.setInBackgroundPossible(PleaseWaitProgressMonitor.this.taskId != null && Main.isDisplayingMapView()); 299 reset(); 300 getDialog(); 301 } 302 }); 338 303 } 339 304 … … 341 306 public void setProgressTaskId(ProgressTaskId taskId) { 342 307 this.taskId = taskId; 343 doInEDT(new Runnable() { 344 @Override 345 public void run() { 346 if (dialog != null) { 347 dialog.setInBackgroundPossible(PleaseWaitProgressMonitor.this.taskId != null && Main.isDisplayingMapView()); 348 } 308 doInEDT(() -> { 309 if (dialog != null) { 310 dialog.setInBackgroundPossible(PleaseWaitProgressMonitor.this.taskId != null && Main.isDisplayingMapView()); 349 311 } 350 312 }); -
trunk/src/org/openstreetmap/josm/gui/progress/SwingRenderingProgressMonitor.java
r10173 r10611 32 32 @Override 33 33 public void doBeginTask() { 34 GuiHelper.runInEDT(new Runnable() { 35 @Override 36 public void run() { 37 delegate.setCustomText(""); 38 delegate.setMaximum(PROGRESS_BAR_MAX); 39 } 34 GuiHelper.runInEDT(() -> { 35 delegate.setCustomText(""); 36 delegate.setMaximum(PROGRESS_BAR_MAX); 40 37 }); 41 38 } … … 51 48 if (newValue != currentProgressValue) { 52 49 currentProgressValue = newValue; 53 GuiHelper.runInEDT(new Runnable() { 54 @Override 55 public void run() { 56 delegate.setValue(currentProgressValue); 57 } 58 }); 50 GuiHelper.runInEDT(() -> delegate.setValue(currentProgressValue)); 59 51 } 60 52 } … … 63 55 protected void doSetCustomText(final String title) { 64 56 checkState(State.IN_TASK, State.IN_SUBTASK); 65 GuiHelper.runInEDT(new Runnable() { 66 @Override 67 public void run() { 68 delegate.setCustomText(title); 69 } 70 }); 57 GuiHelper.runInEDT(() -> delegate.setCustomText(title)); 71 58 } 72 59 … … 74 61 protected void doSetTitle(final String title) { 75 62 checkState(State.IN_TASK, State.IN_SUBTASK); 76 GuiHelper.runInEDT(new Runnable() { 77 @Override 78 public void run() { 79 delegate.setTaskTitle(title); 80 } 81 }); 63 GuiHelper.runInEDT(() -> delegate.setTaskTitle(title)); 82 64 } 83 65 84 66 @Override 85 67 protected void doSetIntermediate(final boolean value) { 86 GuiHelper.runInEDT(new Runnable() { 87 @Override 88 public void run() { 89 delegate.setIndeterminate(value); 90 } 91 }); 68 GuiHelper.runInEDT(() -> delegate.setIndeterminate(value)); 92 69 } 93 70 -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
r10604 r10611 9 9 import java.util.Collection; 10 10 import java.util.Collections; 11 import java.util.Comparator;12 11 import java.util.EnumSet; 13 12 import java.util.HashMap; … … 563 562 */ 564 563 protected void sort() { 565 Collections.sort( 566 tags, 567 new Comparator<TagModel>() { 568 @Override 569 public int compare(TagModel self, TagModel other) { 570 return self.getName().compareTo(other.getName()); 571 } 572 } 573 ); 564 Collections.sort(tags, (self, other) -> self.getName().compareTo(other.getName())); 574 565 } 575 566 -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java
r10179 r10611 15 15 import javax.swing.JPanel; 16 16 import javax.swing.JScrollPane; 17 import javax.swing.event.TableModelEvent;18 import javax.swing.event.TableModelListener;19 17 20 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 125 123 126 124 if (presetHandler != null) { 127 model.addTableModelListener(new TableModelListener() { 128 @Override 129 public void tableChanged(TableModelEvent e) { 130 updatePresets(); 131 } 132 }); 125 model.addTableModelListener(e -> updatePresets()); 133 126 } 134 127 -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java
r9371 r10611 38 38 import org.openstreetmap.josm.tools.MultiMap; 39 39 import org.openstreetmap.josm.tools.Utils; 40 import org.openstreetmap.josm.tools.Utils.Function; 40 41 41 42 /** … … 336 337 for (TaggingPreset tp : presets) { 337 338 if (tp.roles != null) { 338 list.add(Utils.transform(tp.roles.roles, new Utils.Function<Role, String>() { 339 public String apply(Role x) { 340 return x.key; 341 } 342 }), AutoCompletionItemPriority.IS_IN_STANDARD); 339 list.add(Utils.transform(tp.roles.roles, (Function<Role, String>) x -> x.key), AutoCompletionItemPriority.IS_IN_STANDARD); 343 340 } 344 341 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r10591 r10611 59 59 import org.openstreetmap.josm.tools.GBC; 60 60 import org.openstreetmap.josm.tools.ImageProvider; 61 import org.openstreetmap.josm.tools.Image Resource;61 import org.openstreetmap.josm.tools.ImageProvider.ImageResourceCallback; 62 62 import org.openstreetmap.josm.tools.Predicate; 63 63 import org.openstreetmap.josm.tools.Utils; … … 204 204 imgProv.setArchive(arch); 205 205 imgProv.setOptional(true); 206 imgProv.getInBackground(new ImageProvider.ImageResourceCallback() { 207 @Override 208 public void finished(final ImageResource result) { 209 if (result != null) { 210 GuiHelper.runInEDT(() -> result.attachImageIcon(TaggingPreset.this)); 211 } else { 212 Main.warn(TaggingPreset.this + ": " + PRESET_ICON_ERROR_MSG_PREFIX + iconName); 213 } 206 imgProv.getInBackground((ImageResourceCallback) result -> { 207 if (result != null) { 208 GuiHelper.runInEDT(() -> result.attachImageIcon(TaggingPreset.this)); 209 } else { 210 Main.warn(TaggingPreset.this + ": " + PRESET_ICON_ERROR_MSG_PREFIX + iconName); 214 211 } 215 212 }); -
trunk/src/org/openstreetmap/josm/gui/util/AdjustmentSynchronizer.java
r10378 r10611 8 8 import java.awt.event.AdjustmentListener; 9 9 import java.awt.event.ItemEvent; 10 import java.awt.event.ItemListener;11 10 import java.util.HashMap; 12 11 import java.util.HashSet; … … 15 14 16 15 import javax.swing.JCheckBox; 17 import javax.swing.event.ChangeEvent;18 import javax.swing.event.ChangeListener;19 16 20 17 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 125 122 // register an item lister with the check box 126 123 // 127 view.addItemListener(new ItemListener() { 128 @Override 129 public void itemStateChanged(ItemEvent e) { 130 switch(e.getStateChange()) { 131 case ItemEvent.SELECTED: 132 if (!isParticipatingInSynchronizedScrolling(adjustable)) { 133 setParticipatingInSynchronizedScrolling(adjustable, true); 134 } 135 break; 136 case ItemEvent.DESELECTED: 137 if (isParticipatingInSynchronizedScrolling(adjustable)) { 138 setParticipatingInSynchronizedScrolling(adjustable, false); 139 } 140 break; 141 default: // Do nothing 124 view.addItemListener(e -> { 125 switch(e.getStateChange()) { 126 case ItemEvent.SELECTED: 127 if (!isParticipatingInSynchronizedScrolling(adjustable)) { 128 setParticipatingInSynchronizedScrolling(adjustable, true); 142 129 } 130 break; 131 case ItemEvent.DESELECTED: 132 if (isParticipatingInSynchronizedScrolling(adjustable)) { 133 setParticipatingInSynchronizedScrolling(adjustable, false); 134 } 135 break; 136 default: // Do nothing 143 137 } 144 138 }); 145 139 146 observable.addChangeListener( 147 new ChangeListener() { 148 @Override 149 public void stateChanged(ChangeEvent e) { 150 boolean sync = isParticipatingInSynchronizedScrolling(adjustable); 151 if (view.isSelected() != sync) { 152 view.setSelected(sync); 153 } 154 } 155 } 156 ); 140 observable.addChangeListener(e -> { 141 boolean sync = isParticipatingInSynchronizedScrolling(adjustable); 142 if (view.isSelected() != sync) { 143 view.setSelected(sync); 144 } 145 }); 157 146 setParticipatingInSynchronizedScrolling(adjustable, true); 158 147 view.setSelected(true); -
trunk/src/org/openstreetmap/josm/gui/util/AdvancedKeyPressDetector.java
r9085 r10611 9 9 import java.awt.Toolkit; 10 10 import java.awt.event.AWTEventListener; 11 import java.awt.event.ActionEvent;12 import java.awt.event.ActionListener;13 11 import java.awt.event.KeyEvent; 14 12 import java.util.List; … … 83 81 Main.warn(ex); 84 82 } 85 timer = new Timer(0, new ActionListener() { 86 @Override 87 public void actionPerformed(ActionEvent e) { 88 timer.stop(); 89 if (set.remove(releaseEvent.getKeyCode()) && enabled) { 90 if (isFocusInMainWindow()) { 91 for (KeyPressReleaseListener q: keyListeners) { 92 q.doKeyReleased(releaseEvent); 93 } 94 } 83 timer = new Timer(0, e -> { 84 timer.stop(); 85 if (set.remove(releaseEvent.getKeyCode()) && enabled && isFocusInMainWindow()) { 86 for (KeyPressReleaseListener q: keyListeners) { 87 q.doKeyReleased(releaseEvent); 95 88 } 96 89 } -
trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
r10604 r10611 22 22 import java.awt.Window; 23 23 import java.awt.event.ActionListener; 24 import java.awt.event.HierarchyEvent;25 import java.awt.event.HierarchyListener;26 24 import java.awt.event.KeyEvent; 27 25 import java.awt.event.MouseAdapter; … … 91 89 92 90 public static void executeByMainWorkerInEDT(final Runnable task) { 93 Main.worker.submit(new Runnable() { 94 @Override 95 public void run() { 96 runInEDTAndWait(task); 97 } 98 }); 91 Main.worker.submit(() -> runInEDTAndWait(task)); 99 92 } 100 93 … … 272 265 public static Component prepareResizeableOptionPane(final Component pane, final Dimension minDimension) { 273 266 if (pane != null) { 274 pane.addHierarchyListener(new HierarchyListener() { 275 @Override 276 public void hierarchyChanged(HierarchyEvent e) { 277 Window window = SwingUtilities.getWindowAncestor(pane); 278 if (window instanceof Dialog) { 279 Dialog dialog = (Dialog) window; 280 if (!dialog.isResizable()) { 281 dialog.setResizable(true); 282 if (minDimension != null) { 283 dialog.setMinimumSize(minDimension); 284 } 267 pane.addHierarchyListener(e -> { 268 Window window = SwingUtilities.getWindowAncestor(pane); 269 if (window instanceof Dialog) { 270 Dialog dialog = (Dialog) window; 271 if (!dialog.isResizable()) { 272 dialog.setResizable(true); 273 if (minDimension != null) { 274 dialog.setMinimumSize(minDimension); 285 275 } 286 276 } -
trunk/src/org/openstreetmap/josm/gui/util/StayOpenCheckBoxMenuItem.java
r9249 r10611 6 6 import javax.swing.MenuElement; 7 7 import javax.swing.MenuSelectionManager; 8 import javax.swing.event.ChangeEvent;9 import javax.swing.event.ChangeListener;10 8 11 9 /** … … 19 17 20 18 { 21 getModel().addChangeListener(new ChangeListener() { 22 23 @Override 24 public void stateChanged(ChangeEvent e) { 19 getModel().addChangeListener(e -> { 25 20 if (getModel().isArmed() && isShowing()) { 26 21 path = MenuSelectionManager.defaultManager().getSelectedPath(); 27 22 } 28 } 29 }); 23 }); 30 24 } 31 25 -
trunk/src/org/openstreetmap/josm/gui/widgets/DateEditorWithSlider.java
r9078 r10611 16 16 import javax.swing.JSpinner; 17 17 import javax.swing.SpinnerDateModel; 18 import javax.swing.event.ChangeEvent;19 18 import javax.swing.event.ChangeListener; 20 19 … … 52 51 53 52 slider = new JSlider(0, MAX_SLIDER); 54 spinner.addChangeListener(new ChangeListener() { 55 @Override 56 public void stateChanged(ChangeEvent e) { 57 int i = slider.getValue(); 58 Date d = (Date) spinner.getValue(); 59 int j = intFromDate(d); 60 if (i != j) { 61 watchSlider = false; 62 slider.setValue(j); 63 watchSlider = true; 64 } 65 for (ChangeListener l : listeners) { 66 l.stateChanged(e); 67 } 53 spinner.addChangeListener(e -> { 54 int i = slider.getValue(); 55 Date d = (Date) spinner.getValue(); 56 int j = intFromDate(d); 57 if (i != j) { 58 watchSlider = false; 59 slider.setValue(j); 60 watchSlider = true; 61 } 62 for (ChangeListener l : listeners) { 63 l.stateChanged(e); 68 64 } 69 65 }); 70 slider.addChangeListener(new ChangeListener() { 71 @Override 72 public void stateChanged(ChangeEvent e) { 73 if (!watchSlider) return; 74 Date d = (Date) spinner.getValue(); 75 Date d1 = dateFromInt(slider.getValue()); 76 if (!d.equals(d1)) { 77 spinner.setValue(d1); 78 } 66 slider.addChangeListener(e -> { 67 if (!watchSlider) return; 68 Date d = (Date) spinner.getValue(); 69 Date d1 = dateFromInt(slider.getValue()); 70 if (!d.equals(d1)) { 71 spinner.setValue(d1); 79 72 } 80 73 }); -
trunk/src/org/openstreetmap/josm/gui/widgets/EditableList.java
r8509 r10611 7 7 import java.awt.Dimension; 8 8 import java.awt.GridBagLayout; 9 import java.awt.event.ActionEvent;10 import java.awt.event.ActionListener;11 9 import java.util.ArrayList; 12 10 import java.util.List; … … 46 44 setLayout(new BorderLayout()); 47 45 48 addSrcButton.addActionListener(new ActionListener() { 49 @Override 50 public void actionPerformed(ActionEvent e) { 51 String source = JOptionPane.showInputDialog( 52 Main.parent, 46 addSrcButton.addActionListener(e -> { 47 String source = JOptionPane.showInputDialog( 48 Main.parent, 49 title, 50 title, 51 JOptionPane.QUESTION_MESSAGE); 52 if (source != null) { 53 ((DefaultListModel<String>) sourcesList.getModel()).addElement(source); 54 } 55 sourcesList.clearSelection(); 56 }); 57 58 editSrcButton.addActionListener(e -> { 59 int row = sourcesList.getSelectedIndex(); 60 if (row == -1 && sourcesList.getModel().getSize() == 1) { 61 sourcesList.setSelectedIndex(0); 62 row = 0; 63 } 64 if (row == -1) { 65 if (sourcesList.getModel().getSize() == 0) { 66 String source1 = JOptionPane.showInputDialog(Main.parent, title, title, JOptionPane.QUESTION_MESSAGE); 67 if (source1 != null) { 68 ((DefaultListModel<String>) sourcesList.getModel()).addElement(source1); 69 } 70 } else { 71 JOptionPane.showMessageDialog( 72 Main.parent, 73 tr("Please select the row to edit."), 74 tr("Information"), 75 JOptionPane.INFORMATION_MESSAGE 76 ); 77 } 78 } else { 79 String source2 = (String) JOptionPane.showInputDialog(Main.parent, 53 80 title, 54 81 title, 55 JOptionPane.QUESTION_MESSAGE); 56 if (source != null) { 57 ((DefaultListModel<String>) sourcesList.getModel()).addElement(source); 82 JOptionPane.QUESTION_MESSAGE, null, null, 83 sourcesList.getSelectedValue()); 84 if (source2 != null) { 85 ((DefaultListModel<String>) sourcesList.getModel()).setElementAt(source2, row); 58 86 } 59 sourcesList.clearSelection();60 87 } 88 sourcesList.clearSelection(); 61 89 }); 62 90 63 editSrcButton.addActionListener(new ActionListener() { 64 @Override 65 public void actionPerformed(ActionEvent e) { 66 int row = sourcesList.getSelectedIndex(); 67 if (row == -1 && sourcesList.getModel().getSize() == 1) { 68 sourcesList.setSelectedIndex(0); 69 row = 0; 70 } 71 if (row == -1) { 72 if (sourcesList.getModel().getSize() == 0) { 73 String source = JOptionPane.showInputDialog(Main.parent, title, title, JOptionPane.QUESTION_MESSAGE); 74 if (source != null) { 75 ((DefaultListModel<String>) sourcesList.getModel()).addElement(source); 76 } 77 } else { 78 JOptionPane.showMessageDialog( 79 Main.parent, 80 tr("Please select the row to edit."), 81 tr("Information"), 82 JOptionPane.INFORMATION_MESSAGE 83 ); 84 } 85 } else { 86 String source = (String) JOptionPane.showInputDialog(Main.parent, 87 title, 88 title, 89 JOptionPane.QUESTION_MESSAGE, null, null, 90 sourcesList.getSelectedValue()); 91 if (source != null) { 92 ((DefaultListModel<String>) sourcesList.getModel()).setElementAt(source, row); 93 } 94 } 95 sourcesList.clearSelection(); 96 } 97 }); 98 99 deleteSrcButton.addActionListener(new ActionListener() { 100 @Override 101 public void actionPerformed(ActionEvent e) { 102 if (sourcesList.getSelectedIndex() == -1) { 103 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete."), tr("Information"), 104 JOptionPane.QUESTION_MESSAGE); 105 } else { 106 ((DefaultListModel<String>) sourcesList.getModel()).remove(sourcesList.getSelectedIndex()); 107 } 91 deleteSrcButton.addActionListener(e -> { 92 if (sourcesList.getSelectedIndex() == -1) { 93 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete."), tr("Information"), 94 JOptionPane.QUESTION_MESSAGE); 95 } else { 96 ((DefaultListModel<String>) sourcesList.getModel()).remove(sourcesList.getSelectedIndex()); 108 97 } 109 98 }); -
trunk/src/org/openstreetmap/josm/gui/widgets/NativeFileChooser.java
r10001 r10611 98 98 @Override 99 99 public void setFileFilter(final FileFilter cff) { 100 FilenameFilter filter = new FilenameFilter() { 101 @Override 102 public boolean accept(File directory, String fileName) { 103 return cff.accept(new File(directory.getAbsolutePath() + fileName)); 104 } 105 }; 100 FilenameFilter filter = (directory, fileName) -> cff.accept(new File(directory.getAbsolutePath() + fileName)); 106 101 fileDialog.setFilenameFilter(filter); 107 102 fileFilter = cff; -
trunk/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java
r10428 r10611 8 8 import java.awt.event.ActionEvent; 9 9 import java.awt.event.KeyEvent; 10 import java.beans.PropertyChangeEvent;11 10 import java.beans.PropertyChangeListener; 12 11 … … 17 16 import javax.swing.JPopupMenu; 18 17 import javax.swing.KeyStroke; 19 import javax.swing.event.UndoableEditEvent;20 18 import javax.swing.event.UndoableEditListener; 21 19 import javax.swing.text.DefaultEditorKit; … … 51 49 protected final UndoManager undo = new UndoManager(); 52 50 53 protected final transient UndoableEditListener undoEditListener = new UndoableEditListener() { 54 @Override 55 public void undoableEditHappened(UndoableEditEvent e) { 56 undo.addEdit(e.getEdit()); 57 undoAction.updateUndoState(); 58 redoAction.updateRedoState(); 59 } 51 protected final transient UndoableEditListener undoEditListener = e -> { 52 undo.addEdit(e.getEdit()); 53 undoAction.updateUndoState(); 54 redoAction.updateRedoState(); 60 55 }; 61 56 62 protected final transient PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { 63 @Override 64 public void propertyChange(PropertyChangeEvent evt) { 65 if (EDITABLE.equals(evt.getPropertyName())) { 66 removeAll(); 67 addMenuEntries(); 68 } 57 protected final transient PropertyChangeListener propertyChangeListener = evt -> { 58 if (EDITABLE.equals(evt.getPropertyName())) { 59 removeAll(); 60 addMenuEntries(); 69 61 } 70 62 };
Note:
See TracChangeset
for help on using the changeset viewer.