Ticket #17401: 17401-v3.patch
| File 17401-v3.patch, 4.4 KB (added by , 7 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
34 34 import org.openstreetmap.josm.actions.ValidateAction; 35 35 import org.openstreetmap.josm.actions.relation.EditRelationAction; 36 36 import org.openstreetmap.josm.command.Command; 37 import org.openstreetmap.josm.command.SequenceCommand; 37 38 import org.openstreetmap.josm.data.UndoRedoHandler; 38 39 import org.openstreetmap.josm.data.osm.DataSelectionListener; 39 40 import org.openstreetmap.josm.data.osm.DataSet; … … 601 602 // do nothing 602 603 } 603 604 604 protected void fixError(TestError error) throws InterruptedException, InvocationTargetException{605 protected void fixError(TestError error) { 605 606 if (error.isFixable()) { 606 607 final Command fixCommand = error.getFix(); 607 608 if (fixCommand != null) { 608 SwingUtilities.invokeAndWait(() -> UndoRedoHandler.getInstance().addNoRedraw(fixCommand));609 609 fixCommands.add(fixCommand); 610 610 } 611 611 // It is wanted to ignore an error if it said fixable, even if fixCommand was null … … 622 622 monitor.setTicksCount(testErrors.size()); 623 623 final DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); 624 624 int i = 0; 625 SwingUtilities.invokeAndWait(ds::beginUpdate); 626 try { 627 for (TestError error: testErrors) { 628 i++; 629 monitor.subTask(tr("Fixing ({0}/{1}): ''{2}''", i, testErrors.size(), error.getMessage())); 630 if (this.canceled) 631 return; 632 fixError(error); 633 monitor.worked(1); 634 } 635 } finally { 636 SwingUtilities.invokeAndWait(ds::endUpdate); 625 for (TestError error: testErrors) { 626 i++; 627 monitor.subTask(tr("Fixing ({0}/{1}): ''{2}''", i, testErrors.size(), error.getMessage())); 628 if (this.canceled) 629 return; 630 fixError(error); 631 monitor.worked(1); 637 632 } 638 633 monitor.subTask(tr("Updating map ...")); 634 List<TestError> oldErrors = new ArrayList<>(tree.getErrors()); 635 tree.getErrors().clear(); 639 636 SwingUtilities.invokeAndWait(() -> { 640 UndoRedoHandler.getInstance().afterAdd(fixCommands);641 invalidateValidatorLayers();642 tree.resetErrors();637 ds.beginUpdate(); 638 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("fixed by Validator"), fixCommands, true)); 639 ds.endUpdate(); 643 640 }); 641 invalidateValidatorLayers(); 642 643 oldErrors.removeIf(error -> error.getPrimitives().stream().anyMatch(OsmPrimitive::isDeleted)); 644 tree.getErrors().addAll(oldErrors); 645 tree.resetErrors(); 644 646 } catch (InterruptedException | InvocationTargetException e) { 645 647 // FIXME: signature of realRun should have a generic checked exception we could throw here 646 648 throw new JosmRuntimeException(e); -
src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
483 483 484 484 @Override public void primitivesRemoved(PrimitivesRemovedEvent event) { 485 485 // Remove purged primitives (fix #8639) 486 if (errors != null) { 487 final Set<? extends OsmPrimitive> deletedPrimitives = new HashSet<>(event.getPrimitives()); 488 errors.removeIf(error -> error.getPrimitives().stream().anyMatch(deletedPrimitives::contains)); 486 if (errors != null && !errors.isEmpty()) { 487 errors.removeIf(error -> error.getPrimitives().stream().anyMatch(OsmPrimitive::isDeleted)); 489 488 } 490 489 } 491 490
