Changeset 2494 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-11-21T20:13:15+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2484 r2494 76 76 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache; 77 77 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 78 import org.openstreetmap.josm.io.Osm Api;78 import org.openstreetmap.josm.io.OsmServerBackreferenceReader; 79 79 import org.openstreetmap.josm.io.OsmServerObjectReader; 80 80 import org.openstreetmap.josm.io.OsmTransferException; … … 87 87 * 88 88 */ 89 public class GenericRelationEditor extends RelationEditor {89 public class GenericRelationEditor extends RelationEditor { 90 90 91 91 static private final Logger logger = Logger.getLogger(GenericRelationEditor.class.getName()); … … 1381 1381 private OsmDataLayer curLayer; 1382 1382 private MemberTableModel memberTableModel; 1383 private OsmServerObjectReader objectReader; 1384 private OsmServerBackreferenceReader parentReader; 1383 1385 1384 1386 public DownloadTask(List<Relation> relations, OsmDataLayer curLayer, MemberTableModel memberTableModel, Dialog parent) { … … 1399 1401 protected void cancel() { 1400 1402 cancelled = true; 1401 OsmApi.getOsmApi().cancel(); 1403 synchronized(this) { 1404 if (objectReader != null) { 1405 objectReader.cancel(); 1406 } else if (parentReader != null) { 1407 parentReader.cancel(); 1408 } 1409 } 1402 1410 } 1403 1411 … … 1419 1427 try { 1420 1428 for (Relation relation : relations) { 1421 progressMonitor.indeterminateSubTask(""); 1422 OsmServerObjectReader reader = new OsmServerObjectReader(relation.getId(), OsmPrimitiveType.RELATION, 1423 true); 1424 final DataSet dataSet = reader.parseOsm(progressMonitor 1429 // download the relation 1430 // 1431 progressMonitor.indeterminateSubTask(tr("Downloading relation ''{0}''", relation.getDisplayName(DefaultNameFormatter.getInstance()))); 1432 synchronized(this) { 1433 if (cancelled) return; 1434 objectReader = new OsmServerObjectReader(relation.getId(), OsmPrimitiveType.RELATION, true /* full download */); 1435 } 1436 final DataSet dataSet = objectReader.parseOsm(progressMonitor 1425 1437 .createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 1426 1438 if (dataSet == null) 1427 1439 return; 1440 synchronized (this) { 1441 if (cancelled) return; 1442 objectReader = null; 1443 } 1444 1445 // download referring objects of the downloaded member objects 1446 // 1447 // asked for in #3999, but uncommented for the time being. Could be used 1448 // later, perhaps if user explicity requests so (for instance by checking 1449 // a checkbox) 1450 // for (OsmPrimitive p: relation.getMemberPrimitives()) { 1451 // synchronized(this) { 1452 // if (cancelled) return; 1453 // parentReader = new OsmServerBackreferenceReader(p); 1454 // } 1455 // DataSet parents = parentReader.parseOsm(progressMonitor.createSubTaskMonitor(1, false)); 1456 // synchronized(this) { 1457 // if (cancelled) return; 1458 // parentReader = null; 1459 // } 1460 // DataSetMerger merger = new DataSetMerger(dataSet, parents); 1461 // merger.merge(); 1462 // } 1463 // if (cancelled) return; 1464 1428 1465 // has to run on the EDT because mergeFrom may trigger events 1429 1466 // which update the UI … … 1438 1475 } 1439 1476 ); 1440 1441 1477 } 1442 1478 } catch (Exception e) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r2421 r2494 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.dialogs.relation; 3 4 import static org.openstreetmap.josm.gui.dialogs.relation.WayConnectionType.Direction.BACKWARD; 5 import static org.openstreetmap.josm.gui.dialogs.relation.WayConnectionType.Direction.FORWARD; 6 import static org.openstreetmap.josm.gui.dialogs.relation.WayConnectionType.Direction.NONE; 7 import static org.openstreetmap.josm.gui.dialogs.relation.WayConnectionType.Direction.ROUNDABOUT_LEFT; 8 import static org.openstreetmap.josm.gui.dialogs.relation.WayConnectionType.Direction.ROUNDABOUT_RIGHT; 3 9 4 10 import java.util.ArrayList; … … 11 17 import java.util.List; 12 18 import java.util.Set; 13 import java.util.Vector;14 19 import java.util.concurrent.CopyOnWriteArrayList; 15 20 16 21 import javax.swing.DefaultListSelectionModel; 17 22 import javax.swing.ListSelectionModel; 23 import javax.swing.event.TableModelEvent; 24 import javax.swing.event.TableModelListener; 18 25 import javax.swing.table.AbstractTableModel; 19 import javax.swing.event.TableModelListener;20 import javax.swing.event.TableModelEvent;21 26 22 27 import org.openstreetmap.josm.Main; … … 30 35 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 31 36 32 import static org.openstreetmap.josm.gui.dialogs.relation.WayConnectionType.Direction.*;33 34 37 public class MemberTableModel extends AbstractTableModel implements TableModelListener { 35 38 … … 39 42 private ArrayList<RelationMember> members; 40 43 private ArrayList<WayConnectionType> connectionType = null; 41 44 42 45 private DefaultListSelectionModel listSelectionModel; 43 46 private CopyOnWriteArrayList<IMemberModelListener> listeners; … … 98 101 public Object getValueAt(int rowIndex, int columnIndex) { 99 102 switch (columnIndex) { 100 101 102 103 104 105 103 case 0: 104 return members.get(rowIndex).getRole(); 105 case 1: 106 return members.get(rowIndex).getMember(); 107 case 2: 108 return wayConnection(rowIndex); 106 109 } 107 110 // should not happen … … 582 585 // current group of members that are linked among each other 583 586 // Two successive members are always linked i.e. have a common node. 584 // 587 // 585 588 LinkedList<Integer> group; 586 589 … … 619 622 620 623 if (members.size() != newMembers.size()) throw new AssertionError(); 621 624 622 625 members.clear(); 623 626 members.addAll(newMembers); … … 638 641 **/ 639 642 private Direction determineDirection(int ref_i,Direction ref_direction, int k) { 640 if (ref_i < 0 || k < 0 || ref_i >= members.size() || k >= members.size()) {643 if (ref_i < 0 || k < 0 || ref_i >= members.size() || k >= members.size()) 641 644 return NONE; 642 } 643 if (ref_direction == NONE) { 645 if (ref_direction == NONE) 644 646 return NONE; 645 } 646 647 647 648 RelationMember m_ref = members.get(ref_i); 648 649 RelationMember m = members.get(k); … … 656 657 way = m.getWay(); 657 658 } 658 659 if (way_ref == null || way == null) {659 660 if (way_ref == null || way == null) 660 661 return NONE; 661 }662 662 663 663 /** the list of nodes the way k can dock to */ … … 665 665 666 666 switch (ref_direction) { 667 668 669 670 671 672 673 674 675 676 677 } 678 679 if (refNodes == null) {667 case FORWARD: 668 refNodes.add(way_ref.lastNode()); 669 break; 670 case BACKWARD: 671 refNodes.add(way_ref.firstNode()); 672 break; 673 case ROUNDABOUT_LEFT: 674 case ROUNDABOUT_RIGHT: 675 refNodes = way_ref.getNodes(); 676 break; 677 } 678 679 if (refNodes == null) 680 680 return NONE; 681 }682 681 683 682 for (Node n : refNodes) { 684 if (n == null) continue; 683 if (n == null) { 684 continue; 685 } 685 686 if (roundaboutType(k) != NONE) { 686 687 for (Node nn : way.getNodes()) { 687 if (n == nn) {688 if (n == nn) 688 689 return roundaboutType(k); 689 }690 690 } 691 691 } else { 692 if (n == way.firstNode()) {692 if (n == way.firstNode()) 693 693 return FORWARD; 694 } 695 if (n == way.lastNode()) { 694 if (n == way.lastNode()) 696 695 return BACKWARD; 697 }698 696 } 699 697 } … … 749 747 ArrayList<WayConnectionType> con = new ArrayList<WayConnectionType>(); 750 748 751 for (int i=0; i<members.size(); ++i) con.add(null); 749 for (int i=0; i<members.size(); ++i) { 750 con.add(null); 751 } 752 752 753 753 int firstGroupIdx=0; … … 796 796 } 797 797 } 798 798 799 799 } 800 800 … … 817 817 } 818 818 connectionType = con; 819 // for (int i=0; i<con.size(); ++i) {820 // System.err.println(con.get(i));821 // }819 // for (int i=0; i<con.size(); ++i) { 820 // System.err.println(con.get(i)); 821 // } 822 822 } 823 823 }
Note:
See TracChangeset
for help on using the changeset viewer.