Changeset 10615 in josm for trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
- Timestamp:
- 2016-07-23T20:04:31+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r10446 r10615 155 155 */ 156 156 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(); 165 162 }); 166 163 } … … 170 167 if (args.containsKey("select") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) { 171 168 // 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)); 194 188 } 195 189 }); … … 197 191 try { 198 192 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); 208 199 }); 209 200 } catch (SearchCompiler.ParseError ex) { … … 218 209 // add changeset tags after download if necessary 219 210 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")); 230 218 } 231 219 } … … 245 233 } else if (Main.isDisplayingMapView()) { 246 234 // 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); 254 239 }); 255 240 } … … 297 282 toSelect.add(SimplePrimitiveId.fromString(item)); 298 283 } catch (IllegalArgumentException ex) { 299 Main.warn( "RemoteControl: invalid selection '" + item + "' ignored");284 Main.warn(ex, "RemoteControl: invalid selection '" + item + "' ignored"); 300 285 } 301 286 }
Note:
See TracChangeset
for help on using the changeset viewer.