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

Last change on this file since 14397 was 14121, checked in by Don-vip, 6 years ago

see #15229 - deprecate all Main methods related to network features. New NetworkManager class

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