Changeset 2088 in josm for trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
- Timestamp:
- 09.09.2009 19:38:48 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r2055 r2088 68 68 public String locale_name; 69 69 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 79 70 public static abstract class Item { 80 71 protected void initAutoCompletionField(AutoCompletingTextField field, String key) { 81 72 OsmDataLayer layer = Main.main.getEditLayer(); 82 73 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); 84 78 } 85 79 … … 154 148 // find out if our key is already used in the selection. 155 149 Usage usage = determineTextUsage(sel, key); 150 AutoCompletingTextField textField = new AutoCompletingTextField(); 151 initAutoCompletionField(textField, key); 156 152 if (usage.unused()){ 157 AutoCompletingTextField textField = new AutoCompletingTextField();158 initAutoCompletionField(textField, key);159 153 if (use_last_as_default && lastValue.containsKey(key)) { 160 154 textField.setText(lastValue.get(key)); … … 166 160 } else if (usage.hasUniqueValue()) { 167 161 // all objects use the same value 168 AutoCompletingTextField textField = new AutoCompletingTextField();169 initAutoCompletionField(textField, key);170 162 textField.setText(usage.getFirst()); 171 163 value = textField; … … 173 165 } else { 174 166 // the objects have different values 175 AutoCompletingTextField textField = new AutoCompletingTextField();176 initAutoCompletionField(textField, key);177 167 JComboBox comboBox = new JComboBox(usage.values.toArray()); 178 168 comboBox.setEditable(true); … … 646 636 } 647 637 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 }660 638 public PresetPanel createPanel(Collection<OsmPrimitive> selected) { 661 639 if (data == null) … … 663 641 OsmDataLayer layer = Main.main.getEditLayer(); 664 642 if (layer != null) { 665 refreshAutocompletionList(layer);643 AutoCompletionCache.getCacheForLayer(layer).initFromDataSet(); 666 644 } 667 645 PresetPanel p = new PresetPanel();
Note: See TracChangeset
for help on using the changeset viewer.
