Changeset 19483 in josm
- Timestamp:
- 2026-02-03T07:29:02+01:00 (7 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r19115 r19483 70 70 import org.openstreetmap.josm.data.UndoRedoHandler; 71 71 import org.openstreetmap.josm.data.osm.DataSet; 72 import org.openstreetmap.josm.data.osm.Filter; 72 73 import org.openstreetmap.josm.data.osm.OsmDataManager; 73 74 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 147 148 public static final ListProperty PROPERTY_RECENT_TAGS = new ListProperty("properties.recent-tags", 148 149 Collections.emptyList()); 149 /** The preference listof tags which should not be remembered, since r9940 */150 /** The preference filter of tags which should not be remembered, since r9940 */ 150 151 public static final StringProperty PROPERTY_TAGS_TO_IGNORE = new StringProperty("properties.recent-tags.ignore", 152 new SearchSetting().writeToString()); 153 /** The preference filter for tag keys for which values should not be auto-completed, since xxx */ 154 public static final StringProperty NO_AUTOCOMPLETE_KEYS = new StringProperty("properties.autocomplete.exclude-keys", 151 155 new SearchSetting().writeToString()); 152 156 … … 183 187 final RecentTagCollection recentTags = new RecentTagCollection(MAX_LRU_TAGS_NUMBER); 184 188 SearchSetting tagsToIgnore; 189 SearchSetting noAutocomplete; 185 190 186 191 /** … … 241 246 this.tagData = propertyData; 242 247 this.valueCount = valueCount; 248 this.noAutocomplete = SearchSetting.readFromString(NO_AUTOCOMPLETE_KEYS.get()); 243 249 } 244 250 … … 737 743 } 738 744 745 /** 746 * Check if values should be auto-completed for the given tag key. 747 * @param key the key 748 * @return false if auto-completion is disabled or if the key matches the exclusion filter, true else 749 */ 750 private boolean autocompleteValuesForKey(String key) { 751 if (!AUTOCOMPLETE_VALUES.get()) 752 return false; 753 if (noAutocomplete == null || Utils.isEmpty(noAutocomplete.text)) 754 return true; 755 try { 756 return !SearchCompiler.compile(noAutocomplete).match(new Tag(key)); 757 } catch (SearchParseError parseError) { 758 throw new IllegalStateException(parseError); 759 } 760 } 761 739 762 protected void addEventListeners() { 740 763 // OK on Enter in values … … 778 801 // update the values combobox orientation if the key changed 779 802 values.applyComponentOrientation(OrientationAction.getNamelikeOrientation(keys.getText())); 803 // update the auto-completion setting for the given tag key 804 values.setAutocompleteEnabled(autocompleteValuesForKey(keys.getText())); 780 805 } 781 806 … … 1163 1188 add(new IgnoreTagAction(tr("Ignore tag ''{0}''", t), t)); 1164 1189 add(new EditIgnoreTagsAction()); 1190 add(new EditExcludeAutocompleteValues(t)); 1165 1191 } 1166 1192 } … … 1190 1216 1191 1217 EditIgnoreTagsAction() { 1192 super(tr("Edit ignore list"));1218 super(tr("Edit ignore filter")); 1193 1219 } 1194 1220 1195 1221 @Override 1196 1222 public void actionPerformed(ActionEvent e) { 1197 final SearchSetting newTagsToIngore = SearchAction.showSearchDialog(tagsToIgnore); 1223 final SearchSetting newTagsToIngore = SearchAction.showSearchDialog(new Filter(tagsToIgnore)); 1198 1224 if (newTagsToIngore == null) { 1199 1225 return; … … 1205 1231 } catch (SearchParseError parseError) { 1206 1232 warnAboutParseError(parseError); 1233 } 1234 } 1235 } 1236 1237 class EditExcludeAutocompleteValues extends AbstractAction { 1238 final transient Tag tag; 1239 1240 EditExcludeAutocompleteValues(Tag tag) { 1241 super(tr("Edit tag filter to stop autocompletion of values")); 1242 this.tag = tag; 1243 setEnabled(AUTOCOMPLETE_VALUES.get()); 1244 } 1245 1246 @Override 1247 public void actionPerformed(ActionEvent e) { 1248 SearchSetting initFilter = SearchSetting.fromString('"' + tag.getKey() + '"'); 1249 1250 if (noAutocomplete != null && !Utils.isEmpty(noAutocomplete.text)) 1251 initFilter = noAutocomplete; 1252 final SearchSetting newNoAutocomplete = SearchAction.showSearchDialog(new Filter(initFilter)); 1253 if (newNoAutocomplete != null) { 1254 noAutocomplete = newNoAutocomplete; 1255 NO_AUTOCOMPLETE_KEYS.put(noAutocomplete.writeToString()); 1207 1256 } 1208 1257 }
Note:
See TracChangeset
for help on using the changeset viewer.
