Changeset 5287 in josm
- Timestamp:
- 2012-06-20T21:57:46+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/Test.java
r5269 r5287 12 12 import javax.swing.JPanel; 13 13 14 import org.openstreetmap.josm.Main; 14 15 import org.openstreetmap.josm.command.Command; 16 import org.openstreetmap.josm.command.DeleteCommand; 15 17 import org.openstreetmap.josm.data.osm.Node; 16 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 223 225 return progressMonitor.isCanceled(); 224 226 } 227 228 /** 229 * Build a Delete command on all primitives that have not yet been deleted manually by user, or by another error fix. 230 * If all primitives have already been deleted, null is returned. 231 * @param primitives The primitives wanted for deletion 232 * @return a Delete command on all primitives that have not yet been deleted, or null otherwise 233 */ 234 protected final Command deletePrimitivesIfNeeded(Collection<? extends OsmPrimitive> primitives) { 235 Collection<OsmPrimitive> primitivesToDelete = new ArrayList<OsmPrimitive>(); 236 for (OsmPrimitive p : primitives) { 237 if (!p.isDeleted()) { 238 primitivesToDelete.add(p); 239 } 240 } 241 if (!primitivesToDelete.isEmpty()) { 242 return DeleteCommand.delete(Main.map.mapView.getEditLayer(), primitivesToDelete); 243 } else { 244 return null; 245 } 246 } 225 247 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
r5060 r5287 373 373 LinkedHashSet<Node> nodes = new LinkedHashSet<Node>(OsmPrimitive.getFilteredList(sel, Node.class)); 374 374 375 // Use first existing node or first node if all nodes are new 376 Node target = null; 377 for (Node n: nodes) { 378 if (!n.isNew()) { 379 target = n; 380 break; 381 } 382 } 383 if (target == null) { 384 target = nodes.iterator().next(); 385 } 386 387 if (DeleteCommand.checkAndConfirmOutlyingDelete(Main.main.getCurrentDataSet().getDataSourceArea(), nodes, Collections.singleton(target))) 388 return MergeNodesAction.mergeNodes(Main.main.getEditLayer(), nodes, target); 375 // Filter nodes that have already been deleted (see #5764 and #5773) 376 for (Iterator<Node> it = nodes.iterator(); it.hasNext();) { 377 if (it.next().isDeleted()) { 378 it.remove(); 379 } 380 } 381 382 // Merge only if at least 2 nodes remain 383 if (nodes.size() >= 2) { 384 // Use first existing node or first node if all nodes are new 385 Node target = null; 386 for (Node n: nodes) { 387 if (!n.isNew()) { 388 target = n; 389 break; 390 } 391 } 392 if (target == null) { 393 target = nodes.iterator().next(); 394 } 395 396 if (DeleteCommand.checkAndConfirmOutlyingDelete(Main.main.getCurrentDataSet().getDataSourceArea(), nodes, Collections.singleton(target))) 397 return MergeNodesAction.mergeNodes(Main.main.getEditLayer(), nodes, target); 398 } 389 399 390 400 return null;// undoRedo handling done in mergeNodes -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicatedWayNodes.java
r4869 r5287 7 7 import java.util.Collections; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.command.ChangeCommand; 11 10 import org.openstreetmap.josm.command.Command; 12 import org.openstreetmap.josm.command.DeleteCommand;13 11 import org.openstreetmap.josm.data.osm.Node; 14 12 import org.openstreetmap.josm.data.osm.Way; … … 61 59 if (wnew.getNodesCount() < 2) 62 60 // Empty way, delete 63 return DeleteCommand.delete(Main.map.mapView.getEditLayer(),Collections.singleton(w));61 return deletePrimitivesIfNeeded(Collections.singleton(w)); 64 62 else 65 63 return new ChangeCommand(w, wnew); -
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java
r4806 r5287 8 8 import java.util.Map; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.command.Command; 12 import org.openstreetmap.josm.command.DeleteCommand;13 11 import org.openstreetmap.josm.data.osm.Node; 14 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 110 108 @Override 111 109 public Command fixError(TestError testError) { 112 return DeleteCommand.delete(Main.map.mapView.getEditLayer(),testError.getPrimitives());110 return deletePrimitivesIfNeeded(testError.getPrimitives()); 113 111 } 114 112 -
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java
r4806 r5287 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.command.Command; 13 import org.openstreetmap.josm.command.DeleteCommand;14 13 import org.openstreetmap.josm.data.osm.Relation; 15 14 import org.openstreetmap.josm.data.osm.RelationMember; … … 142 141 @Override 143 142 public Command fixError(TestError testError) { 144 return DeleteCommand.delete(Main.map.mapView.getEditLayer(),testError.getPrimitives());143 return deletePrimitivesIfNeeded(testError.getPrimitives()); 145 144 } 146 145 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
r5266 r5287 25 25 import javax.swing.JOptionPane; 26 26 import javax.swing.JPopupMenu; 27 import javax.swing.KeyStroke;28 27 import javax.swing.SwingUtilities; 29 28 import javax.swing.event.TreeSelectionEvent; … … 570 569 if (this.canceled) 571 570 return; 572 final Command fixCommand = error.getFix(); 573 if (fixCommand != null) { 574 SwingUtilities.invokeAndWait(new Runnable() { 575 @Override 576 public void run() { 577 Main.main.undoRedo.addNoRedraw(fixCommand); 578 } 579 }); 571 if (error.isFixable()) { 572 final Command fixCommand = error.getFix(); 573 if (fixCommand != null) { 574 SwingUtilities.invokeAndWait(new Runnable() { 575 @Override 576 public void run() { 577 Main.main.undoRedo.addNoRedraw(fixCommand); 578 } 579 }); 580 } 581 // It is wanted to ignore an error if it said fixable, even if fixCommand was null 582 // This is to fix #5764 and #5773: a delete command, for example, may be null if all concerned primitives have already been deleted 580 583 error.setIgnored(true); 581 584 }
Note:
See TracChangeset
for help on using the changeset viewer.