Changeset 16562 in josm


Ignore:
Timestamp:
2020-06-07T18:40:25+02:00 (4 years ago)
Author:
simon04
Message:

fix #19196 - Don't require a restart when a MapPaint color is changed (patch by taylor.smock)

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r16553 r16562  
    2424import org.openstreetmap.josm.io.FileWatcher;
    2525import org.openstreetmap.josm.spi.preferences.Config;
     26import org.openstreetmap.josm.spi.preferences.IPreferences;
     27import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;
     28import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener;
    2629import org.openstreetmap.josm.tools.ImageProvider;
    2730import org.openstreetmap.josm.tools.ListenerList;
     
    4548    private static final ListenerList<MapPaintSylesUpdateListener> listeners = ListenerList.createUnchecked();
    4649
     50    private static final class MapPaintStylesPreferenceListener implements PreferenceChangedListener {
     51        private final IPreferences pref;
     52
     53        MapPaintStylesPreferenceListener(IPreferences pref) {
     54            this.pref = pref;
     55        }
     56
     57        @Override
     58        public void preferenceChanged(PreferenceChangeEvent e) {
     59            if (e.getKey().contains("mappaint")) {
     60                // We need to remove this from the listeners, so that we don't recursively call ourselves.
     61                pref.removePreferenceChangeListener(this);
     62                MapPaintStyles.readFromPreferences();
     63                pref.addPreferenceChangeListener(this);
     64            }
     65        }
     66    }
     67
    4768    static {
    4869        listeners.addListener(new MapPaintSylesUpdateListener() {
     
    5778            }
    5879        });
     80        Config.getPref().addPreferenceChangeListener(new MapPaintStylesPreferenceListener(Config.getPref()));
    5981    }
    6082
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java

    r15496 r16562  
    391391    @Override
    392392    public boolean ok() {
    393         boolean ret = false;
    394393        for (ColorEntry d : tableModel.getDeleted()) {
    395394            d.toProperty().remove();
    396395        }
    397396        for (ColorEntry e : tableModel.getData()) {
    398             if (e.info.getValue() != null && e.toProperty().put(e.info.getValue())
    399                     && NamedColorProperty.COLOR_CATEGORY_MAPPAINT.equals(e.info.getCategory())) {
    400                 ret = true;
     397            if (e.info.getValue() != null) {
     398                e.toProperty().put(e.info.getValue());
    401399            }
    402400        }
    403401        OsmDataLayer.createHatchTexture();
    404         return ret;
     402        return false;
    405403    }
    406404
Note: See TracChangeset for help on using the changeset viewer.