Changeset 9682 in josm


Ignore:
Timestamp:
2016-01-29T23:47:45+01:00 (9 years ago)
Author:
wiktorn
Message:

Check if the imagery is valid before returning the info object.

I decided for such solution, as WMTS is the only source, that needs such validation. Alternative approach is to change ImageryPreference.NewEntryAction.actionPerformed(...) so it would instantiate imagery layer using ImageryLayer.create(...) and then call getTileSource(...) on this object, but this would require making this method public.

Closes: #12450

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMTSLayerPanel.java

    r8624 r9682  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.IOException;
     7
    68import javax.swing.JLabel;
    79
    810import org.openstreetmap.josm.data.imagery.ImageryInfo;
    911import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
     12import org.openstreetmap.josm.data.imagery.WMTSTileSource;
    1013import org.openstreetmap.josm.tools.GBC;
    1114
     
    3235    @Override
    3336    protected ImageryInfo getImageryInfo() {
    34         return new ImageryInfo(getImageryName(), "wmts:" + sanitize(getImageryRawUrl(), ImageryType.WMTS));
     37        ImageryInfo ret = new ImageryInfo(getImageryName(), "wmts:" + sanitize(getImageryRawUrl(), ImageryType.WMTS));
     38        try {
     39            new WMTSTileSource(ret); // check if constructor throws an error
     40        } catch (IOException e) {
     41            throw new IllegalArgumentException(e); // if so, wrap exception, so proper message will be shown to the user
     42        }
     43        return ret;
     44
    3545    }
    3646
Note: See TracChangeset for help on using the changeset viewer.