Changeset 5458 in josm for trunk


Ignore:
Timestamp:
2012-08-19T02:54:58+02:00 (12 years ago)
Author:
Don-vip
Message:

fix #2519 - do not allow multiple identical imagery layers

File:
1 edited

Legend:

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

    r5091 r5458  
    5656        }
    5757    }
     58   
     59    protected boolean isLayerAlreadyPresent() {
     60        if (Main.map != null && Main.map.mapView != null) {
     61            for (ImageryLayer layer : Main.map.mapView.getLayersOfType(ImageryLayer.class)) {
     62                if (info.equals(layer.getInfo())) {
     63                    return true;
     64                }
     65            }
     66        }
     67        return false;
     68    }
    5869
    5970    @Override
    6071    protected void updateEnabledState() {
    61         // never enable blacklisted entries.
    62         if (info.isBlacklisted()) {
     72        // never enable blacklisted entries. Do not add same imagery layer twice (fix #2519)
     73        if (info.isBlacklisted() || isLayerAlreadyPresent()) {
    6374            setEnabled(false);
    6475        } else if (info.getImageryType() == ImageryType.TMS || info.getImageryType() == ImageryType.BING || info.getImageryType() == ImageryType.SCANEX) {
Note: See TracChangeset for help on using the changeset viewer.