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

Last change on this file since 2683 was 2512, checked in by stoecker, 14 years ago

i18n updated, fixed files to reduce problems when applying patches, fix #4017

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
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;
10import java.util.logging.Logger;
11
12import org.openstreetmap.josm.Main;
13import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
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 private static final Logger logger = Logger.getLogger(DownloadAction.class.getName());
30
31 public DownloadAction() {
32 super(tr("Download from OSM..."), "download", tr("Download map data from the OSM server."),
33 Shortcut.registerShortcut("file:download", tr("File: {0}", tr("Download from OSM...")), KeyEvent.VK_D, Shortcut.GROUPS_ALT1+Shortcut.GROUP_HOTKEY), true);
34 putValue("help", ht("/Action/Download"));
35 }
36
37 public void actionPerformed(ActionEvent e) {
38 DownloadDialog dialog = DownloadDialog.getInstance();
39 dialog.restoreSettings();
40 dialog.setVisible(true);
41 if (! dialog.isCanceled()) {
42 dialog.rememberSettings();
43 Bounds area = dialog.getSelectedDownloadArea();
44 if (dialog.isDownloadOsmData()) {
45 DownloadOsmTask task = new DownloadOsmTask();
46 Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
47 Main.worker.submit(new PostDownloadHandler(task, future));
48 }
49 if (dialog.isDownloadGpxData()) {
50 DownloadGpsTask task = new DownloadGpsTask();
51 Future<?> future = task.download(dialog.isNewLayerRequired(),area, null);
52 Main.worker.submit(new PostDownloadHandler(task, future));
53 }
54 }
55 }
56}
Note: See TracBrowser for help on using the repository browser.