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)

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

Legend:

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

    r5874 r5957  
    1313import org.openstreetmap.josm.Main;
    1414import org.openstreetmap.josm.gui.MapFrame;
     15import org.openstreetmap.josm.gui.MapFrameListener;
    1516import org.openstreetmap.josm.gui.download.DownloadSelection;
    1617import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     
    3839 * @author Immanuel.Scholz
    3940 */
    40 public abstract class Plugin {
     41public abstract class Plugin implements MapFrameListener {
    4142
    4243    /**
     
    8384    }
    8485
    85     /**
    86      * Called after Main.mapFrame is initalized. (After the first data is loaded).
    87      * You can use this callback to tweak the newFrame to your needs, as example install
    88      * an alternative Painter.
    89      */
     86    @Override
    9087    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {}
    9188
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r5886 r5957  
    508508            if (klass != null) {
    509509                System.out.println(tr("loading plugin ''{0}'' (version {1})", plugin.name, plugin.localversion));
    510                 pluginList.add(plugin.load(klass));
     510                PluginProxy pluginProxy = plugin.load(klass);
     511                pluginList.add(pluginProxy);
     512                Main.addMapFrameListener(pluginProxy);
    511513            }
    512514            msg = null;
     
    919921    }
    920922
    921     /**
    922      * Notified loaded plugins about a new map frame
    923      *
    924      * @param old the old map frame
    925      * @param map the new map frame
    926      */
    927     public static void notifyMapFrameChanged(MapFrame old, MapFrame map) {
    928         for (PluginProxy plugin : pluginList) {
    929             plugin.mapFrameInitialized(old, map);
    930         }
    931     }
    932 
    933923    public static Object getPlugin(String name) {
    934924        for (PluginProxy plugin : pluginList)
Note: See TracChangeset for help on using the changeset viewer.