Changeset 16045 in josm


Ignore:
Timestamp:
2020-03-06T00:23:37+01:00 (5 years ago)
Author:
simon04
Message:

see #18864 - TaggingPreset: use byte for use_last_as_default field, use boolean for values_searchable field

Reduces retained size of TaggingPreset from 1_667_448 to 1_663_120 (de).

Location:
trunk/src/org/openstreetmap/josm/gui/tagging/presets
Files:
4 edited

Legend:

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

    r15926 r16045  
    109109                    if (item instanceof ComboMultiSelect) {
    110110                        final ComboMultiSelect cms = (ComboMultiSelect) item;
    111                         if (Boolean.parseBoolean(cms.values_searchable)) {
     111                        if (cms.values_searchable) {
    112112                            tagSet.addAll(cms.getDisplayValues());
    113113                        }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java

    r16043 r16045  
    7474        } else if (def != null && usage.unused()) {
    7575            // default is set and all items were unset
    76             if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) {
     76            if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || isForceUseLastAsDefault()) {
    7777                // selected osm primitives are untagged or filling default feature is enabled
    7878                combobox.setSelectedItem(lhm.get(def).getDisplayValue(true));
     
    8585            // all items were unset (and so is default)
    8686            originalValue = lhm.get("");
    87             if (!presetInitiallyMatches && "force".equals(use_last_as_default) && LAST_VALUES.containsKey(key)) {
     87            if (!presetInitiallyMatches && isForceUseLastAsDefault() && LAST_VALUES.containsKey(key)) {
    8888                combobox.setSelectedItem(lhm.get(LAST_VALUES.get(key)));
    8989            } else {
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

    r16043 r16045  
    9191     */
    9292    public char delimiter = ';'; // NOSONAR
    93     /** whether the last value is used as default. Using "force" enforces this behaviour also for already tagged objects. Default is "false".*/
    94     public String use_last_as_default = "false"; // NOSONAR
     93    /** whether the last value is used as default. Using "force" (2) enforces this behaviour also for already tagged objects. Default is "false" (0).*/
     94    public byte use_last_as_default = 0; // NOSONAR
    9595    /** whether to use values for search via {@link TaggingPresetSelector} */
    96     public String values_searchable = "false"; // NOSONAR
     96    public boolean values_searchable = false; // NOSONAR
    9797
    9898    protected JComponent component;
     
    530530            return;
    531531
    532         if (!"false".equals(use_last_as_default)) {
     532        if (isUseLastAsDefault()) {
    533533            LAST_VALUES.put(key, value);
    534534        }
    535535        changedTags.add(new Tag(key, value));
     536    }
     537
     538    public void setUse_last_as_default(String v) {
     539        if ("force".equals(v)) {
     540            use_last_as_default = 2;
     541        } else if ("true".equals(v)) {
     542            use_last_as_default = 1;
     543        } else {
     544            use_last_as_default = 0;
     545        }
     546    }
     547
     548    protected boolean isUseLastAsDefault() {
     549        return use_last_as_default > 0;
     550    }
     551
     552    protected boolean isForceUseLastAsDefault() {
     553        return use_last_as_default == 2;
    536554    }
    537555
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/MultiSelect.java

    r16042 r16045  
    3434            originalValue = usage.getFirst();
    3535            list.setSelectedItem(originalValue);
    36         } else if ((def != null && !usage.hadKeys()) || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) {
     36        } else if ((def != null && !usage.hadKeys()) || PROP_FILL_DEFAULT.get() || isForceUseLastAsDefault()) {
    3737            originalValue = DIFFERENT;
    3838            list.setSelectedItem(def);
Note: See TracChangeset for help on using the changeset viewer.