- Timestamp:
- 2021-07-16T19:18:18+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java
r18023 r18040 22 22 import javax.swing.JPanel; 23 23 import javax.swing.JToggleButton; 24 import javax.swing.SwingUtilities;25 24 26 25 import org.openstreetmap.josm.data.osm.Tag; … … 250 249 251 250 private void setupListeners(AutoCompletingTextField textField, TaggingPresetItemGuiSupport support) { 252 textField.getDocument().addDocumentListener(DocumentAdapter.create(ignore ->253 support.fireItemValueModified(this, key, textField.getText())));254 255 if (valueTemplate != null) {251 if (valueTemplate == null) { // only fire on normal fields 252 textField.getDocument().addDocumentListener(DocumentAdapter.create(ignore -> 253 support.fireItemValueModified(this, key, textField.getText()))); 254 } else { // only listen on calculated fields 256 255 textField.setForeground(Color.BLUE); 257 256 support.addListener((source, key, newValue) -> { 258 if (source != this) { 259 String valueTemplateText = valueTemplate.getText(support); 260 Logging.trace("Evaluating value_template {0} for key {1} from {2} with new value {3} => {4}", 261 valueTemplate, key, source, newValue, valueTemplateText); 262 if (!textField.getText().equals(valueTemplateText)) { 263 SwingUtilities.invokeLater(() -> textField.setItem(valueTemplateText)); 264 } 265 } 257 String valueTemplateText = valueTemplate.getText(support); 258 Logging.trace("Evaluating value_template {0} for key {1} from {2} with new value {3} => {4}", 259 valueTemplate, key, source, newValue, valueTemplateText); 260 textField.setItem(valueTemplateText); 266 261 }); 267 262 }
Note:
See TracChangeset
for help on using the changeset viewer.