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

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

see #15182 - deprecate Main.getLayerManager(). Replacement: gui.MainApplication.getLayerManager()

  • Property svn:eol-style set to native
File size: 2.1 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.gui.MainApplication;
14import org.openstreetmap.josm.io.OnlineResource;
15
16/**
17 * Action that downloads the notes within the current view from the server.
18 *
19 * No interaction is required.
20 */
21public final class DownloadNotesInViewAction extends JosmAction {
22
23 private DownloadNotesInViewAction(String iconName) {
24 super(tr("Download notes in current view"), iconName, tr("Download notes in current view"), null, false,
25 "dialogs/notes/download_in_view", true);
26 }
27
28 /**
29 * Constructs a new {@code DownloadNotesInViewAction} with note icon.
30 * @return a new {@code DownloadNotesInViewAction} with note icon
31 */
32 public static DownloadNotesInViewAction newActionWithNoteIcon() {
33 return new DownloadNotesInViewAction("dialogs/notes/note_open");
34 }
35
36 /**
37 * Constructs a new {@code DownloadNotesInViewAction} with download icon.
38 * @return a new {@code DownloadNotesInViewAction} with download icon
39 */
40 public static DownloadNotesInViewAction newActionWithDownloadIcon() {
41 return new DownloadNotesInViewAction("download");
42 }
43
44 @Override
45 public void actionPerformed(ActionEvent e) {
46 final Bounds bounds = MainApplication.getMap().mapView.getRealBounds();
47 DownloadNotesTask task = new DownloadNotesTask();
48 task.setZoomAfterDownload(false);
49 Future<?> future = task.download(false, bounds, null);
50 MainApplication.worker.submit(new PostDownloadHandler(task, future));
51 }
52
53 @Override
54 protected void updateEnabledState() {
55 setEnabled(getLayerManager().getActiveLayer() != null
56 && !Main.isOffline(OnlineResource.OSM_API));
57 }
58}
Note: See TracBrowser for help on using the repository browser.