Ignore:
Timestamp:
2009-09-04T19:47:18+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3393: loooong delay when using presets with a large osm file
Initializing only one cache for autocompletion; now initializing in background thread, preset dialog should pop up immediately

File:
1 edited

Legend:

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

    r2048 r2055  
    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
    7079    public static abstract class Item {
    7180        protected void initAutoCompletionField(AutoCompletingTextField field, String key) {
    7281            OsmDataLayer layer = Main.main.getEditLayer();
    7382            if (layer == null) return;
    74             AutoCompletionCache cache = AutoCompletionCache.getCacheForLayer(layer);
    75             AutoCompletionList list = new AutoCompletionList();
    76             cache.populateWithValues(list, false /* don't append */);
    77             field.setAutoCompletionList(list);
     83            field.setAutoCompletionList(getPresetAutocompletionList());
    7884        }
    7985
     
    640646    }
    641647
     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    }
    642660    public PresetPanel createPanel(Collection<OsmPrimitive> selected) {
    643661        if (data == null)
     
    645663        OsmDataLayer layer = Main.main.getEditLayer();
    646664        if (layer != null) {
    647             AutoCompletionCache.getCacheForLayer(layer).initFromDataSet();
     665            refreshAutocompletionList(layer);
    648666        }
    649667        PresetPanel p = new PresetPanel();
Note: See TracChangeset for help on using the changeset viewer.