Changeset 7118 in josm for trunk


Ignore:
Timestamp:
2014-05-13T13:39:24+02:00 (6 years ago)
Author:
simon04
Message:

fix #9901 - Presets: add support for alternative_autocomplete_keys, esp. auto-complete addr:street also from name

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/defaultpresets.xml

    r7116 r7118  
    5959  match: none/key/key!/keyvalue (default is "none", see below for more information)
    6060  length: length of input box (number of characters allowed)
     61  alternative_autocomplete_keys: comma separated list of alternative keys to use for autocompletion
    6162
    6263combo: combo box, with multiple choices and possible to enter free form text
     
    66826683            <text key="addr:housenumber" text="House number" match="key" auto_increment="-2,-1,+1,+2" />
    66836684            <optional>
    6684                 <text key="addr:housename" text="House name" match="key" />
    6685                 <text key="addr:street" text="Street name" use_last_as_default="force" match="key" />
     6685                <text key="addr:housename" text="House name" match="key" alternative_autocomplete_keys="name" />
     6686                <text key="addr:street" text="Street name" use_last_as_default="force" match="key" alternative_autocomplete_keys="name" />
    66866687                <text key="addr:city" text="City name" use_last_as_default="force" match="key" />
    66876688                <text key="addr:postcode" text="Post code" use_last_as_default="force" match="key" />
  • trunk/data/tagging-preset.xsd

    r6824 r7118  
    157157                <attribute name="match" type="tns:match" />
    158158                <attribute name="length" type="positiveInteger" />
     159                <attribute name="alternative_autocomplete_keys" type="string" />
    159160
    160161                <attribute name="type" use="prohibited" />
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItem.java

    r6795 r7118  
    22package org.openstreetmap.josm.gui.tagging;
    33
     4import java.util.Arrays;
    45import java.util.Collection;
    56import java.util.List;
     
    2122public abstract class TaggingPresetItem {
    2223
    23     protected void initAutoCompletionField(AutoCompletingTextField field, String key) {
     24    protected void initAutoCompletionField(AutoCompletingTextField field, String... key) {
     25        initAutoCompletionField(field, Arrays.asList(key));
     26    }
     27
     28    protected void initAutoCompletionField(AutoCompletingTextField field, List<String> keys) {
    2429        if (Main.main == null) return;
    2530        OsmDataLayer layer = Main.main.getEditLayer();
     
    2833        }
    2934        AutoCompletionList list = new AutoCompletionList();
    30         layer.data.getAutoCompletionManager().populateWithTagValues(list, key);
     35        layer.data.getAutoCompletionManager().populateWithTagValues(list, keys);
    3136        field.setAutoCompletionList(list);
    3237    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java

    r7100 r7118  
    577577        public String auto_increment;
    578578        public String length;
     579        public String alternative_autocomplete_keys;
    579580
    580581        private JComponent value;
     
    585586            Usage usage = determineTextUsage(sel, key);
    586587            AutoCompletingTextField textField = new AutoCompletingTextField();
    587             initAutoCompletionField(textField, key);
     588            if (alternative_autocomplete_keys != null) {
     589                initAutoCompletionField(textField, (key + "," + alternative_autocomplete_keys).split(","));
     590            } else {
     591                initAutoCompletionField(textField, key);
     592            }
    588593            if (length != null && !length.isEmpty()) {
    589594                textField.setMaxChars(Integer.valueOf(length));
Note: See TracChangeset for help on using the changeset viewer.