Changeset 11658 in josm


Ignore:
Timestamp:
2017-03-04T00:49:24+01:00 (2 months ago)
Author:
Don-vip
Message:

fix #13922 - Add (expert) option to not zoom to the new downloaded data

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

Legend:

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

    r11621 r11658  
    4848            if (dialog.isDownloadOsmData()) {
    4949                DownloadOsmTask task = new DownloadOsmTask();
     50                task.setZoomAfterDownload(dialog.isZoomToDownloadedDataRequired());
    5051                Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
    5152                Main.worker.submit(new PostDownloadHandler(task, future));
     
    5354            if (dialog.isDownloadGpxData()) {
    5455                DownloadGpsTask task = new DownloadGpsTask();
     56                task.setZoomAfterDownload(dialog.isZoomToDownloadedDataRequired());
    5557                Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
    5658                Main.worker.submit(new PostDownloadHandler(task, future));
     
    5860            if (dialog.isDownloadNotes()) {
    5961                DownloadNotesTask task = new DownloadNotesTask();
     62                task.setZoomAfterDownload(dialog.isZoomToDownloadedDataRequired());
    6063                Future<?> future = task.download(false, area, null);
    6164                Main.worker.submit(new PostDownloadHandler(task, future));
  • trunk/src/org/openstreetmap/josm/actions/OverpassDownloadAction.java

    r10782 r11658  
    8181            Bounds area = dialog.getSelectedDownloadArea();
    8282            DownloadOsmTask task = new DownloadOsmTask();
     83            task.setZoomAfterDownload(dialog.isZoomToDownloadedDataRequired());
    8384            Future<?> future = task.download(
    8485                    new OverpassDownloadReader(area, OverpassServerPreference.getOverpassServer(), dialog.getOverpassQuery()),
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTask.java

    r10305 r11658  
    1717    private boolean failed;
    1818    protected T downloadedData;
     19    protected boolean zoomAfterDownload = true;
    1920
    2021    /**
     
    7576    public final T getDownloadedData() {
    7677        return downloadedData;
     78    }
     79
     80    /**
     81     * Sets whether the map view will zoom to download area after download
     82     * @param zoomAfterDownload if true, the map view will zoom to download area after download
     83     * @since 11658
     84     */
     85    public final void setZoomAfterDownload(boolean zoomAfterDownload) {
     86        this.zoomAfterDownload = zoomAfterDownload;
    7787    }
    7888
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

    r11124 r11658  
    163163                mergeLayer.mergeFrom(layer);
    164164                mergeLayer.invalidate();
    165                 if (Main.map != null) {
     165                if (Main.map != null && zoomAfterDownload) {
    166166                    Main.map.mapView.scheduleZoomTo(new ViewportData(layer.getViewProjectionBounds()));
    167167                }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java

    r10463 r11658  
    1414import org.openstreetmap.josm.Main;
    1515import org.openstreetmap.josm.data.Bounds;
     16import org.openstreetmap.josm.data.ViewportData;
    1617import org.openstreetmap.josm.data.notes.Note;
    1718import org.openstreetmap.josm.data.osm.NoteData;
     
    117118            if (!noteLayers.isEmpty()) {
    118119                noteLayers.get(0).getNoteData().addNotes(notesData);
     120                if (Main.map != null && zoomAfterDownload) {
     121                    Main.map.mapView.scheduleZoomTo(new ViewportData(noteLayers.get(0).getViewProjectionBounds()));
     122                }
    119123            } else {
    120124                Main.getLayerManager().addLayer(new NoteLayer(notesData, tr("Notes")));
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r11627 r11658  
    115115     */
    116116    public Future<?> download(OsmServerReader reader, boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor) {
    117         return download(new DownloadTask(newLayer, reader, progressMonitor), downloadArea);
     117        return download(new DownloadTask(newLayer, reader, progressMonitor, zoomAfterDownload), downloadArea);
    118118    }
    119119
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r11277 r11658  
    6363    private static final BooleanProperty DOWNLOAD_NOTES = new BooleanProperty("download.notes", false);
    6464    private static final BooleanProperty DOWNLOAD_NEWLAYER = new BooleanProperty("download.newlayer", false);
     65    private static final BooleanProperty DOWNLOAD_ZOOMTODATA = new BooleanProperty("download.zoomtodata", true);
    6566
    6667    /** the unique instance of the download dialog */
     
    8485    protected JCheckBox cbNewLayer;
    8586    protected JCheckBox cbStartup;
     87    protected JCheckBox cbZoomToDownloadedData;
    8688    protected final JLabel sizeCheck = new JLabel();
    8789    protected transient Bounds currentBounds;
     
    161163        cbStartup.addActionListener(e -> DOWNLOAD_AUTORUN.put(cbStartup.isSelected()));
    162164
     165        cbZoomToDownloadedData = new JCheckBox(tr("Zoom to downloaded data"));
     166        cbZoomToDownloadedData.setToolTipText(tr("Select to zoom to entire newly downloaded data."));
     167
    163168        pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5));
    164169        pnl.add(cbStartup, GBC.std().anchor(GBC.WEST).insets(15, 5, 5, 5));
     170        pnl.add(cbZoomToDownloadedData, GBC.std().anchor(GBC.WEST).insets(15, 5, 5, 5));
     171
     172        ExpertToggleAction.addVisibilitySwitcher(cbZoomToDownloadedData);
    165173
    166174        pnl.add(sizeCheck, GBC.eol().anchor(GBC.EAST).insets(5, 5, 5, 2));
     
    192200        InputMapUtils.addEnterActionWhenAncestor(cbDownloadNotes, actDownload);
    193201        InputMapUtils.addEnterActionWhenAncestor(cbNewLayer, actDownload);
     202        InputMapUtils.addEnterActionWhenAncestor(cbStartup, actDownload);
     203        InputMapUtils.addEnterActionWhenAncestor(cbZoomToDownloadedData, actDownload);
    194204
    195205        // -- cancel button
     
    339349
    340350    /**
     351     * Replies true if the user requires to zoom to new downloaded data
     352     *
     353     * @return true if the user requires to zoom to new downloaded data
     354     * @since 11658
     355     */
     356    public boolean isZoomToDownloadedDataRequired() {
     357        return cbZoomToDownloadedData.isSelected();
     358    }
     359
     360    /**
    341361     * Adds a new download area selector to the download dialog
    342362     *
     
    367387        DOWNLOAD_NOTES.put(cbDownloadNotes.isSelected());
    368388        DOWNLOAD_NEWLAYER.put(cbNewLayer.isSelected());
     389        DOWNLOAD_ZOOMTODATA.put(cbZoomToDownloadedData.isSelected());
    369390        if (currentBounds != null) {
    370391            Main.pref.put("osm-download.bounds", currentBounds.encodeAsString(";"));
     
    381402        cbNewLayer.setSelected(DOWNLOAD_NEWLAYER.get());
    382403        cbStartup.setSelected(isAutorunEnabled());
     404        cbZoomToDownloadedData.setSelected(DOWNLOAD_ZOOMTODATA.get());
    383405        int idx = Utils.clamp(DOWNLOAD_TAB.get(), 0, tpDownloadAreaSelectors.getTabCount() - 1);
    384406        tpDownloadAreaSelectors.setSelectedIndex(idx);
Note: See TracChangeset for help on using the changeset viewer.