- Timestamp:
- 2009-11-19T18:09:12+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r2471 r2484 39 39 */ 40 40 private Set<Long> childrenToMerge; 41 42 41 private Set<OsmPrimitive> deletedObjectsToUnlink; 43 42 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2474 r2484 602 602 } 603 603 604 public void addRelations(Collection<? extends OsmPrimitive> addedPrimitives) { 605 if (addedPrimitives == null || addedPrimitives.isEmpty()) return; 606 boolean added = false; 607 for (OsmPrimitive p: addedPrimitives) { 608 if (! (p instanceof Relation)) { 609 continue; 610 } 611 if (relations.contains(p)) { 612 continue; 613 } 614 relations.add((Relation)p); 615 added = true; 616 } 617 if (added) { 618 fireIntervalAdded(this, 0, getSize()); 619 } 620 } 621 604 622 public Object getElementAt(int index) { 605 623 if (relations == null) return null; … … 681 699 682 700 public void primtivesAdded(Collection<? extends OsmPrimitive> added) { 683 updateList();701 model.addRelations(added); 684 702 } 685 703 … … 689 707 690 708 public void relationMembersChanged(Relation r) { 691 updateList(); 709 // trigger a repaint of the relation list 710 displaylist.repaint(); 692 711 } 693 712 694 713 public void tagsChanged(OsmPrimitive prim) { 695 714 if (prim instanceof Relation) { 696 updateList(); 715 // trigger a repaint of the relation list 716 displaylist.repaint(); 697 717 } 698 718 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2434 r2484 56 56 import org.openstreetmap.josm.data.conflict.Conflict; 57 57 import org.openstreetmap.josm.data.osm.DataSet; 58 import org.openstreetmap.josm.data.osm.DataSetMerger;59 import org.openstreetmap.josm.data.osm.DataSource;60 58 import org.openstreetmap.josm.data.osm.OsmPrimitive; 61 59 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 1379 1377 public static class DownloadTask extends PleaseWaitRunnable { 1380 1378 private boolean cancelled; 1381 private int conflictsCount;1382 1379 private Exception lastException; 1383 1380 private List<Relation> relations; … … 1386 1383 1387 1384 public DownloadTask(List<Relation> relations, OsmDataLayer curLayer, MemberTableModel memberTableModel, Dialog parent) { 1388 super(tr("Download relation members"), new PleaseWaitProgressMonitor(parent), false /* 1389 * don't 1390 * ignore 1391 * exception 1392 */); 1385 super(tr("Download relation members"), new PleaseWaitProgressMonitor(parent), false /* don't ignore exception */); 1393 1386 this.relations = relations; 1394 1387 this.curLayer = curLayer; … … 1397 1390 1398 1391 public DownloadTask(List<Relation> relations, OsmDataLayer curLayer, MemberTableModel memberTableModel) { 1399 super(tr("Download relation members"), new PleaseWaitProgressMonitor(), false /* 1400 * don't 1401 * ignore 1402 * exception 1403 */); 1392 super(tr("Download relation members"), new PleaseWaitProgressMonitor(), false /* don't ignore exception */); 1404 1393 this.relations = relations; 1405 1394 this.curLayer = curLayer; … … 1424 1413 ExceptionDialogUtil.explainException(lastException); 1425 1414 } 1426 1427 if (conflictsCount > 0) {1428 JOptionPane.showMessageDialog(1429 Main.parent,1430 tr("There were {0} conflicts during import.", conflictsCount),1431 tr("Warning"),1432 JOptionPane.WARNING_MESSAGE1433 );1434 }1435 1415 } 1436 1416 … … 1438 1418 protected void realRun() throws SAXException, IOException, OsmTransferException { 1439 1419 try { 1440 boolean changed = false;1441 1420 for (Relation relation : relations) { 1442 1421 progressMonitor.indeterminateSubTask(""); 1443 1422 OsmServerObjectReader reader = new OsmServerObjectReader(relation.getId(), OsmPrimitiveType.RELATION, 1444 1423 true); 1445 DataSet dataSet = reader.parseOsm(progressMonitor1424 final DataSet dataSet = reader.parseOsm(progressMonitor 1446 1425 .createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 1447 if (dataSet != null) { 1448 changed = true; 1449 final DataSetMerger visitor = new DataSetMerger(curLayer.data, dataSet); 1450 visitor.merge(); 1451 1452 // copy the merged layer's data source info 1453 for (DataSource src : dataSet.dataSources) { 1454 curLayer.data.dataSources.add(src); 1455 } 1456 if (!visitor.getConflicts().isEmpty()) { 1457 curLayer.getConflicts().add(visitor.getConflicts()); 1458 conflictsCount = visitor.getConflicts().size(); 1459 } 1460 } 1461 } 1462 // FIXME: this is necessary because there are dialogs listening 1463 // for DataChangeEvents which manipulate Swing components on this 1464 // thread. 1465 // 1466 if (changed) { 1467 SwingUtilities.invokeLater(new Runnable() { 1468 public void run() { 1469 curLayer.fireDataChange(); 1470 curLayer.onPostDownloadFromServer(); 1471 } 1472 }); 1426 if (dataSet == null) 1427 return; 1428 // has to run on the EDT because mergeFrom may trigger events 1429 // which update the UI 1430 // 1431 SwingUtilities.invokeAndWait( 1432 new Runnable() { 1433 public void run() { 1434 curLayer.mergeFrom(dataSet); 1435 curLayer.fireDataChange(); 1436 curLayer.onPostDownloadFromServer(); 1437 } 1438 } 1439 ); 1440 1473 1441 } 1474 1442 } catch (Exception e) { -
trunk/src/org/openstreetmap/josm/io/OsmServerObjectReader.java
r2070 r2484 34 34 InputStream in = null; 35 35 try { 36 progressMonitor. subTask(tr("Downloading OSM data..."));36 progressMonitor.indeterminateSubTask(tr("Downloading OSM data...")); 37 37 StringBuffer sb = new StringBuffer(); 38 38 sb.append(type.getAPIName());
Note:
See TracChangeset
for help on using the changeset viewer.