source: josm/trunk/src/org/openstreetmap/josm/actions/DownloadAction.java@ 9629

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

fix remaining checkstyle issues

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9import java.util.concurrent.Future;
10
11import org.openstreetmap.josm.Main;
12import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
13import org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTask;
14import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
15import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
16import org.openstreetmap.josm.data.Bounds;
17import org.openstreetmap.josm.gui.download.DownloadDialog;
18import org.openstreetmap.josm.tools.Shortcut;
19
20/**
21 * Action that opens a connection to the osm server and downloads map data.
22 *
23 * An dialog is displayed asking the user to specify a rectangle to grab.
24 * The url and account settings from the preferences are used.
25 *
26 * @author imi
27 */
28public class DownloadAction extends JosmAction {
29
30 /**
31 * Constructs a new {@code DownloadAction}.
32 */
33 public DownloadAction() {
34 super(tr("Download from OSM..."), "download", tr("Download map data from the OSM server."),
35 // CHECKSTYLE.OFF: LineLength
36 Shortcut.registerShortcut("file:download", tr("File: {0}", tr("Download from OSM...")), KeyEvent.VK_DOWN, Shortcut.CTRL_SHIFT), true);
37 // CHECKSTYLE.ON: LineLength
38 putValue("help", ht("/Action/Download"));
39 }
40
41 @Override
42 public void actionPerformed(ActionEvent e) {
43 DownloadDialog dialog = DownloadDialog.getInstance();
44 dialog.restoreSettings();
45 dialog.setVisible(true);
46 if (!dialog.isCanceled()) {
47 dialog.rememberSettings();
48 Bounds area = dialog.getSelectedDownloadArea();
49 if (dialog.isDownloadOsmData()) {
50 DownloadOsmTask task = new DownloadOsmTask();
51 Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
52 Main.worker.submit(new PostDownloadHandler(task, future));
53 }
54 if (dialog.isDownloadGpxData()) {
55 DownloadGpsTask task = new DownloadGpsTask();
56 Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
57 Main.worker.submit(new PostDownloadHandler(task, future));
58 }
59 if (dialog.isDownloadNotes()) {
60 DownloadNotesTask task = new DownloadNotesTask();
61 Future<?> future = task.download(false, area, null);
62 Main.worker.submit(new PostDownloadHandler(task, future));
63 }
64 }
65 }
66}
Note: See TracBrowser for help on using the repository browser.