kopia lustrzana https://github.com/JOSM/MapWithAI
MapWithAIPlugin: initialize download option when user first starts download
Signed-off-by: Taylor Smock <tsmock@fb.com>pull/1/head
rodzic
cfceddfb49
commit
5a265e6520
|
@ -22,6 +22,7 @@ import org.openstreetmap.josm.gui.MainApplication;
|
||||||
import org.openstreetmap.josm.gui.MainMenu;
|
import org.openstreetmap.josm.gui.MainMenu;
|
||||||
import org.openstreetmap.josm.gui.MapFrame;
|
import org.openstreetmap.josm.gui.MapFrame;
|
||||||
import org.openstreetmap.josm.gui.download.DownloadDialog;
|
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.download.OSMDownloadSource;
|
||||||
import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
|
import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
|
||||||
import org.openstreetmap.josm.gui.util.GuiHelper;
|
import org.openstreetmap.josm.gui.util.GuiHelper;
|
||||||
|
@ -124,12 +125,6 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable {
|
||||||
MapPaintUtils.addMapWithAIPaintStyles();
|
MapPaintUtils.addMapWithAIPaintStyles();
|
||||||
|
|
||||||
destroyables = new ArrayList<>();
|
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);
|
setVersionInfo(info.localversion);
|
||||||
RequestProcessor.addRequestHandlerClass("mapwithai", MapWithAIRemoteControl.class);
|
RequestProcessor.addRequestHandlerClass("mapwithai", MapWithAIRemoteControl.class);
|
||||||
|
@ -143,6 +138,17 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable {
|
||||||
destroyables.add(new MapWithAICopyProhibit());
|
destroyables.add(new MapWithAICopyProhibit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addDownloadSelection(List<DownloadSelection> 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
|
@Override
|
||||||
public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
|
public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
|
||||||
final Optional<MapWithAIObject> possibleMapWithAIObject = destroyables.parallelStream()
|
final Optional<MapWithAIObject> possibleMapWithAIObject = destroyables.parallelStream()
|
||||||
|
|
|
@ -39,7 +39,7 @@ public final class CountryUtils {
|
||||||
*/
|
*/
|
||||||
public static Optional<ImageryInfo.ImageryBounds> getCountryShape(String country) {
|
public static Optional<ImageryInfo.ImageryBounds> getCountryShape(String country) {
|
||||||
GeoPropertyIndex<Boolean> geoPropertyIndex = Territories.getGeoPropertyIndex(country);
|
GeoPropertyIndex<Boolean> geoPropertyIndex = Territories.getGeoPropertyIndex(country);
|
||||||
if (geoPropertyIndex.getGeoProperty() instanceof DefaultGeoProperty) {
|
if (geoPropertyIndex != null && geoPropertyIndex.getGeoProperty() instanceof DefaultGeoProperty) {
|
||||||
DefaultGeoProperty prop = (DefaultGeoProperty) geoPropertyIndex.getGeoProperty();
|
DefaultGeoProperty prop = (DefaultGeoProperty) geoPropertyIndex.getGeoProperty();
|
||||||
Rectangle2D areaBounds = prop.getArea().getBounds2D();
|
Rectangle2D areaBounds = prop.getArea().getBounds2D();
|
||||||
ImageryInfo.ImageryBounds tmp = new ImageryInfo.ImageryBounds(bboxToBoundsString(
|
ImageryInfo.ImageryBounds tmp = new ImageryInfo.ImageryBounds(bboxToBoundsString(
|
||||||
|
|
|
@ -229,7 +229,7 @@ public class MapWithAIInfo extends
|
||||||
if (e.shapes != null) {
|
if (e.shapes != null) {
|
||||||
try {
|
try {
|
||||||
for (String s : e.shapes.split(";", -1)) {
|
for (String s : e.shapes.split(";", -1)) {
|
||||||
if (s.matches("[\\d,]+")) {
|
if (s.matches("[\\d,.-]+")) {
|
||||||
bounds.addShape(new Shape(s, ","));
|
bounds.addShape(new Shape(s, ","));
|
||||||
} else {
|
} else {
|
||||||
CountryUtils.getCountryShape(s).map(SourceBounds::getShapes)
|
CountryUtils.getCountryShape(s).map(SourceBounds::getShapes)
|
||||||
|
|
Ładowanie…
Reference in New Issue