Changeset 5972 in josm for trunk


Ignore:
Timestamp:
2013-05-29T00:21:13+02:00 (12 years ago)
Author:
Don-vip
Message:

see #8749 - use the automatic role suggestions when adding selection to a relation from context menu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r5903 r5972  
    2424import java.util.Collection;
    2525import java.util.Collections;
     26import java.util.EnumSet;
    2627import java.util.HashMap;
    2728import java.util.HashSet;
     
    8283import org.openstreetmap.josm.gui.tagging.TagEditorPanel;
    8384import org.openstreetmap.josm.gui.tagging.TagModel;
     85import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    8486import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
    8587import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
     
    753755    public static Command addPrimitivesToRelation(final Relation orig, Collection<? extends OsmPrimitive> primitivesToAdd) {
    754756        try {
     757            final Collection<TaggingPreset> presets = TaggingPreset.getMatchingPresets(EnumSet.of(TaggingPreset.PresetType.RELATION), orig.getKeys(), false);
    755758            Relation relation = new Relation(orig);
    756759            boolean modified = false;
     
    763766                    continue;
    764767                }
    765                 relation.addMember(new RelationMember("", p));
     768                final String role = presets.isEmpty() ? null : presets.iterator().next().suggestRoleForOsmPrimitive(p);
     769                relation.addMember(new RelationMember(role == null ? "" : role, p));
    766770                modified = true;
    767771            }
Note: See TracChangeset for help on using the changeset viewer.