source: josm/trunk/src/org/openstreetmap/josm/actions/DownloadNotesInViewAction.java@ 12052

Last change on this file since 12052 was 11743, checked in by Don-vip, 7 years ago

fix #13922 - make sure Download*InViewAction download their respective data without changing the current view

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.util.concurrent.Future;
8
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask;
11import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
12import org.openstreetmap.josm.data.Bounds;
13import 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 */
20public final class DownloadNotesInViewAction extends JosmAction {
21
22 private DownloadNotesInViewAction(String iconName) {
23 super(tr("Download notes in current view"), iconName, tr("Download notes in current view"), null, false,
24 "dialogs/notes/download_in_view", true);
25 }
26
27 /**
28 * Constructs a new {@code DownloadNotesInViewAction} with note icon.
29 * @return a new {@code DownloadNotesInViewAction} with note icon
30 */
31 public static DownloadNotesInViewAction newActionWithNoteIcon() {
32 return new DownloadNotesInViewAction("dialogs/notes/note_open");
33 }
34
35 /**
36 * Constructs a new {@code DownloadNotesInViewAction} with download icon.
37 * @return a new {@code DownloadNotesInViewAction} with download icon
38 */
39 public static DownloadNotesInViewAction newActionWithDownloadIcon() {
40 return new DownloadNotesInViewAction("download");
41 }
42
43 @Override
44 public void actionPerformed(ActionEvent e) {
45 final Bounds bounds = Main.map.mapView.getRealBounds();
46 DownloadNotesTask task = new DownloadNotesTask();
47 task.setZoomAfterDownload(false);
48 Future<?> future = task.download(false, bounds, null);
49 Main.worker.submit(new PostDownloadHandler(task, future));
50 }
51
52 @Override
53 protected void updateEnabledState() {
54 setEnabled(Main.getLayerManager().getActiveLayer() != null
55 && !Main.isOffline(OnlineResource.OSM_API));
56 }
57}
Note: See TracBrowser for help on using the repository browser.