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

Last change on this file since 6426 was 6380, checked in by Don-vip, 10 years ago

update license/copyright information

  • 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.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.DownloadOsmTask;
14import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
15import org.openstreetmap.josm.data.Bounds;
16import org.openstreetmap.josm.gui.download.DownloadDialog;
17import org.openstreetmap.josm.tools.Shortcut;
18
19/**
20 * Action that opens a connection to the osm server and downloads map data.
21 *
22 * An dialog is displayed asking the user to specify a rectangle to grab.
23 * The url and account settings from the preferences are used.
24 *
25 * @author imi
26 */
27public class DownloadAction extends JosmAction {
28 public DownloadAction() {
29 super(tr("Download from OSM..."), "download", tr("Download map data from the OSM server."),
30 Shortcut.registerShortcut("file:download", tr("File: {0}", tr("Download from OSM...")), KeyEvent.VK_DOWN, Shortcut.CTRL_SHIFT), true);
31 putValue("help", ht("/Action/Download"));
32 }
33
34 @Override
35 public void actionPerformed(ActionEvent e) {
36 DownloadDialog dialog = DownloadDialog.getInstance();
37 dialog.restoreSettings();
38 dialog.setVisible(true);
39 if (! dialog.isCanceled()) {
40 dialog.rememberSettings();
41 Bounds area = dialog.getSelectedDownloadArea();
42 if (dialog.isDownloadOsmData()) {
43 DownloadOsmTask task = new DownloadOsmTask();
44 Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
45 Main.worker.submit(new PostDownloadHandler(task, future));
46 }
47 if (dialog.isDownloadGpxData()) {
48 DownloadGpsTask task = new DownloadGpsTask();
49 Future<?> future = task.download(dialog.isNewLayerRequired(),area, null);
50 Main.worker.submit(new PostDownloadHandler(task, future));
51 }
52 }
53 }
54}
Note: See TracBrowser for help on using the repository browser.