Ticket #12417: MapModePreferenceChangedListener.2.patch

File MapModePreferenceChangedListener.2.patch, 5.1 KB (added by kolesar, 9 years ago)
  • src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    diff --git a/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java b/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
    index bdc4aad..8ee76cf 100644
    a b public class DrawAction extends MapMode implements MapViewPaintable, SelectionCh  
    140140
    141141        readPreferences();
    142142        snapHelper.init();
     143        readPreferences();
    143144    }
    144145
    145146    private JCheckBoxMenuItem addMenuItem() {
    public class DrawAction extends MapMode implements MapViewPaintable, SelectionCh  
    238239        ignoreNextKeyRelease = true;
    239240    }
    240241
    241     private void readPreferences() {
     242    @Override
     243    protected void readPreferences() {
    242244        rubberLineColor = Main.pref.getColor(marktr("helper line"), null);
    243245        if (rubberLineColor == null) rubberLineColor = PaintColors.SELECTED.get();
    244246
  • src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

    diff --git a/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java b/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
    index 0e017a4..18d28fb 100644
    a b public class ExtrudeAction extends MapMode implements MapViewPaintable, KeyPress  
    294294        super.enterMode();
    295295        Main.map.mapView.addMouseListener(this);
    296296        Main.map.mapView.addMouseMotionListener(this);
    297         readPreferences();
    298297        ignoreNextKeyRelease = true;
    299298        Main.map.keyDetector.addKeyListener(this);
    300299        Main.map.keyDetector.addModifierListener(this);
    301300    }
    302301
    303     private void readPreferences() {
     302    @Override
     303    protected void readPreferences() {
    304304        initialMoveDelay = Main.pref.getInteger("edit.initial-move-delay", 200);
    305305        initialMoveThreshold = Main.pref.getInteger("extrude.initial-move-threshold", 1);
    306306        mainColor = Main.pref.getColor(marktr("Extrude: main line"), null);
  • src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java

    diff --git a/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java b/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java
    index 0d343ee..87599f2 100644
    a b public class ImproveWayAccuracyAction extends MapMode implements MapViewPaintabl  
    141141        Main.map.keyDetector.addModifierListener(this);
    142142    }
    143143
    144     private void readPreferences() {
     144    @Override
     145    protected void readPreferences() {
    145146        guideColor = Main.pref.getColor(marktr("improve way accuracy helper line"), null);
    146147        if (guideColor == null) guideColor = PaintColors.HIGHLIGHT.get();
    147148
  • src/org/openstreetmap/josm/actions/mapmode/MapMode.java

    diff --git a/src/org/openstreetmap/josm/actions/mapmode/MapMode.java b/src/org/openstreetmap/josm/actions/mapmode/MapMode.java
    index ba5d48a..f6d774f 100644
    a b import org.openstreetmap.josm.gui.MapFrame;  
    1414import org.openstreetmap.josm.gui.layer.Layer;
    1515import org.openstreetmap.josm.tools.ImageProvider;
    1616import org.openstreetmap.josm.tools.Shortcut;
     17import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
     18import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
    1719
    1820/**
    1921 * A class implementing MapMode is able to be selected as an mode for map editing.
    import org.openstreetmap.josm.tools.Shortcut;  
    2123 *
    2224 * MapModes should register/deregister all necessary listeners on the map's view control.
    2325 */
    24 public abstract class MapMode extends JosmAction implements MouseListener, MouseMotionListener {
     26public abstract class MapMode extends JosmAction implements MouseListener, MouseMotionListener, PreferenceChangedListener {
    2527    protected final Cursor cursor;
    2628    protected boolean ctrl;
    2729    protected boolean alt;
    public abstract class MapMode extends JosmAction implements MouseListener, Mouse  
    6264     */
    6365    public void enterMode() {
    6466        putValue("active", Boolean.TRUE);
     67        Main.pref.addPreferenceChangeListener(this);
     68        readPreferences();
    6569        Main.map.mapView.setNewCursor(cursor, this);
    6670        updateStatusLine();
    6771    }
    public abstract class MapMode extends JosmAction implements MouseListener, Mouse  
    7175     */
    7276    public void exitMode() {
    7377        putValue("active", Boolean.FALSE);
     78        Main.pref.removePreferenceChangeListener(this);
    7479        Main.map.mapView.resetCursor(this);
    7580    }
    7681
    public abstract class MapMode extends JosmAction implements MouseListener, Mouse  
    8388        return "";
    8489    }
    8590
     91    protected void readPreferences() {}
     92
    8693    /**
    8794     * Call selectMapMode(this) on the parent mapFrame.
    8895     */
    public abstract class MapMode extends JosmAction implements MouseListener, Mouse  
    159166    public void mouseDragged(MouseEvent e) {
    160167        // Do nothing
    161168    }
     169
     170    @Override
     171    public void preferenceChanged(PreferenceChangeEvent e) {
     172        readPreferences();
     173    }
    162174}