- Timestamp:
- 2013-06-10T22:03:21+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r5617 r6000 5 5 6 6 import java.awt.Dimension; 7 import java.awt.GridBagLayout; 7 8 import java.awt.event.ActionEvent; 8 9 import java.io.IOException; … … 10 11 import javax.swing.Action; 11 12 import javax.swing.ImageIcon; 13 import javax.swing.JComboBox; 12 14 import javax.swing.JOptionPane; 15 import javax.swing.JPanel; 13 16 import javax.swing.JScrollPane; 14 17 import org.openstreetmap.josm.Main; … … 20 23 import org.openstreetmap.josm.io.imagery.WMSImagery; 21 24 import org.openstreetmap.josm.gui.preferences.imagery.WMSLayerTree; 25 import org.openstreetmap.josm.tools.GBC; 22 26 import org.openstreetmap.josm.tools.ImageProvider; 23 27 … … 77 81 final WMSLayerTree tree = new WMSLayerTree(); 78 82 tree.updateTree(wms); 83 final JComboBox formats = new JComboBox(wms.getFormats().toArray()); 84 formats.setToolTipText(tr("Select image format for WMS layer")); 79 85 80 86 if (1 != new ExtendedDialog(Main.parent, tr("Select WMS layers"), new String[]{tr("Add layers"), tr("Cancel")}) {{ 81 87 final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree()); 82 setContent(scrollPane);83 88 scrollPane.setPreferredSize(new Dimension(400, 400)); 89 final JPanel panel = new JPanel(new GridBagLayout()); 90 panel.add(scrollPane, GBC.eol().fill()); 91 panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL)); 92 setContent(panel); 84 93 }}.showDialog().getValue()) { 85 94 return null; 86 95 } 87 96 88 String url = wms.buildGetMapUrl(tree.getSelectedLayers()); 97 final String url = wms.buildGetMapUrl( 98 tree.getSelectedLayers(), (String) formats.getSelectedItem()); 89 99 return new ImageryInfo(info.getName(), url, "wms", info.getEulaAcceptanceRequired(), info.getCookies()); 90 100 } // exception handling from AddWMSLayerPanel.java -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java
r5886 r6000 12 12 import java.io.IOException; 13 13 import java.net.MalformedURLException; 14 import javax.swing.DefaultComboBoxModel; 14 15 15 16 import javax.swing.JButton; 16 17 import javax.swing.JCheckBox; 18 import javax.swing.JComboBox; 17 19 import javax.swing.JLabel; 18 20 import javax.swing.JOptionPane; … … 31 33 private final JCheckBox endpoint = new JCheckBox(tr("Store WMS endpoint only, select layers at usage")); 32 34 private final WMSLayerTree tree = new WMSLayerTree(); 35 private final JComboBox formats = new JComboBox(); 33 36 private final JLabel wmsInstruction; 34 37 private final JosmTextArea wmsUrl = new JosmTextArea(3, 40); … … 53 56 add(new JScrollPane(showBounds), GBC.eop().fill()); 54 57 55 add(wmsInstruction = new JLabel(tr("3. Verify generated WMS URL")), GBC.eol()); 58 add(new JLabel(tr("3. Select image format")), GBC.eol()); 59 add(formats, GBC.eol().fill()); 60 61 add(wmsInstruction = new JLabel(tr("4. Verify generated WMS URL")), GBC.eol()); 56 62 add(wmsUrl, GBC.eop().fill()); 57 63 wmsUrl.setLineWrap(true); 58 64 59 add(new JLabel(tr(" 4. Enter name for this layer")), GBC.eol());65 add(new JLabel(tr("5. Enter name for this layer")), GBC.eol()); 60 66 add(name, GBC.eop().fill()); 61 67 … … 66 72 wms.attemptGetCapabilities(rawUrl.getText()); 67 73 tree.updateTree(wms); 74 formats.setModel(new DefaultComboBoxModel(wms.getFormats().toArray())); 68 75 } catch (MalformedURLException ex) { 69 76 JOptionPane.showMessageDialog(getParent(), tr("Invalid service URL."), … … 87 94 showBounds.setEnabled(!endpoint.isSelected()); 88 95 wmsInstruction.setEnabled(!endpoint.isSelected()); 96 formats.setEnabled(!endpoint.isSelected()); 89 97 wmsUrl.setEnabled(!endpoint.isSelected()); 90 98 if (endpoint.isSelected()) { … … 99 107 @Override 100 108 public void propertyChange(PropertyChangeEvent evt) { 109 onLayerSelectionChanged(); 110 } 111 }); 112 113 formats.addActionListener(new ActionListener() { 114 @Override 115 public void actionPerformed(ActionEvent e) { 101 116 onLayerSelectionChanged(); 102 117 } … … 124 139 protected final void onLayerSelectionChanged() { 125 140 if (wms.getServiceUrl() != null) { 126 wmsUrl.setText(wms.buildGetMapUrl(tree.getSelectedLayers() ));141 wmsUrl.setText(wms.buildGetMapUrl(tree.getSelectedLayers(), (String) formats.getSelectedItem())); 127 142 name.setText(wms.getServiceUrl().getHost() + ": " + Utils.join(", ", tree.getSelectedLayers())); 128 143 } -
trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
r5731 r6000 10 10 import java.net.URL; 11 11 import java.net.URLConnection; 12 import java.util.ArrayList; 12 13 import java.util.Collection; 13 14 import java.util.HashSet; 14 import java.util.LinkedList;15 15 import java.util.List; 16 16 import java.util.Set; … … 51 51 private List<LayerDetails> layers; 52 52 private URL serviceUrl; 53 private List<String> formats; 53 54 54 55 public List<LayerDetails> getLayers() { … … 58 59 public URL getServiceUrl() { 59 60 return serviceUrl; 61 } 62 63 public List<String> getFormats() { 64 return formats; 60 65 } 61 66 … … 83 88 84 89 public String buildGetMapUrl(Collection<LayerDetails> selectedLayers) { 90 return buildGetMapUrl(selectedLayers, "image/jpeg"); 91 } 92 93 public String buildGetMapUrl(Collection<LayerDetails> selectedLayers, String format) { 85 94 return buildRootUrl() 86 + "FORMAT= image/jpeg&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS="95 + "FORMAT=" + format + "&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS=" 87 96 + Utils.join(",", Utils.transform(selectedLayers, new Utils.Function<LayerDetails, String>() { 88 97 @Override … … 151 160 child = getChild(child, "Request"); 152 161 child = getChild(child, "GetMap"); 162 163 formats = new ArrayList<String>(Utils.transform(getChildren(child, "Format"), new Utils.Function<Element, String>() { 164 @Override 165 public String apply(Element x) { 166 return x.getTextContent(); 167 } 168 })); 169 153 170 child = getChild(child, "DCPType"); 154 171 child = getChild(child, "HTTP"); … … 185 202 186 203 private List<LayerDetails> parseLayers(List<Element> children, Set<String> parentCrs) { 187 List<LayerDetails> details = new LinkedList<LayerDetails>();204 List<LayerDetails> details = new ArrayList<LayerDetails>(); 188 205 for (Element element : children) { 189 206 details.add(parseLayer(element, parentCrs)); … … 281 298 282 299 private static List<Element> getChildren(Element parent, String name) { 283 List<Element> retVal = new LinkedList<Element>();300 List<Element> retVal = new ArrayList<Element>(); 284 301 for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { 285 302 if (child instanceof Element && name.equals(child.getNodeName())) {
Note:
See TracChangeset
for help on using the changeset viewer.