Changeset 16688 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-06-21T09:54:48+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging/presets/items
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java
r16687 r16688 77 77 } 78 78 combobox.setEditor(tf); 79 combobox.setSelectedItem(getItemToSelect(def, presetInitiallyMatches)); 79 80 80 if (usage.hasUniqueValue()) {81 // all items have the same value (and there were no unset items)82 originalValue = getListEntry(usage.getFirst());83 combobox.setSelectedItem(originalValue);84 } else if (def != null && usage.unused()) {85 // default is set and all items were unset86 if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || isForceUseLastAsDefault()) {87 // selected osm primitives are untagged or filling default feature is enabled88 combobox.setSelectedItem(getListEntry(def).getDisplayValue());89 } else {90 // selected osm primitives are tagged and filling default feature is disabled91 combobox.setSelectedItem("");92 }93 originalValue = getListEntry(DIFFERENT);94 } else if (usage.unused()) {95 // all items were unset (and so is default)96 originalValue = getListEntry("");97 if (!presetInitiallyMatches && isUseLastAsDefault() && LAST_VALUES.containsKey(key)) {98 combobox.setSelectedItem(getListEntry(LAST_VALUES.get(key)));99 } else {100 combobox.setSelectedItem(originalValue);101 }102 } else {103 originalValue = getListEntry(DIFFERENT);104 combobox.setSelectedItem(originalValue);105 }106 81 if (key != null && ("colour".equals(key) || key.startsWith("colour:") || key.endsWith(":colour"))) { 107 82 p.add(combobox, GBC.std().fill(GBC.HORIZONTAL)); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
r16643 r16688 517 517 } 518 518 519 protected Object getItemToSelect(String def, boolean presetInitiallyMatches) { 520 final Object itemToSelect; 521 if (usage.hasUniqueValue()) { 522 // all items have the same value (and there were no unset items) 523 originalValue = getListEntry(usage.getFirst()); 524 itemToSelect = originalValue; 525 } else if (def != null && usage.unused()) { 526 // default is set and all items were unset 527 if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || isForceUseLastAsDefault()) { 528 // selected osm primitives are untagged or filling default feature is enabled 529 itemToSelect = getListEntry(def).getDisplayValue(); 530 } else { 531 // selected osm primitives are tagged and filling default feature is disabled 532 itemToSelect = ""; 533 } 534 originalValue = getListEntry(DIFFERENT); 535 } else if (usage.unused()) { 536 // all items were unset (and so is default) 537 originalValue = getListEntry(""); 538 if (!presetInitiallyMatches && isUseLastAsDefault() && LAST_VALUES.containsKey(key)) { 539 itemToSelect = getListEntry(LAST_VALUES.get(key)); 540 } else { 541 itemToSelect = originalValue; 542 } 543 } else { 544 originalValue = getListEntry(DIFFERENT); 545 itemToSelect = originalValue; 546 } 547 return itemToSelect; 548 } 549 519 550 protected String getSelectedValue() { 520 551 Object obj = getSelectedItem(); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/MultiSelect.java
r16687 r16688 30 30 ListCellRenderer<PresetListEntry> renderer = getListCellRenderer(); 31 31 list.setCellRenderer(renderer); 32 33 if (usage.hasUniqueValue() && !usage.unused()) { 34 originalValue = usage.getFirst(); 35 list.setSelectedItem(originalValue); 36 } else if ((def != null && !usage.hadKeys()) || PROP_FILL_DEFAULT.get() || isForceUseLastAsDefault()) { 37 originalValue = DIFFERENT; 38 list.setSelectedItem(def); 39 } else if (usage.unused()) { 40 originalValue = null; 41 if (!presetInitiallyMatches && isUseLastAsDefault() && LAST_VALUES.containsKey(key)) { 42 list.setSelectedItem(getListEntry(LAST_VALUES.get(key))); 43 } else { 44 list.setSelectedItem(originalValue); 45 } 46 } else { 47 originalValue = DIFFERENT; 48 list.setSelectedItem(originalValue); 49 } 32 list.setSelectedItem(getItemToSelect(def, presetInitiallyMatches)); 50 33 51 34 JScrollPane sp = new JScrollPane(list);
Note:
See TracChangeset
for help on using the changeset viewer.