Ignore:
Timestamp:
2017-09-09T16:58:45+02:00 (4 years ago)
Author:
Don-vip
Message:

see #15229 - see #15182 - remove GUI references from OsmApi

File:
1 edited

Legend:

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

    r12803 r12804  
    9999import org.openstreetmap.josm.gui.io.SaveLayersDialog;
    100100import org.openstreetmap.josm.gui.layer.AutosaveTask;
     101import org.openstreetmap.josm.gui.layer.ImageryLayer;
    101102import org.openstreetmap.josm.gui.layer.Layer;
    102103import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     
    387388        return Arrays.asList(
    388389            new InitializationTask(tr("Initializing OSM API"), () -> {
     390                    OsmApi.addOsmApiInitializationListener(api -> {
     391                        // This checks if there are any layers currently displayed that are now on the blacklist, and removes them.
     392                        // This is a rare situation - probably only occurs if the user changes the API URL in the preferences menu.
     393                        // Otherwise they would not have been able to load the layers in the first place because they would have been disabled
     394                        if (isDisplayingMapView()) {
     395                            for (Layer l : getLayerManager().getLayersOfType(ImageryLayer.class)) {
     396                                if (((ImageryLayer) l).getInfo().isBlacklisted()) {
     397                                    Logging.info(tr("Removed layer {0} because it is not allowed by the configured API.", l.getName()));
     398                                    getLayerManager().removeLayer(l);
     399                                }
     400                            }
     401                        }
     402                    });
    389403                    // We try to establish an API connection early, so that any API
    390404                    // capabilities are already known to the editor instance. However
Note: See TracChangeset for help on using the changeset viewer.