Ticket #15707: no_exception_for_empty_selection3.patch
File no_exception_for_empty_selection3.patch, 3.7 KB (added by , 6 years ago) |
---|
-
src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
13 13 import java.util.Set; 14 14 import java.util.concurrent.Future; 15 15 16 import javax.swing.JOptionPane; 17 18 import org.openstreetmap.josm.Main; 16 19 import org.openstreetmap.josm.actions.AutoScaleAction; 17 20 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 18 21 import org.openstreetmap.josm.actions.downloadtasks.DownloadTask; … … 171 174 }); 172 175 } 173 176 174 final Collection<OsmPrimitive> forTagAdd = new HashSet<>(); 177 final Collection<OsmPrimitive> forTagAdd = new HashSet<>(); // these objects will receive tags 175 178 final Bounds bbox = new Bounds(minlat, minlon, maxlat, maxlon); 176 179 if (args.containsKey("select") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) { 177 180 // select objects after downloading, zoom to selection. 178 181 GuiHelper.executeByMainWorkerInEDT(() -> { 179 Set<OsmPrimitive> newSel = new HashSet<>(); 182 Set<OsmPrimitive> newSel = new HashSet<>(); // these objects will be selected later on 180 183 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 181 184 if (ds == null) // e.g. download failed 182 185 return; … … 193 196 forTagAdd.addAll(sel); 194 197 } 195 198 toSelect.clear(); 196 isKeepingCurrentSelection = false;197 199 ds.setSelected(newSel); 198 200 zoom(newSel, bbox); 199 201 MapFrame map = MainApplication.getMap(); … … 236 238 }); 237 239 } 238 240 239 AddTagsDialog.addTags(args, sender, forTagAdd); 241 // add tags to objects 242 if (args.containsKey("addtags")) { 243 // needs to run in EDT since forTagAdd is updated in EDT as well 244 GuiHelper.executeByMainWorkerInEDT(() -> { 245 if (!forTagAdd.isEmpty()) { 246 AddTagsDialog.addTags(args, sender, forTagAdd); 247 } else { // something is wrong, forTagAdd should not be empty 248 if (isKeepingCurrentSelection) { 249 JOptionPane.showMessageDialog(Main.parent, 250 tr("You clicked on a JOSM remotecontrol link that would apply tags onto selected objects.\n" 251 + "Since no objects have been selected before this click, no tags were added.\n" 252 + "Select one or more objects and click the link again."), 253 tr("No object selected"), JOptionPane.ERROR_MESSAGE); 254 } else { // !isKeepingCurrentSelection 255 JOptionPane.showMessageDialog(Main.parent, 256 tr("You clicked on a JOSM remotecontrol link that would apply tags onto objects.\n" 257 + "Unfortunately that link seems to be broken.\n" 258 + "Technical explanation: the URL query parameter ''select='' or ''search='' has an invalid value.\n" 259 + "Ask someone at the origin of the clicked link to fix this."), 260 tr("Invalid query parameter"), JOptionPane.ERROR_MESSAGE); 261 } 262 } 263 }); 264 } 240 265 } 241 266 242 267 protected void zoom(Collection<OsmPrimitive> primitives, final Bounds bbox) {