Ticket #13491: 13491_v3.patch
| File 13491_v3.patch, 4.3 KB (added by , 10 years ago) |
|---|
-
src/org/openstreetmap/josm/command/Command.java
242 242 return cloneMap.keySet(); 243 243 } 244 244 245 /** IS_OK : operation is okay */ 246 public static int IS_OK = 0; 247 /** IS_OUTSIDE : operation on element outside of download area */ 248 public static int IS_OUTSIDE = 1; 249 /** IS_INCOMPLETE: operation on incomplete target */ 250 public static int IS_INCOMPLET = 2; 245 251 /** 246 252 * Check whether user is about to operate on data outside of the download area. 253 * 254 * @param operation the operation name which is used for setting some preferences 255 * @param primitives the primitives to operate on 256 * @param ignore {@code null} or a primitive to be ignored 257 * @return true, if operating on outlying primitives is OK; false, otherwise 258 */ 259 public static int checkOutlyingOrIncompleteOperation(String operation, 260 Collection<? extends OsmPrimitive> primitives, 261 Collection<? extends OsmPrimitive> ignore) { 262 int res = 0; 263 for (OsmPrimitive osm : primitives) { 264 if (osm.isIncomplete()) { 265 res |= IS_INCOMPLET; 266 } else if (osm.isOutsideDownloadArea() 267 && (ignore == null || !ignore.contains(osm))) { 268 res |= IS_OUTSIDE; 269 } 270 } 271 return res; 272 } 273 274 /** 275 * Check whether user is about to operate on data outside of the download area. 247 276 * Request confirmation if he is. 248 277 * 249 278 * @param operation the operation name which is used for setting some preferences … … 258 287 String dialogTitle, String outsideDialogMessage, String incompleteDialogMessage, 259 288 Collection<? extends OsmPrimitive> primitives, 260 289 Collection<? extends OsmPrimitive> ignore) { 261 boolean outside = false; 262 boolean incomplete = false; 263 for (OsmPrimitive osm : primitives) { 264 if (osm.isIncomplete()) { 265 incomplete = true; 266 } else if (osm.isOutsideDownloadArea() 267 && (ignore == null || !ignore.contains(osm))) { 268 outside = true; 269 } 270 } 271 if (outside) { 290 int checkRes = checkOutlyingOrIncompleteOperation(operation, primitives, ignore); 291 if ((checkRes & IS_OUTSIDE) != 0) { 272 292 JPanel msg = new JPanel(new GridBagLayout()); 273 293 msg.add(new JMultilineLabel("<html>" + outsideDialogMessage + "</html>")); 274 294 boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog( … … 282 302 if (!answer) 283 303 return false; 284 304 } 285 if ( incomplete) {305 if ((checkRes & IS_INCOMPLET) != 0) { 286 306 JPanel msg = new JPanel(new GridBagLayout()); 287 307 msg.add(new JMultilineLabel("<html>" + incompleteDialogMessage + "</html>")); 288 308 boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog( … … 299 319 return true; 300 320 } 301 321 322 302 323 @Override 303 324 public int hashCode() { 304 325 return Objects.hash(cloneMap, layer); -
src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
20 20 import org.openstreetmap.josm.Main; 21 21 import org.openstreetmap.josm.actions.MergeNodesAction; 22 22 import org.openstreetmap.josm.command.Command; 23 import org.openstreetmap.josm.command.DeleteCommand;24 23 import org.openstreetmap.josm.data.coor.LatLon; 25 24 import org.openstreetmap.josm.data.osm.Hash; 26 25 import org.openstreetmap.josm.data.osm.Node; … … 407 406 target = nodes.iterator().next(); 408 407 } 409 408 410 if ( DeleteCommand.checkAndConfirmOutlyingDelete(nodes, Collections.singleton(target)))409 if (Command.checkOutlyingOrIncompleteOperation("delete", nodes, Collections.singleton(target)) == Command.IS_OK) 411 410 return MergeNodesAction.mergeNodes(Main.getLayerManager().getEditLayer(), nodes, target); 412 411 } 413 412
