Changeset 18838 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
- Timestamp:
- 2009-11-28T17:05:44+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
r18720 r18838 36 36 37 37 public WMSLayer addNewLayer(ArrayList<WMSLayer> existingLayers) { 38 /*if (Main.map == null) { 39 JOptionPane.showMessageDialog(Main.parent, 40 tr("Open a layer first (GPX, OSM, cache)")); 38 String location = ""; 39 String codeDepartement = ""; 40 String codeCommune = ""; 41 boolean resetCookie = false; 42 JLabel labelSectionNewLocation = new JLabel(tr("Add a new layer")); 43 JPanel p = new JPanel(new GridBagLayout()); 44 JLabel labelLocation = new JLabel(tr("Location")); 45 final JTextField inputTown = new JTextField( Main.pref.get("cadastrewms.location") ); 46 inputTown.setToolTipText(tr("<html>Enter the town,village or city name.<br>" 47 + "Use the syntax and punctuation known by www.cadastre.gouv.fr .</html>")); 48 49 p.add(labelSectionNewLocation, GBC.eol()); 50 p.add(labelLocation, GBC.std().insets(10, 0, 0, 0)); 51 p.add(inputTown, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5)); 52 JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null) { 53 private static final long serialVersionUID = 1L; 54 55 @Override 56 public void selectInitialValue() { 57 inputTown.requestFocusInWindow(); 58 inputTown.selectAll(); 59 } 60 }; 61 pane.createDialog(Main.parent, tr("Add new layer")).setVisible(true); 62 if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue())) 41 63 return null; 42 } else {*/43 String location = "";44 String codeDepartement = "";45 String codeCommune = "";46 boolean resetCookie = false;47 JLabel labelSectionNewLocation = new JLabel(tr("Add a new layer"));48 JPanel p = new JPanel(new GridBagLayout());49 JLabel labelLocation = new JLabel(tr("Location"));50 final JTextField inputTown = new JTextField( Main.pref.get("cadastrewms.location") );51 inputTown.setToolTipText(tr("<html>Enter the town,village or city name.<br>"52 + "Use the syntax and punctuation known by www.cadastre.gouv.fr .</html>"));53 64 54 p.add(labelSectionNewLocation, GBC.eol()); 55 p.add(labelLocation, GBC.std().insets(10, 0, 0, 0)); 56 p.add(inputTown, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5)); 57 JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null) { 58 private static final long serialVersionUID = 1L; 59 60 @Override 61 public void selectInitialValue() { 62 inputTown.requestFocusInWindow(); 63 inputTown.selectAll(); 64 } 65 }; 66 pane.createDialog(Main.parent, tr("Add new layer")).setVisible(true); 67 if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue())) 68 return null; 69 70 WMSLayer wmsLayer = null; 71 if (!inputTown.getText().equals("")) { 72 location = inputTown.getText().toUpperCase(); 73 resetCookie = true; 74 Main.pref.put("cadastrewms.location", location); 75 Main.pref.put("cadastrewms.codeCommune", codeCommune); 76 if (Main.map != null) { 77 for (Layer l : Main.map.mapView.getAllLayers()) { 78 if (l instanceof WMSLayer && l.getName().equalsIgnoreCase(location + codeDepartement)) { 79 return null; 80 } 65 WMSLayer wmsLayer = null; 66 if (!inputTown.getText().equals("")) { 67 location = inputTown.getText().toUpperCase(); 68 resetCookie = true; 69 Main.pref.put("cadastrewms.location", location); 70 Main.pref.put("cadastrewms.codeCommune", codeCommune); 71 if (Main.map != null) { 72 for (Layer l : Main.map.mapView.getAllLayers()) { 73 if (l instanceof WMSLayer && l.getName().equalsIgnoreCase(location + codeDepartement)) { 74 return null; 81 75 } 82 76 } 83 // add the layer if it doesn't exist84 int zone = -1;85 if (Main.proj instanceof LambertCC9Zones)86 zone = ((LambertCC9Zones)Main.proj).getLayoutZone();87 else if (Main.proj instanceof Lambert)88 zone = ((Lambert)Main.proj).getLayoutZone();89 else if (Main.proj instanceof UTM_20N_France_DOM)90 zone = ((UTM_20N_France_DOM)Main.proj).getCurrentGeodesic();91 wmsLayer = new WMSLayer(location, codeCommune, zone);92 Main.main.addLayer(wmsLayer);93 System.out.println("Add new layer with Location:" + inputTown.getText());94 } else if (existingLayers != null && existingLayers.size() > 0 && Main.map.mapView.getActiveLayer() instanceof WMSLayer) {95 wmsLayer = (WMSLayer)Main.map.mapView.getActiveLayer();96 resetCookie = true;97 77 } 78 // add the layer if it doesn't exist 79 int zone = -1; 80 if (Main.proj instanceof LambertCC9Zones) 81 zone = ((LambertCC9Zones)Main.proj).getLayoutZone(); 82 else if (Main.proj instanceof Lambert) 83 zone = ((Lambert)Main.proj).getLayoutZone(); 84 else if (Main.proj instanceof UTM_20N_France_DOM) 85 zone = ((UTM_20N_France_DOM)Main.proj).getCurrentGeodesic(); 86 wmsLayer = new WMSLayer(location, codeCommune, zone); 87 Main.main.addLayer(wmsLayer); 88 System.out.println("Add new layer with Location:" + inputTown.getText()); 89 } else if (existingLayers != null && existingLayers.size() > 0 && Main.map.mapView.getActiveLayer() instanceof WMSLayer) { 90 wmsLayer = (WMSLayer)Main.map.mapView.getActiveLayer(); 91 resetCookie = true; 92 } 98 93 99 if (resetCookie) 100 CadastrePlugin.cadastreGrabber.getWmsInterface().resetCookieIfNewLayer(wmsLayer.getName()); 101 return wmsLayer; 102 //} 94 if (resetCookie) 95 CadastrePlugin.cadastreGrabber.getWmsInterface().resetCookieIfNewLayer(wmsLayer.getName()); 96 return wmsLayer; 103 97 } 104 98
Note:
See TracChangeset
for help on using the changeset viewer.
