Changeset 8973 in josm


Ignore:
Timestamp:
2015-11-01T17:32:50+01:00 (8 years ago)
Author:
Don-vip
Message:

see #12025 - allow dynamic changes of mappaint.nameOrder

File:
1 edited

Legend:

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

    r8849 r8973  
    88
    99import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
     11import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
    1012import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1113import org.openstreetmap.josm.tools.LanguageInfo;
     
    148150    }
    149151
    150     public static class DeriveLabelFromNameTagsCompositionStrategy extends LabelCompositionStrategy {
     152    public static class DeriveLabelFromNameTagsCompositionStrategy
     153        extends LabelCompositionStrategy implements PreferenceChangedListener {
    151154
    152155        /**
     
    176179        /**
    177180         * <p>Creates the strategy and initializes its name tags from the preferences.</p>
    178          *
    179          * <p><strong>Note:</strong> If the list of name tags in the preferences changes, strategy instances
    180          * are not notified. It's up to the client to listen to preference changes and
    181          * invoke {@link #initNameTagsFromPreferences()} accordingly.</p>
    182          *
    183181         */
    184182        public DeriveLabelFromNameTagsCompositionStrategy() {
     
    296294            return "{" + getClass().getSimpleName() +'}';
    297295        }
     296
     297        @Override
     298        public void preferenceChanged(PreferenceChangeEvent e) {
     299            if (e.getKey() != null && e.getKey().startsWith("mappaint.name")) {
     300                initNameTagsFromPreferences();
     301            }
     302        }
    298303    }
    299304}
Note: See TracChangeset for help on using the changeset viewer.