| 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 | import static org.openstreetmap.josm.tools.I18n.marktr; | 
|---|
| 6 |  | 
|---|
| 7 | import java.awt.event.ActionEvent; | 
|---|
| 8 | import java.awt.event.KeyEvent; | 
|---|
| 9 |  | 
|---|
| 10 | import javax.swing.JOptionPane; | 
|---|
| 11 |  | 
|---|
| 12 | import org.openstreetmap.josm.Main; | 
|---|
| 13 | import org.openstreetmap.josm.actions.JosmAction; | 
|---|
| 14 | import org.openstreetmap.josm.tools.Shortcut; | 
|---|
| 15 |  | 
|---|
| 16 | public class MenuActionGrab extends JosmAction { | 
|---|
| 17 |  | 
|---|
| 18 | /** | 
|---|
| 19 | * Action calling the wms grabber for cadastre.gouv.fr | 
|---|
| 20 | */ | 
|---|
| 21 | private static final long serialVersionUID = 1L; | 
|---|
| 22 |  | 
|---|
| 23 | public static String name = marktr("Cadastre grab"); | 
|---|
| 24 |  | 
|---|
| 25 | public MenuActionGrab() { | 
|---|
| 26 | super(tr(name), "cadastre_small", tr("Download Image from French Cadastre WMS"), | 
|---|
| 27 | Shortcut.registerShortcut("cadastre:grab", tr("Cadastre: {0}", tr("Download Image from French Cadastre WMS")), | 
|---|
| 28 | KeyEvent.VK_F10, Shortcut.DIRECT), false, "cadastrefr/grab", true); | 
|---|
| 29 | } | 
|---|
| 30 |  | 
|---|
| 31 | public void actionPerformed(ActionEvent e) { | 
|---|
| 32 | if (Main.map != null) { | 
|---|
| 33 | if (CadastrePlugin.isCadastreProjection()) { | 
|---|
| 34 | WMSLayer wmsLayer = WMSDownloadAction.getLayer(); | 
|---|
| 35 | if (wmsLayer != null) | 
|---|
| 36 | DownloadWMSVectorImage.download(wmsLayer); | 
|---|
| 37 | } else { | 
|---|
| 38 | CadastrePlugin.askToChangeProjection(); | 
|---|
| 39 | } | 
|---|
| 40 | } else | 
|---|
| 41 | new MenuActionNewLocation().actionPerformed(e); | 
|---|
| 42 | } | 
|---|
| 43 |  | 
|---|
| 44 | } | 
|---|