Ticket #15707: no_exception_for_empty_selection2.patch

File no_exception_for_empty_selection2.patch, 3.0 KB (added by skorbut, 8 years ago)
  • src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

     
    171171            });
    172172        }
    173173
    174         final Collection<OsmPrimitive> forTagAdd = new HashSet<>();
     174        final Collection<OsmPrimitive> forTagAdd = new HashSet<>(); // these objects will receive new tags
    175175        final Bounds bbox = new Bounds(minlat, minlon, maxlat, maxlon);
    176176        if (args.containsKey("select") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) {
    177177            // select objects after downloading, zoom to selection.
    178178            GuiHelper.executeByMainWorkerInEDT(() -> {
    179                 Set<OsmPrimitive> newSel = new HashSet<>();
     179                Set<OsmPrimitive> newSel = new HashSet<>(); // these objects will be selected later on
    180180                DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    181181                if (ds == null) // e.g. download failed
    182182                    return;
     
    193193                    forTagAdd.addAll(sel);
    194194                }
    195195                toSelect.clear();
    196                 isKeepingCurrentSelection = false;
    197196                ds.setSelected(newSel);
    198197                zoom(newSel, bbox);
    199198                MapFrame map = MainApplication.getMap();
     
    236235            });
    237236        }
    238237
    239         AddTagsDialog.addTags(args, sender, forTagAdd);
     238        // needs to run in EDT since forTagAdd is updated in EDT as well
     239        GuiHelper.executeByMainWorkerInEDT(() -> {
     240            if (forTagAdd.size() > 0) {
     241                AddTagsDialog.addTags(args, sender, forTagAdd);
     242            } else if (isKeepingCurrentSelection && args.containsKey("addtags")) {
     243                // TODO: see #15707, display error message:
     244                // You clicked on a JOSM remotecontrol link that would apply tags onto selected objects.
     245                // Since no objects were selected, no tags were added. Select one or more objects and click the link again.
     246                Logging.warn("RemoteControl: addtags= is set, but forTagAdd is empty (isKeepingCurrentSelection is set)");
     247            } else if (!isKeepingCurrentSelection && args.containsKey("addtags")) {
     248                // TODO: see #15707, display error message:
     249                // You clicked on a JOSM remotecontrol link that would apply tags onto selected objects.
     250                // This link seems to be broken due to an invalid value of the query parameter 'select='.
     251                // Ask at the source of the link if it can be fixed.
     252                Logging.warn("RemoteControl: addtags= is set, but forTagAdd is empty (isKeepingCurrentSelection is not set)");
     253            }
     254        });
     255
    240256    }
    241257
    242258    protected void zoom(Collection<OsmPrimitive> primitives, final Bounds bbox) {