Changeset 17876 in josm for trunk/src


Ignore:
Timestamp:
2021-05-06T22:37:43+02:00 (4 years ago)
Author:
simon04
Message:

fix #20851, see #20842 - Tagging presets: value_template="..." for conditional template

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/Tagged.java

    r17662 r17876  
    66import java.util.Map;
    77import java.util.Objects;
     8import java.util.stream.Collectors;
    89import java.util.stream.Stream;
    910
     
    234235    }
    235236
     237
     238    /**
     239     * Returns a Tagged instance for the given tag collection
     240     * @param tags the tag collection
     241     * @return a Tagged instance for the given tag collection
     242     */
     243    static Tagged ofTags(Collection<Tag> tags) {
     244        return ofMap(tags.stream().collect(Collectors.toMap(Tag::getKey, Tag::getValue, (a, b) -> a)));
     245    }
     246
    236247    /**
    237248     * Returns a Tagged instance for the given tag map
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItemGuiSupport.java

    r17875 r17876  
    44import org.openstreetmap.josm.data.osm.OsmPrimitive;
    55import org.openstreetmap.josm.data.osm.Tag;
     6import org.openstreetmap.josm.data.osm.Tagged;
    67import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    78import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem;
     
    107108    @Override
    108109    public boolean evaluateCondition(SearchCompiler.Match condition) {
    109         throw new UnsupportedOperationException();
     110        Tagged tagged = Tagged.ofTags(changedTagsSupplier.get());
     111        return condition.match(tagged);
    110112    }
    111113
Note: See TracChangeset for help on using the changeset viewer.