Changeset 6772 in josm


Ignore:
Timestamp:
2014-01-29T21:14:07+01:00 (11 years ago)
Author:
simon04
Message:

fix #8413 - Presets: no not apply use_last_as_default when calling the preset dialog on an object with some tags of this preset already set

This avoids wrongs address tags when using the address preset.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r6738 r6772  
    275275    }
    276276
     277    static boolean presetInitiallyMatches = false;
     278
    277279    @Override
    278280    public void actionPerformed(ActionEvent e) {
     
    281283
    282284        Collection<OsmPrimitive> sel = createSelection(Main.main.getCurrentDataSet().getSelected());
     285        presetInitiallyMatches = !sel.isEmpty() && Utils.forAll(sel, this);
    283286        int answer = showDialog(sel, supportsRelation());
    284287
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java

    r6699 r6772  
    597597                else if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) {
    598598                    // selected osm primitives are untagged or filling default values feature is enabled
    599                     if (!"false".equals(use_last_as_default) && lastValue.containsKey(key)) {
     599                    if (!"false".equals(use_last_as_default) && lastValue.containsKey(key) && !TaggingPreset.presetInitiallyMatches) {
    600600                        textField.setText(lastValue.get(key));
    601601                    } else {
     
    12271227                // all items were unset (and so is default)
    12281228                originalValue = lhm.get("");
    1229                 if ("force".equals(use_last_as_default) && lastValue.containsKey(key)) {
     1229                if ("force".equals(use_last_as_default) && lastValue.containsKey(key) && !TaggingPreset.presetInitiallyMatches) {
    12301230                    combo.setSelectedItem(lhm.get(lastValue.get(key)));
    12311231                } else {
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6749 r6772  
    6565    public static final Charset UTF_8 = Charset.forName("UTF-8");
    6666
     67    /**
     68     * Tests whether {@code predicate} applies to at least one elements from {@code collection}.
     69     */
    6770    public static <T> boolean exists(Iterable<? extends T> collection, Predicate<? super T> predicate) {
    6871        for (T item : collection) {
     
    7174        }
    7275        return false;
     76    }
     77
     78    /**
     79     * Tests whether {@code predicate} applies to all elements from {@code collection}.
     80     */
     81    public static <T> boolean forAll(Iterable<? extends T> collection, Predicate<? super T> predicate) {
     82        return !exists(collection, Predicates.not(predicate));
    7383    }
    7484
Note: See TracChangeset for help on using the changeset viewer.