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

Last change on this file since 20390 was 20390, checked in by pieren, 15 years ago

Many small fixes and improvements

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