Ignore:
Timestamp:
09.09.2009 19:38:48 (3 years ago)
Author:
Gubaer
Message:

see #3393: loooong delay when using presets with a large osm file

File:
1 edited

Legend:

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

    r2055 r2088  
    6868    public String locale_name; 
    6969 
    70     private static AutoCompletionList autoCompletionList; 
    71  
    72     public static AutoCompletionList getPresetAutocompletionList() { 
    73         if (autoCompletionList == null) { 
    74             autoCompletionList = new AutoCompletionList(); 
    75         } 
    76         return autoCompletionList; 
    77     } 
    78  
    7970    public static abstract class Item { 
    8071        protected void initAutoCompletionField(AutoCompletingTextField field, String key) { 
    8172            OsmDataLayer layer = Main.main.getEditLayer(); 
    8273            if (layer == null) return; 
    83             field.setAutoCompletionList(getPresetAutocompletionList()); 
     74            AutoCompletionList list  = new AutoCompletionList(); 
     75            List<String> values = AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).getValues(key); 
     76            list.add(values,AutoCompletionItemPritority.IS_IN_DATASET); 
     77            field.setAutoCompletionList(list); 
    8478        } 
    8579 
     
    154148            // find out if our key is already used in the selection. 
    155149            Usage usage = determineTextUsage(sel, key); 
     150            AutoCompletingTextField textField = new AutoCompletingTextField(); 
     151            initAutoCompletionField(textField, key); 
    156152            if (usage.unused()){ 
    157                 AutoCompletingTextField textField = new AutoCompletingTextField(); 
    158                 initAutoCompletionField(textField, key); 
    159153                if (use_last_as_default && lastValue.containsKey(key)) { 
    160154                    textField.setText(lastValue.get(key)); 
     
    166160            } else if (usage.hasUniqueValue()) { 
    167161                // all objects use the same value 
    168                 AutoCompletingTextField textField = new AutoCompletingTextField(); 
    169                 initAutoCompletionField(textField, key); 
    170162                textField.setText(usage.getFirst()); 
    171163                value = textField; 
     
    173165            } else { 
    174166                // the objects have different values 
    175                 AutoCompletingTextField textField = new AutoCompletingTextField(); 
    176                 initAutoCompletionField(textField, key); 
    177167                JComboBox comboBox = new JComboBox(usage.values.toArray()); 
    178168                comboBox.setEditable(true); 
     
    646636    } 
    647637 
    648     protected void refreshAutocompletionList(final OsmDataLayer layer) { 
    649         Runnable task = new Runnable() { 
    650             public void run() { 
    651                 System.out.print("refreshing preset auto completion list ..."); 
    652                 AutoCompletionCache.getCacheForLayer(layer).initFromDataSet(); 
    653                 AutoCompletionCache.getCacheForLayer(layer).populateWithValues( getPresetAutocompletionList(), false /* don't append */); 
    654                 System.out.println("DONE"); 
    655             } 
    656         }; 
    657         new Thread(task).run(); 
    658  
    659     } 
    660638    public PresetPanel createPanel(Collection<OsmPrimitive> selected) { 
    661639        if (data == null) 
     
    663641        OsmDataLayer layer = Main.main.getEditLayer(); 
    664642        if (layer != null) { 
    665             refreshAutocompletionList(layer); 
     643            AutoCompletionCache.getCacheForLayer(layer).initFromDataSet(); 
    666644        } 
    667645        PresetPanel p = new PresetPanel(); 
Note: See TracChangeset for help on using the changeset viewer.