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

Last change on this file since 8576 was 8419, checked in by Don-vip, 9 years ago

Sonar: various code style cleanup:

  • fix copyright
  • classes that should be final
  • order of javadoc At-clauses
  • unexpected spaces before parenthesis
File size: 1.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.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 }
25
26 public static DownloadNotesInViewAction newActionWithNoteIcon() {
27 return new DownloadNotesInViewAction("dialogs/notes/note_open");
28 }
29
30 public static DownloadNotesInViewAction newActionWithDownloadIcon() {
31 return new DownloadNotesInViewAction("download");
32 }
33
34 @Override
35 public void actionPerformed(ActionEvent e) {
36 final Bounds bounds = Main.map.mapView.getRealBounds();
37 DownloadNotesTask task = new DownloadNotesTask();
38 Future<?> future = task.download(false, bounds, null);
39 Main.worker.submit(new PostDownloadHandler(task, future));
40 }
41
42 @Override
43 protected void updateEnabledState() {
44 setEnabled(Main.map != null && Main.map.mapView != null && !Main.isOffline(OnlineResource.OSM_API));
45 }
46}
Note: See TracBrowser for help on using the repository browser.