Ticket #21634: download-along-less-confirmations.patch

File download-along-less-confirmations.patch, 6.1 KB (added by Amanda McCann <amanda@…>, 4 years ago)

patch against r18327

  • src/org/openstreetmap/josm/actions/DownloadAlongAction.java

     
    125125     * @param gpxDownload Set to true if GPX data should be downloaded
    126126     * @param title the title string for the confirmation dialog
    127127     * @param newLayer Set to true if all areas should be put into a single new layer
     128     * @param confirmNumDownloads Require user to confirm if more than this many download requests, otherwise don't ask
    128129     */
    129130    protected static void confirmAndDownloadAreas(Area a, double maxArea, boolean osmDownload, boolean gpxDownload, String title,
    130             boolean newLayer) {
     131            boolean newLayer, int confirmNumDownloads) {
    131132        List<Rectangle2D> toDownload = new ArrayList<>();
    132133        addToDownload(a, a.getBounds(), toDownload, maxArea);
    133134        if (toDownload.isEmpty()) {
    134135            return;
    135136        }
    136         if (toDownload.size() > 1) {
     137        if (toDownload.size() > confirmNumDownloads) {
    137138            JPanel msg = new JPanel(new GridBagLayout());
    138139            msg.add(new JLabel(trn(
    139140                    "<html>This action will require {0} individual<br>download request. Do you wish<br>to continue?</html>",
     
    185186     * @param panel the panel that was displayed to the user and now contains his selections
    186187     * @param confirmTitle the title to display in the confirmation panel
    187188     * @param newLayer Set to true if all areas should be put into a single new layer
     189     * @param confirmNumDownloads Require user to confirm if more than this many download requests, otherwise don't ask
    188190     * @return the task or null if canceled by user
    189191     */
    190     protected PleaseWaitRunnable createCalcTask(Path2D alongPath, DownloadAlongPanel panel, String confirmTitle, boolean newLayer) {
     192    protected PleaseWaitRunnable createCalcTask(Path2D alongPath, DownloadAlongPanel panel, String confirmTitle, boolean newLayer, int confirmNumDownloads) {
    191193        /*
    192194         * Find the average latitude for the data we're contemplating, so we can know how many
    193195         * metres per degree of longitude we have.
     
    253255                    return;
    254256                }
    255257                confirmAndDownloadAreas(new Area(downloadPath), maxArea, panel.isDownloadOsmData(), panel.isDownloadGpxData(),
    256                         confirmTitle, newLayer);
     258                        confirmTitle, newLayer, confirmNumDownloads);
    257259            }
    258260
    259261            /**
  • src/org/openstreetmap/josm/actions/DownloadAlongWayAction.java

     
    1616import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    1717import org.openstreetmap.josm.gui.help.HelpUtil;
    1818import org.openstreetmap.josm.gui.layer.gpx.DownloadAlongPanel;
     19import org.openstreetmap.josm.spi.preferences.Config;
    1920import org.openstreetmap.josm.tools.Shortcut;
    2021
    2122/**
     
    2829    private static final String PREF_DOWNLOAD_ALONG_WAY_DISTANCE = "downloadAlongWay.distance";
    2930    private static final String PREF_DOWNLOAD_ALONG_WAY_AREA = "downloadAlongWay.area";
    3031
     32        // Ask user to confirm the download if there are more than this many requests.
     33    private static final String PREF_DOWNLOAD_ALONG_WAY_DL_REQ_CONFIRM = "downloadAlongWay.numDownloadRequestConfirmation";
     34
    3135    private static final String PREF_DOWNLOAD_ALONG_WAY_OSM = "downloadAlongWay.download.osm";
    3236    private static final String PREF_DOWNLOAD_ALONG_WAY_GPS = "downloadAlongWay.download.gps";
    3337
     
    7175                }
    7276            }
    7377        }
    74         return createCalcTask(alongPath, panel, tr("Download from OSM along selected ways"), 1 == ret);
     78        int confirmNumDownloads = Config.getPref().getInt(PREF_DOWNLOAD_ALONG_WAY_DL_REQ_CONFIRM, 1);
     79        return createCalcTask(alongPath, panel, tr("Download from OSM along selected ways"), 1 == ret, confirmNumDownloads);
    7580    }
    7681
    7782    @Override
  • src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackAction.java

     
    1212import javax.swing.Action;
    1313import javax.swing.JMenuItem;
    1414
    15 import org.openstreetmap.josm.actions.DownloadAlongAction;
     15mport org.openstreetmap.josm.actions.DownloadAlongAction;
    1616import org.openstreetmap.josm.data.gpx.GpxData;
    1717import org.openstreetmap.josm.data.gpx.WayPoint;
    1818import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     
    1919import org.openstreetmap.josm.gui.help.HelpUtil;
    2020import org.openstreetmap.josm.gui.layer.GpxLayer;
    2121import org.openstreetmap.josm.gui.layer.Layer;
     22import org.openstreetmap.josm.spi.preferences.Config;
    2223import org.openstreetmap.josm.tools.Utils;
    2324
    2425/**
     
    3940    private static final String PREF_DOWNLOAD_ALONG_TRACK_DISTANCE = "downloadAlongTrack.distance";
    4041    private static final String PREF_DOWNLOAD_ALONG_TRACK_AREA = "downloadAlongTrack.area";
    4142    private static final String PREF_DOWNLOAD_ALONG_TRACK_NEAR = "downloadAlongTrack.near";
     43        // Ask user to confirm the download if there are more than this many requests.
     44    private static final String PREF_DOWNLOAD_ALONG_TRACK_DL_REQ_CONFIRM = "downloadAlongTrack.numDownloadRequestConfirmation";
    4245
     46
    4347    private final transient Collection<GpxData> data;
    4448
    4549    /**
     
    8589                gpxPath.closePath();
    8690            });
    8791        }
    88         return createCalcTask(gpxPath, panel, tr("Download from OSM along this track"), 1 == ret);
     92        int confirmNumDownloads = Config.getPref().getInt(PREF_DOWNLOAD_ALONG_TRACK_DL_REQ_CONFIRM, 1);
     93        return createCalcTask(gpxPath, panel, tr("Download from OSM along this track"), 1 == ret, confirmNumDownloads);
    8994    }
    9095
    9196    @Override