Changeset 10948 in josm
- Timestamp:
- 2016-09-03T22:29:48+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/Command.java
r10663 r10948 42 42 public abstract class Command implements PseudoCommand { 43 43 44 /** IS_OK : operation is okay */ 45 public static final int IS_OK = 0; 46 /** IS_OUTSIDE : operation on element outside of download area */ 47 public static final int IS_OUTSIDE = 1; 48 /** IS_INCOMPLETE: operation on incomplete target */ 49 public static final int IS_INCOMPLETE = 2; 50 44 51 private static final class CloneVisitor extends AbstractVisitor { 45 52 public final Map<OsmPrimitive, PrimitiveData> orig = new LinkedHashMap<>(); … … 245 252 /** 246 253 * Check whether user is about to operate on data outside of the download area. 254 * 255 * @param operation the operation name which is used for setting some preferences 256 * @param primitives the primitives to operate on 257 * @param ignore {@code null} or a primitive to be ignored 258 * @return true, if operating on outlying primitives is OK; false, otherwise 259 */ 260 public static int checkOutlyingOrIncompleteOperation(String operation, 261 Collection<? extends OsmPrimitive> primitives, 262 Collection<? extends OsmPrimitive> ignore) { 263 int res = 0; 264 for (OsmPrimitive osm : primitives) { 265 if (osm.isIncomplete()) { 266 res |= IS_INCOMPLETE; 267 } else if (osm.isOutsideDownloadArea() 268 && (ignore == null || !ignore.contains(osm))) { 269 res |= IS_OUTSIDE; 270 } 271 } 272 return res; 273 } 274 275 /** 276 * Check whether user is about to operate on data outside of the download area. 247 277 * Request confirmation if he is. 248 278 * … … 259 289 Collection<? extends OsmPrimitive> primitives, 260 290 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) { 291 int checkRes = checkOutlyingOrIncompleteOperation(operation, primitives, ignore); 292 if ((checkRes & IS_OUTSIDE) != 0) { 272 293 JPanel msg = new JPanel(new GridBagLayout()); 273 294 msg.add(new JMultilineLabel("<html>" + outsideDialogMessage + "</html>")); … … 283 304 return false; 284 305 } 285 if ( incomplete) {306 if ((checkRes & IS_INCOMPLETE) != 0) { 286 307 JPanel msg = new JPanel(new GridBagLayout()); 287 308 msg.add(new JMultilineLabel("<html>" + incompleteDialogMessage + "</html>")); -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
r10924 r10948 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; … … 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 }
Note:
See TracChangeset
for help on using the changeset viewer.