Changeset 15363 in josm


Ignore:
Timestamp:
2019-09-19T16:30:27+02:00 (2 years ago)
Author:
Don-vip
Message:

fix #18050 - DownloadAlong: download as new layer

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

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

    r15350 r15363  
    123123     * @param gpxDownload Set to true if GPX data should be downloaded
    124124     * @param title the title string for the confirmation dialog
    125      */
    126     protected static void confirmAndDownloadAreas(Area a, double maxArea, boolean osmDownload, boolean gpxDownload, String title) {
     125     * @param newLayer Set to true if all areas should be put into a single new layer
     126     */
     127    protected static void confirmAndDownloadAreas(Area a, double maxArea, boolean osmDownload, boolean gpxDownload, String title,
     128            boolean newLayer) {
    127129        List<Rectangle2D> toDownload = new ArrayList<>();
    128130        addToDownload(a, a.getBounds(), toDownload, maxArea);
     
    140142        final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download data"));
    141143        final Future<?> future = new DownloadTaskList(Config.getPref().getBoolean("download.along.zoom-after-download"))
    142                 .download(false, toDownload, osmDownload, gpxDownload, monitor);
     144                .download(newLayer, toDownload, osmDownload, gpxDownload, monitor);
    143145        waitFuture(future, monitor);
    144146    }
     
    179181     * @param panel the panel that was displayed to the user and now contains his selections
    180182     * @param confirmTitle the title to display in the confirmation panel
     183     * @param newLayer Set to true if all areas should be put into a single new layer
    181184     * @return the task or null if canceled by user
    182185     */
    183     protected PleaseWaitRunnable createCalcTask(Path2D alongPath, DownloadAlongPanel panel, String confirmTitle) {
     186    protected PleaseWaitRunnable createCalcTask(Path2D alongPath, DownloadAlongPanel panel, String confirmTitle, boolean newLayer) {
    184187        /*
    185188         * Find the average latitude for the data we're contemplating, so we can know how many
     
    221224
    222225            private final Path2D downloadPath = new Path2D.Double();
     226            private final boolean newLayer;
    223227            private boolean cancel;
    224228            private int ticks;
    225229            private final Rectangle2D r = new Rectangle2D.Double();
    226230
    227             CalculateDownloadArea() {
     231            CalculateDownloadArea(boolean newLayer) {
    228232                super(tr("Calculating Download Area"), displayProgress ? null : NullProgressMonitor.INSTANCE, false);
     233                this.newLayer = newLayer;
    229234            }
    230235
     
    245250                }
    246251                confirmAndDownloadAreas(new Area(downloadPath), maxArea, panel.isDownloadOsmData(), panel.isDownloadGpxData(),
    247                         confirmTitle);
     252                        confirmTitle, newLayer);
    248253            }
    249254
     
    291296        }
    292297
    293         return new CalculateDownloadArea();
     298        return new CalculateDownloadArea(newLayer);
    294299    }
    295300
  • trunk/src/org/openstreetmap/josm/actions/DownloadAlongWayAction.java

    r15028 r15363  
    5454                PREF_DOWNLOAD_ALONG_WAY_DISTANCE, PREF_DOWNLOAD_ALONG_WAY_AREA, null);
    5555
    56         if (0 != panel.showInDownloadDialog(tr("Download from OSM along selected ways"), HelpUtil.ht("/Tools/DownloadAlong"))) {
     56        int ret = panel.showInDownloadDialog(tr("Download from OSM along selected ways"), HelpUtil.ht("/Tools/DownloadAlong"));
     57        if (0 != ret && 1 != ret) {
    5758            return null;
    5859        }
     
    7172            }
    7273        }
    73         return createCalcTask(alongPath, panel, tr("Download from OSM along selected ways"));
    74 
     74        return createCalcTask(alongPath, panel, tr("Download from OSM along selected ways"), 1 == ret);
    7575    }
    7676
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongPanel.java

    r14273 r15363  
    172172                ),
    173173                new ButtonSpec(
     174                        tr("Download as new layer"),
     175                        new ImageProvider("download_new_layer"),
     176                        tr("Click to download into a new data layer"),
     177                        null // no specific help text
     178                ),
     179                new ButtonSpec(
    174180                        tr("Cancel"),
    175181                        new ImageProvider("cancel"),
     
    183189        int ret = HelpAwareOptionPane.showOptionDialog(MainApplication.getMainFrame(), this, title,
    184190                    JOptionPane.QUESTION_MESSAGE, null, options, options[0], helpTopic);
    185         if (0 == ret) {
     191        if (0 == ret || 1 == ret) {
    186192            rememberSettings();
    187193        }
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackAction.java

    r14962 r15363  
    5050                PREF_DOWNLOAD_ALONG_TRACK_DISTANCE, PREF_DOWNLOAD_ALONG_TRACK_AREA, PREF_DOWNLOAD_ALONG_TRACK_NEAR);
    5151
    52         if (0 != panel.showInDownloadDialog(tr("Download from OSM along this track"), HelpUtil.ht("/Action/DownloadAlongTrack"))) {
     52        int ret = panel.showInDownloadDialog(tr("Download from OSM along this track"), HelpUtil.ht("/Action/DownloadAlongTrack"));
     53        if (0 != ret && 1 != ret) {
    5354            return null;
    5455        }
     
    7980            }
    8081        }
    81         return createCalcTask(gpxPath, panel, tr("Download from OSM along this track"));
     82        return createCalcTask(gpxPath, panel, tr("Download from OSM along this track"), 1 == ret);
    8283    }
    8384}
Note: See TracChangeset for help on using the changeset viewer.