}
protected ImageryInfo getWMSLayerInfo() {
try {
assert (ImageryType.WMS_ENDPOINT.equals(info.getImageryType()));
final WMSImagery wms = new WMSImagery();
wms.attemptGetCapabilities(info.getUrl());
final WMSLayerTree tree = new WMSLayerTree();
tree.updateTree(wms);
final JComboBox<String> formats = new JComboBox<>(wms.getFormats().toArray(new String[0]));
formats.setSelectedItem(wms.getPreferredFormats());
formats.setToolTipText(tr("Select image format for WMS layer"));
if (1 != new ExtendedDialog(Main.parent, tr("Select WMS layers"), new String[]{tr("Add layers"), tr("Cancel")}) {{
final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree());
scrollPane.setPreferredSize(new Dimension(400, 400));
final JPanel panel = new JPanel(new GridBagLayout());
panel.add(scrollPane, GBC.eol().fill());
panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL));
setContent(panel);
}}.showDialog().getValue()) {
return null;
}
final String url = wms.buildGetMapUrl(
tree.getSelectedLayers(), (String) formats.getSelectedItem());
return new ImageryInfo(info.getName(), url, "wms", info.getEulaAcceptanceRequired(), info.getCookies());
} // exception handling from AddWMSLayerPanel.java
catch (MalformedURLException ex) {
JOptionPane.showMessageDialog(Main.parent, tr("Invalid service URL."),