Ignore:
Timestamp:
02.05.2010 18:12:34 (2 years ago)
Author:
bastiK
Message:

autocompletion cleanup - fixes #2729

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java

    r3213 r3214  
    109109 
    110110    protected void cachePrimitives(Collection<? extends OsmPrimitive> primitives) { 
    111         if (tagCache == null) { 
    112             // We are coming from a DataSetListener event and 
    113             // rebuild has not been called yet, so do it now and  
    114             // ignore the method parameter. 
    115             rebuild(); 
    116             return; 
    117         } 
    118111        for (OsmPrimitive primitive : primitives) { 
    119112            cachePrimitiveTags(primitive); 
     
    204197    } 
    205198 
    206     public TreeSet<String> getKeys(Comparator<String> c) { 
    207         TreeSet<String> ret = new TreeSet<String>(c); 
    208         ret.addAll(getDataKeys()); 
    209         ret.addAll(getPresetKeys()); 
    210         return ret; 
    211     } 
    212  
    213199    /** 
    214200     * replies the auto completion values allowed for a specific key. Replies 
     
    226212    } 
    227213 
    228     public TreeSet<String> getValues(String key, Comparator<String> c) { 
    229         TreeSet<String> ret = new TreeSet<String>(c); 
    230         ret.addAll(getDataValues(key)); 
    231         ret.addAll(getPresetValues(key)); 
    232         return ret; 
    233     } 
    234  
    235214    /** 
    236215     * Replies the list of member roles 
     
    249228     */ 
    250229    public void populateWithMemberRoles(AutoCompletionList list) { 
    251         list.clear(); 
    252230        list.add(getRoleCache(), AutoCompletionItemPritority.IS_IN_DATASET); 
     231    } 
     232 
     233    /** 
     234     * Populates the an {@see AutoCompletionList} with the currently cached 
     235     * tag keys 
     236     * 
     237     * @param list the list to populate 
     238     * @param append true to add the keys to the list; false, to replace the keys 
     239     * in the list by the keys in the cache 
     240     */ 
     241    public void populateWithKeys(AutoCompletionList list) { 
     242        list.add(getPresetKeys(), AutoCompletionItemPritority.IS_IN_STANDARD); 
     243        list.add(getDataKeys(), AutoCompletionItemPritority.IS_IN_DATASET); 
    253244    } 
    254245 
     
    263254     */ 
    264255    public void populateWithTagValues(AutoCompletionList list, String key) { 
     256        list.add(getPresetValues(key), AutoCompletionItemPritority.IS_IN_STANDARD); 
    265257        list.add(getDataValues(key), AutoCompletionItemPritority.IS_IN_DATASET); 
    266         list.add(getPresetValues(key), AutoCompletionItemPritority.IS_IN_STANDARD); 
    267     } 
    268  
    269     /** 
    270      * Populates the an {@see AutoCompletionList} with the currently cached 
    271      * tag keys 
    272      * 
    273      * @param list the list to populate 
    274      * @param append true to add the keys to the list; false, to replace the keys 
    275      * in the list by the keys in the cache 
    276      */ 
    277     public void populateWithKeys(AutoCompletionList list) { 
    278         list.add(getDataKeys(), AutoCompletionItemPritority.IS_IN_DATASET); 
    279         list.add(getPresetKeys(), AutoCompletionItemPritority.IS_IN_STANDARD); 
     258    } 
     259 
     260    public List<AutoCompletionListItem> getKeys() { 
     261        AutoCompletionList list = new AutoCompletionList(); 
     262        populateWithKeys(list); 
     263        return new ArrayList<AutoCompletionListItem>(list.getList()); 
     264    } 
     265 
     266    public List<AutoCompletionListItem> getValues(String key) { 
     267        AutoCompletionList list = new AutoCompletionList(); 
     268        populateWithTagValues(list, key); 
     269        return new ArrayList<AutoCompletionListItem>(list.getList()); 
    280270    } 
    281271 
     
    286276 
    287277    public void primtivesAdded(PrimitivesAddedEvent event) { 
     278        if (dirty) 
     279            return; 
    288280        cachePrimitives(event.getPrimitives()); 
    289281    } 
     
    294286 
    295287    public void tagsChanged(TagsChangedEvent event) { 
     288        if (dirty) 
     289            return; 
    296290        Map<String, String> newKeys = event.getPrimitive().getKeys(); 
    297291        Map<String, String> oldKeys = event.getOriginalKeys(); 
Note: See TracChangeset for help on using the changeset viewer.