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

Last change on this file since 2331 was 2331, checked in by Gubaer, 15 years ago

Cleanup in DownloadAction and DownloadDialog
Added context-sensitive help to DownloadDialog

  • Property svn:eol-style set to native
File size: 2.5 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.BorderLayout;
8import java.awt.Dimension;
9import java.awt.event.ActionEvent;
10import java.awt.event.KeyEvent;
11import java.util.concurrent.Future;
12import java.util.logging.Logger;
13
14import javax.swing.JOptionPane;
15import javax.swing.JPanel;
16
17import org.openstreetmap.josm.Main;
18import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
19import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
20import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
21import org.openstreetmap.josm.data.Bounds;
22import org.openstreetmap.josm.gui.ExtendedDialog;
23import org.openstreetmap.josm.gui.download.DownloadDialog;
24import org.openstreetmap.josm.tools.Shortcut;
25import org.openstreetmap.josm.tools.WindowGeometry;
26
27/**
28 * Action that opens a connection to the osm server and downloads map data.
29 *
30 * An dialog is displayed asking the user to specify a rectangle to grab.
31 * The url and account settings from the preferences are used.
32 *
33 * @author imi
34 */
35public class DownloadAction extends JosmAction {
36 private static final Logger logger = Logger.getLogger(DownloadAction.class.getName());
37
38 public DownloadAction() {
39 super(tr("Download from OSM..."), "download", tr("Download map data from the OSM server."),
40 Shortcut.registerShortcut("file:download", tr("File: {0}", tr("Download from OSM...")), KeyEvent.VK_D, Shortcut.GROUPS_ALT1+Shortcut.GROUP_HOTKEY), true);
41 putValue("help", ht("/Action/Download"));
42 }
43
44 public void actionPerformed(ActionEvent e) {
45 DownloadDialog dialog = DownloadDialog.getInstance();
46 dialog.setVisible(true);
47 if (! dialog.isCanceled()) {
48 dialog.rememberSettings();
49 Bounds area = dialog.getSelectedDownloadArea();
50 if (dialog.isDownloadOsmData()) {
51 DownloadOsmTask task = new DownloadOsmTask();
52 Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
53 Main.worker.submit(new PostDownloadHandler(task, future));
54 }
55 if (dialog.isDownloadGpxData()) {
56 DownloadGpsTask task = new DownloadGpsTask();
57 Future<?> future = task.download(dialog.isNewLayerRequired(),area, null);
58 Main.worker.submit(new PostDownloadHandler(task, future));
59 }
60 }
61 }
62}
Note: See TracBrowser for help on using the repository browser.