Changeset 18276 in josm for trunk/src/org


Ignore:
Timestamp:
2021-10-17T06:08:14+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #21441 - Make Tags/Membership panel listen to Preset Preferences changes (patch by marcello)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r17775 r18276  
    100100import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
    101101import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler;
     102import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetListener;
    102103import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType;
     104import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    103105import org.openstreetmap.josm.gui.util.AbstractTag2LinkPopupListener;
    104106import org.openstreetmap.josm.gui.util.HighlightHelper;
     
    111113import org.openstreetmap.josm.spi.preferences.Config;
    112114import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener;
     115import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;
    113116import org.openstreetmap.josm.tools.AlphanumComparator;
    114117import org.openstreetmap.josm.tools.GBC;
     
    139142 */
    140143public class PropertiesDialog extends ToggleDialog
    141 implements DataSelectionListener, ActiveLayerChangeListener, DataSetListenerAdapter.Listener {
     144implements DataSelectionListener, ActiveLayerChangeListener, DataSetListenerAdapter.Listener, PreferenceChangedListener, TaggingPresetListener {
    142145
    143146    /**
     
    239242            + tr("Select objects for which to change tags.") + "</p></html>");
    240243
    241     private final PreferenceChangedListener preferenceListener = e -> {
    242                 if (MainApplication.getLayerManager().getActiveData() != null) {
    243                     // Re-load data when display preference change
    244                     updateSelection();
    245                 }
    246             };
    247 
    248244    private final transient TaggingPresetHandler presetHandler = new TaggingPresetCommandHandler();
    249245
     
    308304        editHelper.loadTagsIfNeeded();
    309305
    310         Config.getPref().addKeyPreferenceChangeListener("display.discardable-keys", preferenceListener);
     306        Config.getPref().addKeyPreferenceChangeListener("display.discardable-keys", this);
     307        TaggingPresets.addListener(this);
    311308    }
    312309
     
    621618        membershipTable.removeMouseListener(popupMenuLauncher);
    622619        super.destroy();
    623         Config.getPref().removeKeyPreferenceChangeListener("display.discardable-keys", preferenceListener);
     620        Config.getPref().removeKeyPreferenceChangeListener("display.discardable-keys", this);
     621        TaggingPresets.removeListener(this);
    624622        Container parent = pluginHook.getParent();
    625623        if (parent != null) {
     
    767765
    768766    /* ---------------------------------------------------------------------------------- */
     767    /* PreferenceChangedListener                                                          */
     768    /* ---------------------------------------------------------------------------------- */
     769
     770    /**
     771     * Re-load data when display preference change
     772     */
     773    @Override
     774    public void preferenceChanged(PreferenceChangeEvent e) {
     775        if (MainApplication.getLayerManager().getActiveData() != null) {
     776            updateSelection();
     777        }
     778    }
     779
     780
     781    /* ---------------------------------------------------------------------------------- */
     782    /* TaggingPresetListener                                                              */
     783    /* ---------------------------------------------------------------------------------- */
     784
     785    /**
     786     * Updates the preset list when Presets preference changes.
     787     */
     788    @Override
     789    public void taggingPresetsModified() {
     790        if (MainApplication.getLayerManager().getActiveData() != null) {
     791            updateSelection();
     792        }
     793    }
     794
     795    /* ---------------------------------------------------------------------------------- */
    769796    /* ActiveLayerChangeListener                                                          */
    770797    /* ---------------------------------------------------------------------------------- */
Note: See TracChangeset for help on using the changeset viewer.