Ignore:
Timestamp:
2016-07-23T04:10:39+02:00 (8 years ago)
Author:
Don-vip
Message:

see #11390 - sonar - squid:S1604 - Java 8: Anonymous inner classes containing only one method should become lambdas

Location:
trunk/src/org/openstreetmap/josm/actions/downloadtasks
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/AbstractChangesetDownloadTask.java

    r10250 r10601  
    6161            // Run on the EDT because UI updates are triggered.
    6262            //
    63             Runnable r = new Runnable() {
    64                 @Override public void run() {
    65                     ChangesetCache.getInstance().update(downloadedChangesets);
    66                 }
    67             };
     63            Runnable r = () -> ChangesetCache.getInstance().update(downloadedChangesets);
    6864            if (SwingUtilities.isEventDispatchThread()) {
    6965                r.run();
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java

    r10467 r10601  
    117117        DataSetMerger visitor = new DataSetMerger(targetLayer.data, parents);
    118118        visitor.merge();
    119         SwingUtilities.invokeLater(
    120                 new Runnable() {
    121                     @Override
    122                     public void run() {
    123                         targetLayer.onPostDownloadFromServer();
    124                     }
    125                 }
    126         );
     119        SwingUtilities.invokeLater(targetLayer::onPostDownloadFromServer);
    127120        if (visitor.getConflicts().isEmpty())
    128121            return;
     
    131124                Main.parent,
    132125                trn("There was {0} conflict during import.",
    133                         "There were {0} conflicts during import.",
    134                         visitor.getConflicts().size(),
    135                         visitor.getConflicts().size()
     126                    "There were {0} conflicts during import.",
     127                    visitor.getConflicts().size(),
     128                    visitor.getConflicts().size()
    136129                ),
    137130                trn("Conflict during download", "Conflicts during download", visitor.getConflicts().size()),
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java

    r10436 r10601  
    3333import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3434import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    35 import org.openstreetmap.josm.gui.progress.ProgressMonitor.CancelListener;
    3635import org.openstreetmap.josm.gui.util.GuiHelper;
    3736import org.openstreetmap.josm.tools.ExceptionUtil;
     
    8887            }
    8988        }
    90         progressMonitor.addCancelListener(new CancelListener() {
    91             @Override
    92             public void operationCanceled() {
    93                 for (DownloadTask dt : tasks) {
    94                     dt.cancel();
    95                 }
     89        progressMonitor.addCancelListener(() -> {
     90            for (DownloadTask dt : tasks) {
     91                dt.cancel();
    9692            }
    9793        });
     
    151147            }
    152148        }
    153         EventQueue.invokeLater(new Runnable() {
    154             @Override public void run() {
    155                 UpdateSelectionAction.updatePrimitives(toSelect);
    156             }
    157         });
     149        EventQueue.invokeLater(() -> UpdateSelectionAction.updatePrimitives(toSelect));
    158150    }
    159151
     
    270262                }
    271263
    272                 GuiHelper.runInEDT(new Runnable() {
    273                     @Override
    274                     public void run() {
    275                         if (items.size() == 1 && tr("No data found in this area.").equals(items.iterator().next())) {
    276                             new Notification(items.iterator().next()).setIcon(JOptionPane.WARNING_MESSAGE).show();
    277                         } else {
    278                             JOptionPane.showMessageDialog(Main.parent, "<html>"
    279                                     + tr("The following errors occurred during mass download: {0}",
    280                                             Utils.joinAsHtmlUnorderedList(items)) + "</html>",
    281                                     tr("Errors during download"), JOptionPane.ERROR_MESSAGE);
    282                         }
     264                GuiHelper.runInEDT(() -> {
     265                    if (items.size() == 1 && tr("No data found in this area.").equals(items.iterator().next())) {
     266                        new Notification(items.iterator().next()).setIcon(JOptionPane.WARNING_MESSAGE).show();
     267                    } else {
     268                        JOptionPane.showMessageDialog(Main.parent, "<html>"
     269                                + tr("The following errors occurred during mass download: {0}",
     270                                        Utils.joinAsHtmlUnorderedList(items)) + "</html>",
     271                                tr("Errors during download"), JOptionPane.ERROR_MESSAGE);
    283272                    }
    284273                });
     
    312301                }
    313302                if (!myPrimitives.isEmpty()) {
    314                     GuiHelper.runInEDT(new Runnable() {
    315                         @Override public void run() {
    316                             handlePotentiallyDeletedPrimitives(myPrimitives);
    317                         }
    318                     });
     303                    GuiHelper.runInEDT(() -> handlePotentiallyDeletedPrimitives(myPrimitives));
    319304                }
    320305            }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java

    r10212 r10601  
    5858            final Object error = errors.iterator().next();
    5959            if (!GraphicsEnvironment.isHeadless()) {
    60                 SwingUtilities.invokeLater(new Runnable() {
    61                     @Override
    62                     public void run() {
    63                         if (error instanceof Exception) {
    64                             ExceptionDialogUtil.explainException((Exception) error);
    65                         } else if (tr("No data found in this area.").equals(error)) {
    66                             new Notification(error.toString()).setIcon(JOptionPane.WARNING_MESSAGE).show();
    67                         } else {
    68                             JOptionPane.showMessageDialog(
    69                                     Main.parent,
    70                                     error.toString(),
    71                                     tr("Error during download"),
    72                                     JOptionPane.ERROR_MESSAGE);
    73                         }
     60                SwingUtilities.invokeLater(() -> {
     61                    if (error instanceof Exception) {
     62                        ExceptionDialogUtil.explainException((Exception) error);
     63                    } else if (tr("No data found in this area.").equals(error)) {
     64                        new Notification(error.toString()).setIcon(JOptionPane.WARNING_MESSAGE).show();
     65                    } else {
     66                        JOptionPane.showMessageDialog(
     67                                Main.parent,
     68                                error.toString(),
     69                                tr("Error during download"),
     70                                JOptionPane.ERROR_MESSAGE);
    7471                    }
    7572                });
     
    9188
    9289            if (!GraphicsEnvironment.isHeadless()) {
    93                 SwingUtilities.invokeLater(new Runnable() {
    94                     @Override
    95                     public void run() {
    96                         JOptionPane.showMessageDialog(
    97                                 Main.parent,
    98                                 "<html>"+Utils.joinAsHtmlUnorderedList(items)+"</html>",
    99                                 tr("Errors during download"),
    100                                 JOptionPane.ERROR_MESSAGE);
    101                     }
    102                 });
     90                SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(
     91                        Main.parent,
     92                        "<html>"+Utils.joinAsHtmlUnorderedList(items)+"</html>",
     93                        tr("Errors during download"),
     94                        JOptionPane.ERROR_MESSAGE));
    10395            }
    10496            return;
Note: See TracChangeset for help on using the changeset viewer.