- Timestamp:
- 2021-10-09T15:05:34+02:00 (3 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging/presets
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItemGuiSupport.java
r18257 r18260 85 85 86 86 /** 87 * Returns true if all selected primitives matched this preset (before opening the dialog) 87 * Returns true if all selected primitives matched this preset (before opening the dialog). 88 * <p> 89 * This usually means that the preset dialog was opened from the Tags / Memberships panel as 90 * opposed to being opened by selection from the menu or toolbar or the search. 88 91 * 89 92 * @return true if the preset initially matched -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java
r18257 r18260 154 154 } 155 155 156 String valueToSelect = getInitialValue(usage); 157 if (valueToSelect != null) { 158 PresetListEntry selItem = find(valueToSelect); 159 if (selItem != null) { 160 combobox.setSelectedItem(selItem); 161 } else { 162 combobox.setText(valueToSelect); 163 } 164 } 156 String initialValue = getInitialValue(usage, support); 157 PresetListEntry selItem = find(initialValue); 158 if (selItem != null) { 159 combobox.setSelectedItem(selItem); 160 } else { 161 combobox.setText(initialValue); 162 } 163 165 164 combobox.addActionListener(l -> support.fireItemValueModified(this, key, getSelectedItem().value)); 166 165 combobox.addComponentListener(new ComponentListener()); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
r18258 r18260 23 23 24 24 import org.openstreetmap.josm.data.osm.Tag; 25 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 25 26 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector; 26 27 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; … … 94 95 protected final Map<String, PresetListEntry> seenValues = new TreeMap<>(); 95 96 protected Usage usage; 96 /** Used to see if the user edited the value. May be null.*/97 /** Used to see if the user edited the value. */ 97 98 protected String originalValue; 98 99 … … 318 319 * Returns the initial value to use for this preset. 319 320 * <p> 320 * The initial value is the value shown in the control when the preset dialogs opens. 321 * The initial value is the value shown in the control when the preset dialog opens. For a 322 * discussion of all the options see the enclosed tickets. 321 323 * 322 324 * @param usage The key Usage 325 * @param support The support 323 326 * @return The initial value to use. 324 */ 325 protected String getInitialValue(Usage usage) { 327 * 328 * @see "https://josm.openstreetmap.de/ticket/5564" 329 * @see "https://josm.openstreetmap.de/ticket/12733" 330 * @see "https://josm.openstreetmap.de/ticket/17324" 331 */ 332 protected String getInitialValue(Usage usage, TaggingPresetItemGuiSupport support) { 326 333 String initialValue = null; 327 originalValue = null;334 originalValue = ""; 328 335 329 336 if (usage.hasUniqueValue()) { … … 335 342 initialValue = DIFFERENT; 336 343 originalValue = initialValue; 337 } else if ( PROP_FILL_DEFAULT.get() || isForceUseLastAsDefault()) {344 } else if (!usage.hadKeys() || isForceUseLastAsDefault() || PROP_FILL_DEFAULT.get()) { 338 345 // at this point no primitive had any value for this key 339 // use the last value no matter what 340 initialValue = LAST_VALUES.get(key); 341 } else if (!usage.hadKeys() && isUseLastAsDefault()) { 342 // use the last value only on objects with no keys at all 343 initialValue = LAST_VALUES.get(key); 344 } else if (!usage.hadKeys()) { 345 // use the default only on objects with no keys at all 346 initialValue = default_; 347 } 348 return initialValue; 346 if (!support.isPresetInitiallyMatches() && isUseLastAsDefault() && LAST_VALUES.containsKey(key)) { 347 initialValue = LAST_VALUES.get(key); 348 } else { 349 initialValue = default_; 350 } 351 } 352 return initialValue != null ? initialValue : ""; 349 353 } 350 354 … … 354 358 355 359 // no change if same as before 356 if (value.isEmpty() && originalValue == null)357 return;358 360 if (value.equals(originalValue)) 359 361 return; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/MultiSelect.java
r18257 r18260 49 49 // disable if the selected primitives have different values 50 50 list.setEnabled(usage.hasUniqueValue() || usage.unused()); 51 String initialValue = getInitialValue(usage );51 String initialValue = getInitialValue(usage, support); 52 52 53 53 // Add values from the preset. … … 62 62 63 63 // Select the values in the initial value. 64 if ( initialValue != null&& !DIFFERENT.equals(initialValue)) {64 if (!initialValue.isEmpty() && !DIFFERENT.equals(initialValue)) { 65 65 for (String value : initialValue.split(String.valueOf(delimiter), -1)) { 66 66 PresetListEntry e = new PresetListEntry(value, this);
Note:
See TracChangeset
for help on using the changeset viewer.