Ignore:
Timestamp:
2016-07-23T20:04:31+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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r10446 r10615  
    155155         */
    156156        if (args.containsKey("addtags")) {
    157             GuiHelper.executeByMainWorkerInEDT(new Runnable() {
    158                 @Override
    159                 public void run() {
    160                     DataSet ds = Main.getLayerManager().getEditDataSet();
    161                     if (ds == null) // e.g. download failed
    162                         return;
    163                     ds.clearSelection();
    164                 }
     157            GuiHelper.executeByMainWorkerInEDT(() -> {
     158                DataSet ds = Main.getLayerManager().getEditDataSet();
     159                if (ds == null) // e.g. download failed
     160                    return;
     161                ds.clearSelection();
    165162            });
    166163        }
     
    170167        if (args.containsKey("select") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) {
    171168            // select objects after downloading, zoom to selection.
    172             GuiHelper.executeByMainWorkerInEDT(new Runnable() {
    173                 @Override
    174                 public void run() {
    175                     Set<OsmPrimitive> newSel = new HashSet<>();
    176                     DataSet ds = Main.getLayerManager().getEditDataSet();
    177                     if (ds == null) // e.g. download failed
    178                         return;
    179                     for (SimplePrimitiveId id : toSelect) {
    180                         final OsmPrimitive p = ds.getPrimitiveById(id);
    181                         if (p != null) {
    182                             newSel.add(p);
    183                             forTagAdd.add(p);
    184                         }
    185                     }
    186                     toSelect.clear();
    187                     ds.setSelected(newSel);
    188                     zoom(newSel, bbox);
    189                     if (Main.isDisplayingMapView() && Main.map.relationListDialog != null) {
    190                         Main.map.relationListDialog.selectRelations(null); // unselect all relations to fix #7342
    191                         Main.map.relationListDialog.dataChanged(null);
    192                         Main.map.relationListDialog.selectRelations(Utils.filteredCollection(newSel, Relation.class));
    193                     }
     169            GuiHelper.executeByMainWorkerInEDT(() -> {
     170                Set<OsmPrimitive> newSel = new HashSet<>();
     171                DataSet ds = Main.getLayerManager().getEditDataSet();
     172                if (ds == null) // e.g. download failed
     173                    return;
     174                for (SimplePrimitiveId id : toSelect) {
     175                    final OsmPrimitive p = ds.getPrimitiveById(id);
     176                    if (p != null) {
     177                        newSel.add(p);
     178                        forTagAdd.add(p);
     179                    }
     180                }
     181                toSelect.clear();
     182                ds.setSelected(newSel);
     183                zoom(newSel, bbox);
     184                if (Main.isDisplayingMapView() && Main.map.relationListDialog != null) {
     185                    Main.map.relationListDialog.selectRelations(null); // unselect all relations to fix #7342
     186                    Main.map.relationListDialog.dataChanged(null);
     187                    Main.map.relationListDialog.selectRelations(Utils.filteredCollection(newSel, Relation.class));
    194188                }
    195189            });
     
    197191            try {
    198192                final SearchCompiler.Match search = SearchCompiler.compile(args.get("search"));
    199                 Main.worker.submit(new Runnable() {
    200                     @Override
    201                     public void run() {
    202                         final DataSet ds = Main.getLayerManager().getEditDataSet();
    203                         final Collection<OsmPrimitive> filteredPrimitives = Utils.filter(ds.allPrimitives(), search);
    204                         ds.setSelected(filteredPrimitives);
    205                         forTagAdd.addAll(filteredPrimitives);
    206                         zoom(filteredPrimitives, bbox);
    207                     }
     193                Main.worker.submit(() -> {
     194                    final DataSet ds = Main.getLayerManager().getEditDataSet();
     195                    final Collection<OsmPrimitive> filteredPrimitives = Utils.filter(ds.allPrimitives(), search);
     196                    ds.setSelected(filteredPrimitives);
     197                    forTagAdd.addAll(filteredPrimitives);
     198                    zoom(filteredPrimitives, bbox);
    208199                });
    209200            } catch (SearchCompiler.ParseError ex) {
     
    218209        // add changeset tags after download if necessary
    219210        if (args.containsKey("changeset_comment") || args.containsKey("changeset_source")) {
    220             Main.worker.submit(new Runnable() {
    221                 @Override
    222                 public void run() {
    223                     if (Main.getLayerManager().getEditDataSet() != null) {
    224                         if (args.containsKey("changeset_comment")) {
    225                             Main.getLayerManager().getEditDataSet().addChangeSetTag("comment", args.get("changeset_comment"));
    226                         }
    227                         if (args.containsKey("changeset_source")) {
    228                             Main.getLayerManager().getEditDataSet().addChangeSetTag("source", args.get("changeset_source"));
    229                         }
     211            Main.worker.submit(() -> {
     212                if (Main.getLayerManager().getEditDataSet() != null) {
     213                    if (args.containsKey("changeset_comment")) {
     214                        Main.getLayerManager().getEditDataSet().addChangeSetTag("comment", args.get("changeset_comment"));
     215                    }
     216                    if (args.containsKey("changeset_source")) {
     217                        Main.getLayerManager().getEditDataSet().addChangeSetTag("source", args.get("changeset_source"));
    230218                    }
    231219                }
     
    245233        } else if (Main.isDisplayingMapView()) {
    246234            // make sure this isn't called unless there *is* a MapView
    247             GuiHelper.executeByMainWorkerInEDT(new Runnable() {
    248                 @Override
    249                 public void run() {
    250                     BoundingXYVisitor bbox1 = new BoundingXYVisitor();
    251                     bbox1.visit(bbox);
    252                     Main.map.mapView.zoomTo(bbox1);
    253                 }
     235            GuiHelper.executeByMainWorkerInEDT(() -> {
     236                BoundingXYVisitor bbox1 = new BoundingXYVisitor();
     237                bbox1.visit(bbox);
     238                Main.map.mapView.zoomTo(bbox1);
    254239            });
    255240        }
     
    297282                    toSelect.add(SimplePrimitiveId.fromString(item));
    298283                } catch (IllegalArgumentException ex) {
    299                     Main.warn("RemoteControl: invalid selection '" + item + "' ignored");
     284                    Main.warn(ex, "RemoteControl: invalid selection '" + item + "' ignored");
    300285                }
    301286            }
Note: See TracChangeset for help on using the changeset viewer.