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

Last change on this file since 17335 was 17052, checked in by stoecker, 4 years ago

see #19836 - display main menu item for shortcut name

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