1 | // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others
|
---|
2 | package cadastre_fr;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.event.ActionEvent;
|
---|
7 | import java.awt.event.KeyEvent;
|
---|
8 |
|
---|
9 | import javax.swing.JOptionPane;
|
---|
10 |
|
---|
11 | import org.openstreetmap.josm.Main;
|
---|
12 | import org.openstreetmap.josm.actions.JosmAction;
|
---|
13 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
14 |
|
---|
15 | public class MenuActionGrab extends JosmAction {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Action calling the wms grabber for cadastre.gouv.fr
|
---|
19 | */
|
---|
20 | private static final long serialVersionUID = 1L;
|
---|
21 |
|
---|
22 | public static String name = "Cadastre grab";
|
---|
23 |
|
---|
24 | public MenuActionGrab() {
|
---|
25 | super(tr(name), "cadastre_small", tr("Download Image from French Cadastre WMS"),
|
---|
26 | Shortcut.registerShortcut("cadastre:grab", tr("Cadastre: {0}", tr("Download Image from French Cadastre WMS")),
|
---|
27 | KeyEvent.VK_F11, Shortcut.GROUP_DIRECT), false);
|
---|
28 | }
|
---|
29 |
|
---|
30 | public void actionPerformed(ActionEvent e) {
|
---|
31 | if (Main.map != null) {
|
---|
32 | if (CadastrePlugin.isCadastreProjection()) {
|
---|
33 | WMSLayer wmsLayer = WMSDownloadAction.getLayer();
|
---|
34 | if (wmsLayer != null)
|
---|
35 | DownloadWMSVectorImage.download(wmsLayer);
|
---|
36 | } else {
|
---|
37 | JOptionPane.showMessageDialog(Main.parent,
|
---|
38 | tr("To enable the cadastre WMS plugin, change\n"
|
---|
39 | + "the current projection to one of the cadastre\n"
|
---|
40 | + "projections and retry"));
|
---|
41 | }
|
---|
42 | } else
|
---|
43 | new MenuActionNewLocation().actionPerformed(e);
|
---|
44 | }
|
---|
45 |
|
---|
46 | }
|
---|