[8212] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
| 2 | package org.openstreetmap.josm.actions;
|
---|
| 3 |
|
---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
| 5 |
|
---|
| 6 | import java.awt.event.ActionEvent;
|
---|
| 7 | import java.util.concurrent.Future;
|
---|
| 8 |
|
---|
| 9 | import org.openstreetmap.josm.Main;
|
---|
| 10 | import org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask;
|
---|
| 11 | import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
|
---|
| 12 | import org.openstreetmap.josm.data.Bounds;
|
---|
| 13 | import org.openstreetmap.josm.io.OnlineResource;
|
---|
| 14 |
|
---|
| 15 | /**
|
---|
| 16 | * Action that downloads the notes within the current view from the server.
|
---|
| 17 | *
|
---|
| 18 | * No interaction is required.
|
---|
| 19 | */
|
---|
[8419] | 20 | public final class DownloadNotesInViewAction extends JosmAction {
|
---|
[8212] | 21 |
|
---|
| 22 | private DownloadNotesInViewAction(String iconName) {
|
---|
[8663] | 23 | super(tr("Download notes in current view"), iconName, tr("Download notes in current view"), null, false,
|
---|
| 24 | "dialogs/notes/download_in_view", true);
|
---|
[8212] | 25 | }
|
---|
| 26 |
|
---|
| 27 | public static DownloadNotesInViewAction newActionWithNoteIcon() {
|
---|
| 28 | return new DownloadNotesInViewAction("dialogs/notes/note_open");
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | public static DownloadNotesInViewAction newActionWithDownloadIcon() {
|
---|
| 32 | return new DownloadNotesInViewAction("download");
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | @Override
|
---|
| 36 | public void actionPerformed(ActionEvent e) {
|
---|
| 37 | final Bounds bounds = Main.map.mapView.getRealBounds();
|
---|
| 38 | DownloadNotesTask task = new DownloadNotesTask();
|
---|
| 39 | Future<?> future = task.download(false, bounds, null);
|
---|
| 40 | Main.worker.submit(new PostDownloadHandler(task, future));
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | @Override
|
---|
| 44 | protected void updateEnabledState() {
|
---|
[10318] | 45 | setEnabled(Main.getLayerManager().getActiveLayer() != null
|
---|
[9276] | 46 | && !Main.isOffline(OnlineResource.OSM_API));
|
---|
[8212] | 47 | }
|
---|
| 48 | }
|
---|