Changeset 18040 in josm for trunk/src


Ignore:
Timestamp:
2021-07-16T19:18:18+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #21124 - see #21117 - better fix (patch by marcello)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java

    r18023 r18040  
    2222import javax.swing.JPanel;
    2323import javax.swing.JToggleButton;
    24 import javax.swing.SwingUtilities;
    2524
    2625import org.openstreetmap.josm.data.osm.Tag;
     
    250249
    251250    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
    256255            textField.setForeground(Color.BLUE);
    257256            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);
    266261            });
    267262        }
Note: See TracChangeset for help on using the changeset viewer.