source: josm/trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java@ 1728

Last change on this file since 1728 was 1677, checked in by stoecker, 15 years ago

remove all these ugly tab stops introduced in the last half year

File size: 2.0 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.GridBagLayout;
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9
10import javax.swing.JCheckBox;
11import javax.swing.JLabel;
12import javax.swing.JPanel;
13import javax.swing.JTextField;
14
15import org.openstreetmap.josm.Main;
16import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
17import org.openstreetmap.josm.gui.ExtendedDialog;
18import org.openstreetmap.josm.tools.GBC;
19import org.openstreetmap.josm.tools.Shortcut;
20
21/**
22 * Open an URL input dialog and load data from the given URL.
23 *
24 * @author imi
25 */
26public class OpenLocationAction extends JosmAction {
27
28 /**
29 * Create an open action. The name is "Open a file".
30 */
31 public OpenLocationAction() {
32 super(tr("Open Location..."), "openlocation", tr("Open an URL."),
33 Shortcut.registerShortcut("system:open_location", tr("File: {0}", tr("Open Location...")), KeyEvent.VK_L, Shortcut.GROUP_MENU), true);
34 }
35
36 public void actionPerformed(ActionEvent e) {
37
38 JCheckBox layer = new JCheckBox(tr("Separate Layer"));
39 layer.setSelected(Main.pref.getBoolean("download.newlayer"));
40 JPanel all = new JPanel(new GridBagLayout());
41 all.add(new JLabel(tr("Enter URL to download:")), GBC.eol());
42 JTextField urltext = new JTextField(40);
43 all.add(urltext, GBC.eol());
44 all.add(layer, GBC.eol());
45 int answer = new ExtendedDialog(Main.parent,
46 tr("Download Location"),
47 all,
48 new String[] {tr("Download URL"), tr("Cancel")},
49 new String[] {"download.png", "cancel.png"}).getValue();
50 if (answer != 1) return;
51 openUrl(layer.isSelected(), urltext.getText());
52 }
53
54 /**
55 * Open the given file.
56 */
57 public void openUrl(boolean new_layer, String url) {
58 new DownloadOsmTask().loadUrl(new_layer, url);
59 }
60
61}
Note: See TracBrowser for help on using the repository browser.