Changeset 8029 in josm for trunk


Ignore:
Timestamp:
2015-02-09T22:04:50+01:00 (10 years ago)
Author:
bastiK
Message:

see #11090 - new option for LayerChangeListener to get an initial
notification when the LayerChangeListener is added

File:
1 edited

Legend:

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

    r7817 r8029  
    142142
    143143    /**
     144     * Adds a layer change listener
     145     *
     146     * @param listener the listener. Ignored if null or already registered.
     147     * @param initialFire fire an active-layer-changed-event right after adding
     148     * the listener in case there is a layer present (should be)
     149     */
     150    public static void addLayerChangeListener(LayerChangeListener listener, boolean initialFire) {
     151        addLayerChangeListener(listener);
     152        if (initialFire && Main.isDisplayingMapView()) {
     153            listener.activeLayerChange(null, Main.map.mapView.getActiveLayer());
     154        }
     155    }
     156
     157    /**
    144158     * Adds an edit layer change listener
    145159     *
    146160     * @param listener the listener. Ignored if null or already registered.
    147      * @param initialFire Fire an edit-layer-changed-event right after adding
     161     * @param initialFire fire an edit-layer-changed-event right after adding
    148162     * the listener in case there is an edit layer present
    149163     */
     
    151165        addEditLayerChangeListener(listener);
    152166        if (initialFire && Main.isDisplayingMapView() && Main.map.mapView.getEditLayer() != null) {
    153             fireEditLayerChanged(null, Main.map.mapView.getEditLayer());
     167            listener.editLayerChanged(null, Main.map.mapView.getEditLayer());
    154168        }
    155169    }
Note: See TracChangeset for help on using the changeset viewer.