Ticket #15707: no_exception_for_empty_selection.patch

File no_exception_for_empty_selection.patch, 2.7 KB (added by skorbut, 7 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;
     
    236236            });
    237237        }
    238238
    239         AddTagsDialog.addTags(args, sender, forTagAdd);
     239        // needs to run in EDT since forTagAdd is updated in EDT as well
     240        GuiHelper.executeByMainWorkerInEDT(() -> {
     241            if (forTagAdd.size() > 0) {
     242                AddTagsDialog.addTags(args, sender, forTagAdd);
     243            } else if (isKeepingCurrentSelection && args.containsKey("addtags")) {
     244                // TODO: see #15707, display error message:
     245                // You clicked on a JOSM remotecontrol link that would apply tags onto selected objects.
     246                // Since no objects were selected, no tags were added. Select one or more objects and click the link again.
     247                Logging.warn("RemoteControl: addtags= is set, but forTagAdd is empty (isKeepingCurrentSelection is set)");
     248            } else if (!isKeepingCurrentSelection && args.containsKey("addtags")) {
     249                // TODO: see #15707, display error message:
     250                // You clicked on a JOSM remotecontrol link that would apply tags onto selected objects.
     251                // This link seems to be broken due to an invalid value of the query parameter 'select='.
     252                // Ask at the source of the link if it can be fixed.
     253                Logging.warn("RemoteControl: addtags= is set, but forTagAdd is empty (isKeepingCurrentSelection is not set)");
     254            }
     255        });
     256
    240257    }
    241258
    242259    protected void zoom(Collection<OsmPrimitive> primitives, final Bounds bbox) {