source: osm/applications/editors/josm/plugins/mirrored_download/src/mirrored_download/DownloadAction2.java@ 27906

Last change on this file since 27906 was 27906, checked in by stoecker, 13 years ago

fix toolbar issues

File size: 2.2 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package mirrored_download;
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.actions.JosmAction;
12
13import org.openstreetmap.josm.Main;
14import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
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 DownloadAction2 extends JosmAction {
29 public DownloadAction2() {
30 super(tr("Download from OSM mirror..."), null, tr("Download map data from the OSM server."),
31 Shortcut.registerShortcut("mirror:download", tr("File: {0}", tr("Download from OSM mirror...")), KeyEvent.VK_DOWN, Shortcut.ALT_SHIFT),
32 true, "mirroreddownload/download", true);
33 putValue("help", ht("/Action/MirroredDownload"));
34 }
35
36 public void actionPerformed(ActionEvent e) {
37 DownloadDialog dialog = DownloadDialog.getInstance();
38 dialog.restoreSettings();
39 dialog.setVisible(true);
40 if (! dialog.isCanceled()) {
41 dialog.rememberSettings();
42 Bounds area = dialog.getSelectedDownloadArea();
43 if (dialog.isDownloadOsmData()) {
44 DownloadOsmTask2 task = new DownloadOsmTask2();
45 Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
46 Main.worker.submit(new PostDownloadHandler(task, future));
47 }
48 if (dialog.isDownloadGpxData()) {
49 DownloadGpsTask task = new DownloadGpsTask();
50 Future<?> future = task.download(dialog.isNewLayerRequired(),area, null);
51 Main.worker.submit(new PostDownloadHandler(task, future));
52 }
53 }
54 }
55}
Note: See TracBrowser for help on using the repository browser.