diff --git a/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java b/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
index 96dd026..36df02c 100644
a
|
b
|
public class TaggingPreset extends AbstractAction implements MapView.LayerChange
|
274 | 274 | return null; |
275 | 275 | } |
276 | 276 | |
| 277 | static boolean presetInitiallyMatches = false; |
| 278 | |
277 | 279 | @Override |
278 | 280 | public void actionPerformed(ActionEvent e) { |
279 | 281 | if (Main.main == null) return; |
280 | 282 | if (Main.main.getCurrentDataSet() == null) return; |
281 | 283 | |
282 | 284 | Collection<OsmPrimitive> sel = createSelection(Main.main.getCurrentDataSet().getSelected()); |
| 285 | presetInitiallyMatches = !sel.isEmpty() && Utils.forAll(sel, this); |
283 | 286 | int answer = showDialog(sel, supportsRelation()); |
284 | 287 | |
285 | 288 | if (!sel.isEmpty() && answer == DIALOG_ANSWER_APPLY) { |
diff --git a/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java b/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
index da1b136..852da09 100644
a
|
b
|
public final class TaggingPresetItems {
|
596 | 596 | } |
597 | 597 | else if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) { |
598 | 598 | // 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) { |
600 | 600 | textField.setText(lastValue.get(key)); |
601 | 601 | } else { |
602 | 602 | textField.setText(default_); |
… |
… |
public final class TaggingPresetItems {
|
1226 | 1226 | } else if (usage.unused()) { |
1227 | 1227 | // all items were unset (and so is default) |
1228 | 1228 | 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) { |
1230 | 1230 | combo.setSelectedItem(lhm.get(lastValue.get(key))); |
1231 | 1231 | } else { |
1232 | 1232 | combo.setSelectedItem(originalValue); |
diff --git a/src/org/openstreetmap/josm/tools/Utils.java b/src/org/openstreetmap/josm/tools/Utils.java
index 67f5ae4..3307859 100644
a
|
b
|
public final class Utils {
|
64 | 64 | */ |
65 | 65 | public static final Charset UTF_8 = Charset.forName("UTF-8"); |
66 | 66 | |
| 67 | /** |
| 68 | * Tests whether {@code predicate} applies to at least one elements from {@code collection}. |
| 69 | */ |
67 | 70 | public static <T> boolean exists(Iterable<? extends T> collection, Predicate<? super T> predicate) { |
68 | 71 | for (T item : collection) { |
69 | 72 | if (predicate.evaluate(item)) |
… |
… |
public final class Utils {
|
72 | 75 | return false; |
73 | 76 | } |
74 | 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)); |
| 83 | } |
| 84 | |
75 | 85 | public static <T> boolean exists(Iterable<T> collection, Class<? extends T> klass) { |
76 | 86 | for (Object item : collection) { |
77 | 87 | if (klass.isInstance(item)) |