Changeset 5957 in josm
- Timestamp:
- 2013-05-11T23:40:04+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r5897 r5957 65 65 import org.openstreetmap.josm.gui.MainMenu; 66 66 import org.openstreetmap.josm.gui.MapFrame; 67 import org.openstreetmap.josm.gui.MapFrameListener; 67 68 import org.openstreetmap.josm.gui.MapView; 68 69 import org.openstreetmap.josm.gui.NavigatableComponent.ViewportData; … … 81 82 import org.openstreetmap.josm.gui.util.RedirectInputMap; 82 83 import org.openstreetmap.josm.io.OsmApi; 83 import org.openstreetmap.josm.plugins.PluginHandler;84 84 import org.openstreetmap.josm.tools.CheckParameterUtil; 85 85 import org.openstreetmap.josm.tools.I18n; … … 189 189 private GettingStarted gettingStarted = new GettingStarted(); 190 190 191 private static final Collection<MapFrameListener> mapFrameListeners = new ArrayList<MapFrameListener>(); 192 191 193 /** 192 194 * Logging level (3 = debug, 2 = info, 1 = warn, 0 = none). … … 281 283 Main.map = map; 282 284 283 PluginHandler.notifyMapFrameChanged(old, map); 285 for (MapFrameListener listener : mapFrameListeners ) { 286 listener.mapFrameInitialized(old, map); 287 } 284 288 if (map == null && currentProgressMonitor != null) { 285 289 currentProgressMonitor.showForegroundDialog(); … … 1208 1212 } 1209 1213 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 } 1210 1233 } -
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r5874 r5957 13 13 import org.openstreetmap.josm.Main; 14 14 import org.openstreetmap.josm.gui.MapFrame; 15 import org.openstreetmap.josm.gui.MapFrameListener; 15 16 import org.openstreetmap.josm.gui.download.DownloadSelection; 16 17 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; … … 38 39 * @author Immanuel.Scholz 39 40 */ 40 public abstract class Plugin { 41 public abstract class Plugin implements MapFrameListener { 41 42 42 43 /** … … 83 84 } 84 85 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 90 87 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {} 91 88 -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r5886 r5957 508 508 if (klass != null) { 509 509 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); 511 513 } 512 514 msg = null; … … 919 921 } 920 922 921 /**922 * Notified loaded plugins about a new map frame923 *924 * @param old the old map frame925 * @param map the new map frame926 */927 public static void notifyMapFrameChanged(MapFrame old, MapFrame map) {928 for (PluginProxy plugin : pluginList) {929 plugin.mapFrameInitialized(old, map);930 }931 }932 933 923 public static Object getPlugin(String name) { 934 924 for (PluginProxy plugin : pluginList)
Note:
See TracChangeset
for help on using the changeset viewer.