Ignore:
Timestamp:
2013-05-11T23:40:04+02:00 (11 years ago)
Author:
Don-vip
Message:

New interface MapFrameListener to allow core classes to listen to MapFrame changes (previously only plugins could be notified of these changes)

File:
1 edited

Legend:

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

    r5897 r5957  
    6565import org.openstreetmap.josm.gui.MainMenu;
    6666import org.openstreetmap.josm.gui.MapFrame;
     67import org.openstreetmap.josm.gui.MapFrameListener;
    6768import org.openstreetmap.josm.gui.MapView;
    6869import org.openstreetmap.josm.gui.NavigatableComponent.ViewportData;
     
    8182import org.openstreetmap.josm.gui.util.RedirectInputMap;
    8283import org.openstreetmap.josm.io.OsmApi;
    83 import org.openstreetmap.josm.plugins.PluginHandler;
    8484import org.openstreetmap.josm.tools.CheckParameterUtil;
    8585import org.openstreetmap.josm.tools.I18n;
     
    189189    private GettingStarted gettingStarted = new GettingStarted();
    190190
     191    private static final Collection<MapFrameListener> mapFrameListeners = new ArrayList<MapFrameListener>();
     192
    191193    /**
    192194     * Logging level (3 = debug, 2 = info, 1 = warn, 0 = none).
     
    281283        Main.map = map;
    282284
    283         PluginHandler.notifyMapFrameChanged(old, map);
     285        for (MapFrameListener listener : mapFrameListeners ) {
     286            listener.mapFrameInitialized(old, map);
     287        }
    284288        if (map == null && currentProgressMonitor != null) {
    285289            currentProgressMonitor.showForegroundDialog();
     
    12081212    }
    12091213
     1214    /**
     1215     * Registers a new {@code MapFrameListener} that will be notified of MapFrame changes
     1216     * @param listener The MapFrameListener
     1217     * @return {@code true} if the listeners collection changed as a result of the call
     1218     * @since 5957
     1219     */
     1220    public static boolean addMapFrameListener(MapFrameListener listener) {
     1221        return listener != null ? mapFrameListeners.add(listener) : false;
     1222    }
     1223
     1224    /**
     1225     * Unregisters the given {@code MapFrameListener} from MapFrame changes
     1226     * @param listener The MapFrameListener
     1227     * @return {@code true} if the listeners collection changed as a result of the call
     1228     * @since 5957
     1229     */
     1230    public static boolean removeMapFrameListener(MapFrameListener listener) {
     1231        return listener != null ? mapFrameListeners.remove(listener) : false;
     1232    }
    12101233}
Note: See TracChangeset for help on using the changeset viewer.