Changeset 18737 in osm for applications/editors/josm/plugins/validator/src
- Timestamp:
- 2009-11-22T15:04:33+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidatorDialog.java
r18377 r18737 143 143 144 144 Set<DefaultMutableTreeNode> processedNodes = new HashSet<DefaultMutableTreeNode>(); 145 145 146 146 DuplicateNode.clearBackreferences(); 147 147 LinkedList<TestError> errorsToFix = new LinkedList<TestError>(); … … 160 160 Object nodeInfo = childNode.getUserObject(); 161 161 if (nodeInfo instanceof TestError) { 162 errorsToFix.add((TestError)nodeInfo);163 } 164 } 165 } 166 162 errorsToFix.add((TestError)nodeInfo); 163 } 164 } 165 } 166 167 167 // run fix task asynchronously 168 168 // … … 445 445 tree.setFilter(filter); 446 446 } 447 448 /** 449 * Task for fixing a collection of {@see TestError}s. Can be run asynchronously. 450 * 447 448 /** 449 * Task for fixing a collection of {@see TestError}s. Can be run asynchronously. 451 450 * 451 * 452 452 */ 453 453 class FixTask extends PleaseWaitRunnable { 454 private Collection<TestError> testErrors;455 private boolean canceled;456 private LinkedList<Command> fixCommands;457 458 459 public FixTask(Collection<TestError> testErrors) {460 super(tr("Fixing errors ..."), false /* don't ignore exceptions */);461 this.testErrors = testErrors == null ? new ArrayList<TestError> (): testErrors;462 fixCommands = new LinkedList<Command>();463 }464 465 @Override466 protected void cancel() {467 this.canceled = true;468 }469 470 @Override471 protected void finish() {472 // do nothing473 }474 475 @Override476 protected void realRun() throws SAXException, IOException,477 OsmTransferException {478 ProgressMonitor monitor = getProgressMonitor();479 try { 480 monitor.setTicksCount(testErrors.size());481 int i=0;482 for (TestError error: testErrors) {483 i++;484 monitor.subTask(tr("Fixing ({0}/{1}): ''{2}''", i, testErrors.size(),error.getMessage()));485 if (this.canceled)486 return;487 final Command fixCommand = error.getFix();454 private Collection<TestError> testErrors; 455 private boolean canceled; 456 private LinkedList<Command> fixCommands; 457 458 459 public FixTask(Collection<TestError> testErrors) { 460 super(tr("Fixing errors ..."), false /* don't ignore exceptions */); 461 this.testErrors = testErrors == null ? new ArrayList<TestError> (): testErrors; 462 fixCommands = new LinkedList<Command>(); 463 } 464 465 @Override 466 protected void cancel() { 467 this.canceled = true; 468 } 469 470 @Override 471 protected void finish() { 472 // do nothing 473 } 474 475 @Override 476 protected void realRun() throws SAXException, IOException, 477 OsmTransferException { 478 ProgressMonitor monitor = getProgressMonitor(); 479 try { 480 monitor.setTicksCount(testErrors.size()); 481 int i=0; 482 for (TestError error: testErrors) { 483 i++; 484 monitor.subTask(tr("Fixing ({0}/{1}): ''{2}''", i, testErrors.size(),error.getMessage())); 485 if (this.canceled) 486 return; 487 final Command fixCommand = error.getFix(); 488 488 if (fixCommand != null) { 489 fixCommands.add(fixCommand);490 SwingUtilities.invokeAndWait(491 new Runnable() {492 public void run() {493 Main.main.undoRedo.addNoRedraw(fixCommand);494 }495 }496 );489 fixCommands.add(fixCommand); 490 SwingUtilities.invokeAndWait( 491 new Runnable() { 492 public void run() { 493 Main.main.undoRedo.addNoRedraw(fixCommand); 494 } 495 } 496 ); 497 497 error.setIgnored(true); 498 498 } 499 499 monitor.worked(1); 500 } 501 monitor.subTask(tr("Updating map ..."));502 SwingUtilities.invokeAndWait(new Runnable() {503 public void run() {504 Main.main.undoRedo.afterAdd();505 Main.map.repaint();506 tree.resetErrors();507 Main.main.getCurrentDataSet().fireSelectionChanged();508 }509 });510 } catch(InterruptedException e) {511 // FIXME: signature of realRun should have a generic checked exception we512 // could throw here513 throw new RuntimeException(e);514 } catch(InvocationTargetException e) {515 throw new RuntimeException(e);516 } finally {517 monitor.finishTask();518 } 519 }500 } 501 monitor.subTask(tr("Updating map ...")); 502 SwingUtilities.invokeAndWait(new Runnable() { 503 public void run() { 504 Main.main.undoRedo.afterAdd(); 505 Main.map.repaint(); 506 tree.resetErrors(); 507 Main.main.getCurrentDataSet().fireSelectionChanged(); 508 } 509 }); 510 } catch(InterruptedException e) { 511 // FIXME: signature of realRun should have a generic checked exception we 512 // could throw here 513 throw new RuntimeException(e); 514 } catch(InvocationTargetException e) { 515 throw new RuntimeException(e); 516 } finally { 517 monitor.finishTask(); 518 } 519 } 520 520 } 521 521 }
Note:
See TracChangeset
for help on using the changeset viewer.
