Changeset 7521 in josm for trunk/src/org
- Timestamp:
- 2014-09-10T21:53:16+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io/remotecontrol
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r7005 r7521 291 291 * addtags=wikipedia:de%3DResidenzschloss Dresden|name:en%3DDresden Castle 292 292 */ 293 public static void addTags(final Map<String, String> args, final String sender ) {293 public static void addTags(final Map<String, String> args, final String sender, final Collection<? extends OsmPrimitive> primitives) { 294 294 if (args.containsKey("addtags")) { 295 295 GuiHelper.executeByMainWorkerInEDT(new Runnable() { … … 319 319 i++; 320 320 } 321 addTags(keyValue, sender );321 addTags(keyValue, sender, primitives); 322 322 } 323 323 } … … 333 333 * @param sender is a string for skipping confirmations. Use epmty string for always confirmed adding. 334 334 */ 335 public static void addTags(String[][] keyValue, String sender ) {335 public static void addTags(String[][] keyValue, String sender, Collection<? extends OsmPrimitive> primitives) { 336 336 if (trustedSenders.contains(sender)) { 337 337 if (Main.main.getCurrentDataSet() != null) { 338 Collection<OsmPrimitive> s = Main.main.getCurrentDataSet().getSelected();339 338 for (String[] row : keyValue) { 340 Main.main.undoRedo.add(new ChangePropertyCommand( s, row[0], row[1]));339 Main.main.undoRedo.add(new ChangePropertyCommand(primitives, row[0], row[1])); 341 340 } 342 341 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
r6536 r7521 5 5 6 6 import java.awt.Point; 7 import java.util.Collections; 7 8 import java.util.Map; 8 9 … … 29 30 private double lat; 30 31 private double lon; 32 33 private Node node; 31 34 32 35 @Override … … 87 90 LatLon ll = new LatLon(lat, lon); 88 91 89 Node nd= null;92 node = null; 90 93 91 94 if (Main.isDisplayingMapView()) { 92 95 Point p = Main.map.mapView.getPoint(ll); 93 n d= Main.map.mapView.getNearestNode(p, OsmPrimitive.isUsablePredicate);94 if (n d!=null && nd.getCoor().greatCircleDistance(ll) > Main.pref.getDouble("remotecontrol.tolerance", 0.1)) {95 n d= null; // node is too far96 node = Main.map.mapView.getNearestNode(p, OsmPrimitive.isUsablePredicate); 97 if (node!=null && node.getCoor().greatCircleDistance(ll) > Main.pref.getDouble("remotecontrol.tolerance", 0.1)) { 98 node = null; // node is too far 96 99 } 97 100 } 98 101 99 if (n d==null) {100 n d= new Node(ll);102 if (node==null) { 103 node = new Node(ll); 101 104 // Now execute the commands to add this node. 102 Main.main.undoRedo.add(new AddCommand(n d));105 Main.main.undoRedo.add(new AddCommand(node)); 103 106 } 104 107 105 Main.main.getCurrentDataSet().setSelected(n d);108 Main.main.getCurrentDataSet().setSelected(node); 106 109 if (PermissionPrefWithDefault.CHANGE_VIEWPORT.isAllowed()) { 107 110 AutoScaleAction.autoScale("selection"); … … 110 113 } 111 114 // parse parameter addtags=tag1=value1|tag2=vlaue2 112 AddTagsDialog.addTags(args, sender );115 AddTagsDialog.addTags(args, sender, Collections.singleton(node)); 113 116 } 114 117 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
r7509 r7521 7 7 import java.util.ArrayList; 8 8 import java.util.Arrays; 9 import java.util.Collections; 9 10 import java.util.HashMap; 10 11 import java.util.LinkedList; … … 36 37 37 38 private final List<LatLon> allCoordinates = new ArrayList<>(); 39 40 private Way way; 38 41 39 42 /** … … 69 72 GuiHelper.runInEDTAndWait(new Runnable() { 70 73 @Override public void run() { 71 addWay();74 way = addWay(); 72 75 } 73 76 }); 74 77 // parse parameter addtags=tag1=value1|tag2=value2 75 AddTagsDialog.addTags(args, sender );78 AddTagsDialog.addTags(args, sender, Collections.singleton(way)); 76 79 } 77 80 … … 150 153 * This function creates the way with given coordinates of nodes 151 154 */ 152 private voidaddWay() {155 private Way addWay() { 153 156 addedNodes = new HashMap<>(); 154 157 Way way = new Way(); … … 167 170 Main.map.mapView.repaint(); 168 171 } 172 return way; 169 173 } 170 174 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r7251 r7521 160 160 } 161 161 162 final Collection<OsmPrimitive> forTagAdd = new HashSet<>(); 162 163 final Bounds bbox = new Bounds(minlat, minlon, maxlat, maxlon); 163 164 if (args.containsKey("select") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) { … … 174 175 if (p != null) { 175 176 newSel.add(p); 177 forTagAdd.add(p); 176 178 } 177 179 } … … 188 190 } else if (args.containsKey("search") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) { 189 191 try { 190 final DataSet ds = Main.main.getCurrentDataSet();191 192 final SearchCompiler.Match search = SearchCompiler.compile(args.get("search"), false, false); 192 final Collection<OsmPrimitive> filteredPrimitives = Utils.filter(ds.allPrimitives(), search); 193 ds.setSelected(filteredPrimitives); 194 zoom(filteredPrimitives, bbox); 193 Main.worker.submit(new Runnable() { 194 @Override 195 public void run() { 196 final DataSet ds = Main.main.getCurrentDataSet(); 197 final Collection<OsmPrimitive> filteredPrimitives = Utils.filter(ds.allPrimitives(), search); 198 ds.setSelected(filteredPrimitives); 199 forTagAdd.addAll(filteredPrimitives); 200 zoom(filteredPrimitives, bbox); 201 } 202 }); 195 203 } catch (SearchCompiler.ParseError ex) { 196 204 Main.error(ex); … … 219 227 } 220 228 221 AddTagsDialog.addTags(args, sender );229 AddTagsDialog.addTags(args, sender, forTagAdd); 222 230 } 223 231 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandler.java
r7005 r7521 2 2 package org.openstreetmap.josm.io.remotecontrol.handler; 3 3 4 import java.util.Collection; 5 import java.util.HashSet; 4 6 import static org.openstreetmap.josm.tools.I18n.tr; 5 7 … … 8 10 9 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.data.osm.DataSet; 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 14 import org.openstreetmap.josm.data.osm.PrimitiveId; 11 15 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; … … 68 72 public void run() { 69 73 final List<PrimitiveId> downloaded = task.getDownloadedId(); 74 final DataSet ds = Main.main.getCurrentDataSet(); 70 75 if(downloaded != null) { 71 76 GuiHelper.runInEDT(new Runnable() { 72 77 @Override 73 78 public void run() { 74 Main.main.getCurrentDataSet().setSelected(downloaded);79 ds.setSelected(downloaded); 75 80 } 76 81 }); 77 82 } 78 AddTagsDialog.addTags(args, sender); 83 Collection<OsmPrimitive> downlPrim = new HashSet<>(); 84 for (PrimitiveId id : downloaded) { 85 downlPrim.add(ds.getPrimitiveById(id)); 86 } 87 AddTagsDialog.addTags(args, sender, downlPrim); 79 88 ps.clear(); 80 89 }
Note:
See TracChangeset
for help on using the changeset viewer.