source: osm/applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java@ 15707

Last change on this file since 15707 was 13784, checked in by pieren, 16 years ago

Fix minor bugs, add the fixed size grab scale configurable, fix pbls in transparency.

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1package cadastre_fr;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
4
5import java.awt.event.ActionEvent;
6import java.util.ArrayList;
7
8import javax.swing.JOptionPane;
9
10import org.openstreetmap.josm.Main;
11import org.openstreetmap.josm.actions.JosmAction;
12import org.openstreetmap.josm.gui.layer.Layer;
13
14public class WMSDownloadAction extends JosmAction {
15
16 private static final long serialVersionUID = 1L;
17
18 public WMSDownloadAction(String layerName) {
19 super(layerName, "wmsmenu", tr("Download WMS tile from {0}",layerName), null, false);
20 }
21
22 public void actionPerformed(ActionEvent e) {
23 DownloadWMSTask.download(getLayer());
24 }
25
26 public static WMSLayer getLayer() {
27 // check if we already have a layer created. if not, create; if yes, reuse.
28 if (Main.map != null) {
29 Layer activeLayer = Main.map.mapView.getActiveLayer();
30 if (activeLayer instanceof WMSLayer)
31 return (WMSLayer) activeLayer;
32 ArrayList<WMSLayer> existingWMSlayers = new ArrayList<WMSLayer>();
33 for (Layer l : Main.map.mapView.getAllLayers()) {
34 if (l instanceof WMSLayer) {
35 existingWMSlayers.add((WMSLayer)l);
36 }
37 }
38 if (existingWMSlayers.size() == 1)
39 return existingWMSlayers.get(0);
40 if (existingWMSlayers.size() == 0)
41 return new MenuActionNewLocation().addNewLayer(existingWMSlayers);
42 JOptionPane.showMessageDialog(Main.parent,
43 tr("More than one WMS layer present\nSelect one of them first, then retry"));
44 }
45 return null;
46 }
47};
48
Note: See TracBrowser for help on using the repository browser.