source: josm/trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMTSLayerPanel.java@ 11655

Last change on this file since 11655 was 11289, checked in by wiktorn, 7 years ago

Use explicit ImageryTypes when adding layers

Closes: #14017

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.imagery;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.io.IOException;
7
8import javax.swing.JLabel;
9
10import org.openstreetmap.josm.data.imagery.ImageryInfo;
11import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
12import org.openstreetmap.josm.data.imagery.WMTSTileSource;
13import org.openstreetmap.josm.tools.GBC;
14
15/**
16 * Panel for adding WMTS imagery sources
17 * @author Wiktor Niesiobędzki
18 *
19 */
20public class AddWMTSLayerPanel extends AddImageryPanel {
21
22 /**
23 * default constructor
24 */
25 public AddWMTSLayerPanel() {
26 add(new JLabel(tr("1. Enter getCapabilities URL")), GBC.eol());
27 add(rawUrl, GBC.eop().fill());
28 rawUrl.setLineWrap(true);
29 rawUrl.setAlignmentY(TOP_ALIGNMENT);
30 add(new JLabel(tr("2. Enter name for this layer")), GBC.eol());
31 add(name, GBC.eol().fill(GBC.HORIZONTAL));
32 registerValidableComponent(rawUrl);
33 }
34
35 @Override
36 protected ImageryInfo getImageryInfo() {
37 ImageryInfo ret = new ImageryInfo(getImageryName(), "wmts:" + sanitize(getImageryRawUrl(), ImageryType.WMTS));
38 ret.setImageryType(ImageryType.WMTS);
39 try {
40 new WMTSTileSource(ret); // check if constructor throws an error
41 } catch (IOException e) {
42 throw new IllegalArgumentException(e); // if so, wrap exception, so proper message will be shown to the user
43 }
44 return ret;
45
46 }
47
48 @Override
49 protected boolean isImageryValid() {
50 return !getImageryName().isEmpty() && !getImageryRawUrl().isEmpty();
51 }
52
53}
Note: See TracBrowser for help on using the repository browser.