diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPlugin.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPlugin.java index 0169b9f..e440106 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPlugin.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPlugin.java @@ -22,6 +22,7 @@ import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.MainMenu; import org.openstreetmap.josm.gui.MapFrame; import org.openstreetmap.josm.gui.download.DownloadDialog; +import org.openstreetmap.josm.gui.download.DownloadSelection; import org.openstreetmap.josm.gui.download.OSMDownloadSource; import org.openstreetmap.josm.gui.preferences.PreferenceSetting; import org.openstreetmap.josm.gui.util.GuiHelper; @@ -124,12 +125,6 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable { MapPaintUtils.addMapWithAIPaintStyles(); destroyables = new ArrayList<>(); - // Run in EDT to avoid blocking (has to be run before MapWithAIDownloadOptions - // so its already initialized) - GuiHelper.runInEDT(MapWithAILayerInfo::getInstance); - MapWithAIDownloadOptions mapWithAIDownloadOptions = new MapWithAIDownloadOptions(); - mapWithAIDownloadOptions.addGui(DownloadDialog.getInstance()); - destroyables.add(mapWithAIDownloadOptions); setVersionInfo(info.localversion); RequestProcessor.addRequestHandlerClass("mapwithai", MapWithAIRemoteControl.class); @@ -143,6 +138,17 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable { destroyables.add(new MapWithAICopyProhibit()); } + @Override + public void addDownloadSelection(List list) { + // Run in EDT to avoid blocking (has to be run before MapWithAIDownloadOptions + // so its already initialized) + GuiHelper.runInEDT(MapWithAILayerInfo::getInstance); + MapWithAIDownloadOptions mapWithAIDownloadOptions = new MapWithAIDownloadOptions(); + MainApplication.worker + .execute(() -> GuiHelper.runInEDT(() -> mapWithAIDownloadOptions.addGui(DownloadDialog.getInstance()))); + destroyables.add(mapWithAIDownloadOptions); + } + @Override public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { final Optional possibleMapWithAIObject = destroyables.parallelStream() diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/CountryUtils.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/CountryUtils.java index 85fa447..ecfae78 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/CountryUtils.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/CountryUtils.java @@ -39,7 +39,7 @@ public final class CountryUtils { */ public static Optional getCountryShape(String country) { GeoPropertyIndex geoPropertyIndex = Territories.getGeoPropertyIndex(country); - if (geoPropertyIndex.getGeoProperty() instanceof DefaultGeoProperty) { + if (geoPropertyIndex != null && geoPropertyIndex.getGeoProperty() instanceof DefaultGeoProperty) { DefaultGeoProperty prop = (DefaultGeoProperty) geoPropertyIndex.getGeoProperty(); Rectangle2D areaBounds = prop.getArea().getBounds2D(); ImageryInfo.ImageryBounds tmp = new ImageryInfo.ImageryBounds(bboxToBoundsString( diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAIInfo.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAIInfo.java index 1124fe4..2113d24 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAIInfo.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAIInfo.java @@ -229,7 +229,7 @@ public class MapWithAIInfo extends if (e.shapes != null) { try { for (String s : e.shapes.split(";", -1)) { - if (s.matches("[\\d,]+")) { + if (s.matches("[\\d,.-]+")) { bounds.addShape(new Shape(s, ",")); } else { CountryUtils.getCountryShape(s).map(SourceBounds::getShapes)