Changeset 8908 in josm for trunk/src/org
- Timestamp:
- 2015-10-19T16:55:23+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions/downloadtasks
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTask.java
r8840 r8908 9 9 /** 10 10 * Common abstract implementation of other download tasks 11 * @param <T> The downloaded data type 11 12 * @since 2322 12 13 */ 13 public abstract class AbstractDownloadTask implements DownloadTask {14 public abstract class AbstractDownloadTask<T> implements DownloadTask { 14 15 private List<Object> errorMessages; 15 16 private boolean canceled; 16 17 private boolean failed; 18 protected T downloadedData; 17 19 18 20 public AbstractDownloadTask() { … … 36 38 } 37 39 38 protected void rememberErrorMessage(String message) {40 protected final void rememberErrorMessage(String message) { 39 41 errorMessages.add(message); 40 42 } 41 43 42 protected void rememberException(Exception exception) {44 protected final void rememberException(Exception exception) { 43 45 errorMessages.add(exception); 46 } 47 48 protected final void rememberDownloadedData(T data) { 49 this.downloadedData = data; 50 } 51 52 /** 53 * Replies the downloaded data. 54 * @return The downloaded data. 55 */ 56 public final T getDownloadedData() { 57 return downloadedData; 44 58 } 45 59 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r8904 r8908 33 33 * Task allowing to download GPS data. 34 34 */ 35 public class DownloadGpsTask extends AbstractDownloadTask {35 public class DownloadGpsTask extends AbstractDownloadTask<GpxData> { 36 36 37 37 private DownloadTask downloadTask; … … 128 128 @Override 129 129 protected void finish() { 130 rememberDownloadedData(rawData); 130 131 if (isCanceled() || isFailed()) 131 132 return; -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java
r8855 r8908 15 15 import org.openstreetmap.josm.data.Bounds; 16 16 import org.openstreetmap.josm.data.notes.Note; 17 import org.openstreetmap.josm.data.osm.NoteData; 17 18 import org.openstreetmap.josm.data.preferences.IntegerProperty; 18 19 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 27 28 28 29 /** Task for downloading notes */ 29 public class DownloadNotesTask extends AbstractDownloadTask {30 public class DownloadNotesTask extends AbstractDownloadTask<NoteData> { 30 31 31 32 private static final String PATTERN_API_URL = "https?://.*/api/0.6/notes.*"; … … 38 39 private DownloadTask downloadTask; 39 40 41 /** 42 * Download a specific note by its id. 43 * @param id Note identifier 44 * @param progressMonitor progress monitor 45 * @return the future representing the asynchronous task 46 */ 40 47 public Future<?> download(long id, ProgressMonitor progressMonitor) { 41 48 final String url = OsmApi.getOsmApi().getBaseUrl() + "notes/" + id; … … 98 105 @Override 99 106 protected void finish() { 107 rememberDownloadedData(new NoteData(notesData)); 100 108 if (isCanceled() || isFailed()) { 101 109 return; -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r8846 r8908 36 36 * Run in the worker thread. 37 37 */ 38 public class DownloadOsmTask extends AbstractDownloadTask {38 public class DownloadOsmTask extends AbstractDownloadTask<DataSet> { 39 39 40 40 protected static final String PATTERN_OSM_API_URL = "https?://.*/api/0.6/(map|nodes?|ways?|relations?|\\*).*"; … … 44 44 45 45 protected Bounds currentBounds; 46 protected DataSet downloadedData;47 46 protected DownloadTask downloadTask; 48 47 … … 66 65 return super.getTitle(); 67 66 } 68 }69 70 protected void rememberDownloadedData(DataSet ds) {71 this.downloadedData = ds;72 }73 74 /**75 * Replies the {@link DataSet} containing the downloaded OSM data.76 * @return The {@link DataSet} containing the downloaded OSM data.77 */78 public DataSet getDownloadedData() {79 return downloadedData;80 67 } 81 68
Note:
See TracChangeset
for help on using the changeset viewer.