Changeset 2716 in josm
- Timestamp:
- 2009-12-31T00:25:21+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r2711 r2716 688 688 } 689 689 690 /** 691 * Sort the relation members by the way they are linked. 692 */ 693 void sort() { 694 RelationNodeMap map = new RelationNodeMap(members); 695 690 /* 691 * Sort a collection of relation members by the way they are linked. 692 * 693 * @param relationMembers collection of relation members 694 * @return sorted collection of relation members 695 */ 696 private ArrayList<RelationMember> sortMembers(ArrayList<RelationMember> relationMembers) { 697 RelationNodeMap map = new RelationNodeMap(relationMembers); 696 698 // List of groups of linked members 697 699 // … … 722 724 group.addFirst(next); 723 725 } 724 725 726 } 726 727 … … 732 733 for (LinkedList<Integer> tmpGroup : allGroups) { 733 734 for (Integer p : tmpGroup) { 734 newMembers.add(members.get(p)); 735 newMembers.add(relationMembers.get(p)); 736 } 737 } 738 return newMembers; 739 } 740 741 /** 742 * Sort the relation members by the way they are linked. 743 */ 744 void sort() { 745 ArrayList<RelationMember> selectedMembers = new ArrayList<RelationMember>(getSelectedMembers()); 746 ArrayList<RelationMember> sortedMembers = null; 747 ArrayList<RelationMember> newMembers; 748 if (selectedMembers.isEmpty()) { 749 newMembers = sortMembers(members); 750 } else { 751 sortedMembers = sortMembers(selectedMembers); 752 List<Integer> selectedIndices = getSelectedIndices(); 753 newMembers = new ArrayList<RelationMember>(); 754 boolean inserted = false; 755 for (int i=0; i < members.size(); i++) { 756 if (selectedIndices.contains(i)) { 757 if (!inserted) { 758 newMembers.addAll(sortedMembers); 759 inserted = true; 760 } 761 } else { 762 newMembers.add(members.get(i)); 763 } 735 764 } 736 765 } … … 741 770 members.addAll(newMembers); 742 771 fireTableDataChanged(); 772 setSelectedMembers(sortedMembers); 743 773 } 744 774
Note:
See TracChangeset
for help on using the changeset viewer.