Changeset 15205 in josm


Ignore:
Timestamp:
2019-07-06T18:37:14+02:00 (6 weeks ago)
Author:
Don-vip
Message:

fix #17871 - Don't zoom to download area by default for "Update Data" and "Download Along" actions.

Zoom to download can be restored with advanced properties:

  • update.data.zoom-after-download
  • download.along.zoom-after-download
Location:
trunk/src/org/openstreetmap/josm/actions
Files:
3 edited

Legend:

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

    r14962 r15205  
    2727import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2828import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
     29import org.openstreetmap.josm.spi.preferences.Config;
    2930import org.openstreetmap.josm.tools.GBC;
    3031import org.openstreetmap.josm.tools.Logging;
     
    128129        }
    129130        final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download data"));
    130         final Future<?> future = new DownloadTaskList().download(false, toDownload, osmDownload, gpxDownload, monitor);
     131        final Future<?> future = new DownloadTaskList(Config.getPref().getBoolean("download.along.zoom-after-download"))
     132                .download(false, toDownload, osmDownload, gpxDownload, monitor);
    131133        waitFuture(future, monitor);
    132134    }
  • trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java

    r14397 r15205  
    1818import org.openstreetmap.josm.io.NetworkManager;
    1919import org.openstreetmap.josm.io.OnlineResource;
     20import org.openstreetmap.josm.spi.preferences.Config;
    2021import org.openstreetmap.josm.tools.Shortcut;
    2122
     
    9192            // bounds defined? => use the bbox downloader
    9293            final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download data"));
    93             final Future<?> future = new DownloadTaskList().download(false /* no new layer */, areasToDownload, true, false, monitor);
     94            final Future<?> future = new DownloadTaskList(Config.getPref().getBoolean("update.data.zoom-after-download"))
     95                    .download(false /* no new layer */, areasToDownload, true, false, monitor);
    9496            waitFuture(future, monitor);
    9597        }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java

    r15152 r15205  
    5050    private final List<DownloadTask> tasks = new LinkedList<>();
    5151    private final List<Future<?>> taskFutures = new LinkedList<>();
     52    private final boolean zoomAfterDownload;
    5253    private ProgressMonitor progressMonitor;
     54
     55    /**
     56     * Constructs a new {@code DownloadTaskList}. Zooms to each download area.
     57     */
     58    public DownloadTaskList() {
     59        this(true);
     60    }
     61
     62    /**
     63     * Constructs a new {@code DownloadTaskList}.
     64     * @param zoomAfterDownload whether to zoom to each download area
     65     * @since 15205
     66     */
     67    public DownloadTaskList(boolean zoomAfterDownload) {
     68        this.zoomAfterDownload = zoomAfterDownload;
     69    }
    5370
    5471    private void addDownloadTask(ProgressMonitor progressMonitor, DownloadTask dt, Rectangle2D td, int i, int n) {
    5572        ProgressMonitor childProgress = progressMonitor.createSubTaskMonitor(1, false);
    5673        childProgress.setCustomText(tr("Download {0} of {1} ({2} left)", i, n, n - i));
     74        dt.setZoomAfterDownload(zoomAfterDownload);
    5775        Future<?> future = dt.download(new DownloadParams(), new Bounds(td), childProgress);
    5876        taskFutures.add(future);
     
    109127        progressMonitor.beginTask(tr("Updating data"));
    110128        try {
    111             List<Rectangle2D> rects = new ArrayList<>(areas.size());
    112             for (Area a : areas) {
    113                 rects.add(a.getBounds2D());
    114             }
    115 
     129            List<Rectangle2D> rects = areas.stream().map(Area::getBounds2D).collect(Collectors.toList());
    116130            return download(newLayer, rects, osmData, gpxData, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
    117131        } finally {
Note: See TracChangeset for help on using the changeset viewer.