- Timestamp:
- 2014-11-23T22:25:29+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/relation/AddSelectionToRelations.java
r7005 r7742 19 19 import org.openstreetmap.josm.tools.ImageProvider; 20 20 21 21 /** 22 * Add all objects selected in the current dataset after the last member of relation(s). 23 * @since 5799 24 */ 22 25 public class AddSelectionToRelations extends AbstractRelationAction implements SelectionChangedListener { 23 26 /** -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r7601 r7742 737 737 } 738 738 739 /** 740 * Adds primitives to a given relation. 741 * @param orig The relation to modify 742 * @param primitivesToAdd The primitives to add as relation members 743 * @return The resulting command 744 * @throws IllegalArgumentException if orig is null 745 */ 739 746 public static Command addPrimitivesToRelation(final Relation orig, Collection<? extends OsmPrimitive> primitivesToAdd) 740 747 throws IllegalArgumentException { … … 753 760 continue; 754 761 } 755 final S tring role = presets.isEmpty() ? null : presets.iterator().next().suggestRoleForOsmPrimitive(p);756 relation.addMember(new RelationMember(role == null ? "" : role, p));762 final Set<String> roles = findSuggestedRoles(presets, p); 763 relation.addMember(new RelationMember(roles.size() == 1 ? roles.iterator().next() : "", p)); 757 764 modified = true; 758 765 } … … 761 768 return null; 762 769 } 770 } 771 772 protected static Set<String> findSuggestedRoles(final Collection<TaggingPreset> presets, OsmPrimitive p) { 773 final Set<String> roles = new HashSet<>(); 774 for (TaggingPreset preset : presets) { 775 String role = preset.suggestRoleForOsmPrimitive(p); 776 if (role != null && !role.isEmpty()) { 777 roles.add(role); 778 } 779 } 780 return roles; 763 781 } 764 782
Note:
See TracChangeset
for help on using the changeset viewer.