Changeset 4300 in josm


Ignore:
Timestamp:
2011-08-08T00:26:59+02:00 (13 years ago)
Author:
stoecker
Message:

fix #6306 - patch by simon04 - enable autocompletion with name-values of highways for addr:street

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r4172 r4300  
    2323import java.net.URLEncoder;
    2424import java.util.ArrayList;
     25import java.util.Arrays;
    2526import java.util.Collection;
    2627import java.util.Collections;
     
    249250        values.setEditable(true);
    250251
    251         List<AutoCompletionListItem> valueList = autocomplete.getValues(key);
     252        List<AutoCompletionListItem> valueList = autocomplete.getValues(getAutocompletionKeys(key));
    252253        Collections.sort(valueList, defaultACItemComparator);
    253254
     
    369370
    370371    /**
     372     * For a given key k, return a list of keys which are used as keys for
     373     * auto-completing values to increase the search space.
     374     * @param key the key k
     375     * @return a list of keys
     376     */
     377    static List<String> getAutocompletionKeys(String key) {
     378        if ("name".equals(key) || "addr:street".equals(key)) {
     379            return Arrays.asList("addr:street", "name");
     380        } else {
     381            return Arrays.asList(key);
     382        }
     383    }
     384
     385    /**
    371386     * This simply fires up an relation editor for the relation shown; everything else
    372387     * is the editor's business.
     
    478493                String key = keys.getEditor().getItem().toString();
    479494
    480                 List<AutoCompletionListItem> valueList = autocomplete.getValues(key);
     495                List<AutoCompletionListItem> valueList = autocomplete.getValues(getAutocompletionKeys(key));
    481496                Collections.sort(valueList, defaultACItemComparator);
    482497
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionList.java

    r3214 r4300  
    258258    }
    259259
    260     List<AutoCompletionListItem> getList() {
     260    ArrayList<AutoCompletionListItem> getList() {
     261        return list;
     262    }
     263
     264    List<AutoCompletionListItem> getUnmodifiableList() {
    261265        return Collections.unmodifiableList(list);
    262266    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java

    r4223 r4300  
    33
    44import java.util.ArrayList;
     5import java.util.Arrays;
    56import java.util.Collection;
    67import java.util.Collections;
     
    243244     *
    244245     * @param list the list to populate
    245      * @param append true to add the keys to the list; false, to replace the keys
    246      * in the list by the keys in the cache
    247246     */
    248247    public void populateWithKeys(AutoCompletionList list) {
     
    257256     * @param list the list to populate
    258257     * @param key the tag key
    259      * @param append true to add the values to the list; false, to replace the values
    260      * in the list by the tag values
    261258     */
    262259    public void populateWithTagValues(AutoCompletionList list, String key) {
    263         list.add(getPresetValues(key), AutoCompletionItemPritority.IS_IN_STANDARD);
    264         list.add(getDataValues(key), AutoCompletionItemPritority.IS_IN_DATASET);
    265     }
    266 
     260        populateWithTagValues(list, Arrays.asList(key));
     261    }
     262
     263    /**
     264     * Populates the an {@see AutoCompletionList} with the currently cached
     265     * values for some given tags
     266     *
     267     * @param list the list to populate
     268     * @param key the tag keys
     269     */
     270    public void populateWithTagValues(AutoCompletionList list, List<String> keys) {
     271        for (String key : keys) {
     272            list.add(getPresetValues(key), AutoCompletionItemPritority.IS_IN_STANDARD);
     273            list.add(getDataValues(key), AutoCompletionItemPritority.IS_IN_DATASET);
     274        }
     275    }
     276
     277    /**
     278     * Returns the currently cached tag keys.
     279     * @return a list of tag keys
     280     */
    267281    public List<AutoCompletionListItem> getKeys() {
    268282        AutoCompletionList list = new AutoCompletionList();
    269283        populateWithKeys(list);
    270         return new ArrayList<AutoCompletionListItem>(list.getList());
    271     }
    272 
     284        return list.getList();
     285    }
     286
     287    /**
     288     * Returns the currently cached tag values for a given tag key.
     289     * @param key the tag key
     290     * @return a list of tag values
     291     */
    273292    public List<AutoCompletionListItem> getValues(String key) {
     293        return getValues(Arrays.asList(key));
     294    }
     295
     296    /**
     297     * Returns the currently cached tag values for a given list of tag keys.
     298     * @param keys the tag keys
     299     * @return a list of tag values
     300     */
     301    public List<AutoCompletionListItem> getValues(List<String> keys) {
    274302        AutoCompletionList list = new AutoCompletionList();
    275         populateWithTagValues(list, key);
    276         return new ArrayList<AutoCompletionListItem>(list.getList());
     303        populateWithTagValues(list, keys);
     304        return list.getList();
    277305    }
    278306
Note: See TracChangeset for help on using the changeset viewer.