Ticket #21634: download-along-less-confirmations.patch
File download-along-less-confirmations.patch, 6.1 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/actions/DownloadAlongAction.java
125 125 * @param gpxDownload Set to true if GPX data should be downloaded 126 126 * @param title the title string for the confirmation dialog 127 127 * @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 128 129 */ 129 130 protected static void confirmAndDownloadAreas(Area a, double maxArea, boolean osmDownload, boolean gpxDownload, String title, 130 boolean newLayer ) {131 boolean newLayer, int confirmNumDownloads) { 131 132 List<Rectangle2D> toDownload = new ArrayList<>(); 132 133 addToDownload(a, a.getBounds(), toDownload, maxArea); 133 134 if (toDownload.isEmpty()) { 134 135 return; 135 136 } 136 if (toDownload.size() > 1) {137 if (toDownload.size() > confirmNumDownloads) { 137 138 JPanel msg = new JPanel(new GridBagLayout()); 138 139 msg.add(new JLabel(trn( 139 140 "<html>This action will require {0} individual<br>download request. Do you wish<br>to continue?</html>", … … 185 186 * @param panel the panel that was displayed to the user and now contains his selections 186 187 * @param confirmTitle the title to display in the confirmation panel 187 188 * @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 188 190 * @return the task or null if canceled by user 189 191 */ 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) { 191 193 /* 192 194 * Find the average latitude for the data we're contemplating, so we can know how many 193 195 * metres per degree of longitude we have. … … 253 255 return; 254 256 } 255 257 confirmAndDownloadAreas(new Area(downloadPath), maxArea, panel.isDownloadOsmData(), panel.isDownloadGpxData(), 256 confirmTitle, newLayer );258 confirmTitle, newLayer, confirmNumDownloads); 257 259 } 258 260 259 261 /** -
src/org/openstreetmap/josm/actions/DownloadAlongWayAction.java
16 16 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 17 17 import org.openstreetmap.josm.gui.help.HelpUtil; 18 18 import org.openstreetmap.josm.gui.layer.gpx.DownloadAlongPanel; 19 import org.openstreetmap.josm.spi.preferences.Config; 19 20 import org.openstreetmap.josm.tools.Shortcut; 20 21 21 22 /** … … 28 29 private static final String PREF_DOWNLOAD_ALONG_WAY_DISTANCE = "downloadAlongWay.distance"; 29 30 private static final String PREF_DOWNLOAD_ALONG_WAY_AREA = "downloadAlongWay.area"; 30 31 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 31 35 private static final String PREF_DOWNLOAD_ALONG_WAY_OSM = "downloadAlongWay.download.osm"; 32 36 private static final String PREF_DOWNLOAD_ALONG_WAY_GPS = "downloadAlongWay.download.gps"; 33 37 … … 71 75 } 72 76 } 73 77 } 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); 75 80 } 76 81 77 82 @Override -
src/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackAction.java
12 12 import javax.swing.Action; 13 13 import javax.swing.JMenuItem; 14 14 15 import org.openstreetmap.josm.actions.DownloadAlongAction;15 mport org.openstreetmap.josm.actions.DownloadAlongAction; 16 16 import org.openstreetmap.josm.data.gpx.GpxData; 17 17 import org.openstreetmap.josm.data.gpx.WayPoint; 18 18 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 19 19 import org.openstreetmap.josm.gui.help.HelpUtil; 20 20 import org.openstreetmap.josm.gui.layer.GpxLayer; 21 21 import org.openstreetmap.josm.gui.layer.Layer; 22 import org.openstreetmap.josm.spi.preferences.Config; 22 23 import org.openstreetmap.josm.tools.Utils; 23 24 24 25 /** … … 39 40 private static final String PREF_DOWNLOAD_ALONG_TRACK_DISTANCE = "downloadAlongTrack.distance"; 40 41 private static final String PREF_DOWNLOAD_ALONG_TRACK_AREA = "downloadAlongTrack.area"; 41 42 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"; 42 45 46 43 47 private final transient Collection<GpxData> data; 44 48 45 49 /** … … 85 89 gpxPath.closePath(); 86 90 }); 87 91 } 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); 89 94 } 90 95 91 96 @Override