Changeset 17407 in osm for applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java
- Timestamp:
- 2009-08-31T14:40:43+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java
r17397 r17407 65 65 private ExecutorService executor = null; 66 66 67 /** set to true if this layer uses an invalid base url */ 68 private boolean usesInvalidUrl = false; 69 /** set to true if the user confirmed to use an potentially invalid WMS base url */ 70 private boolean isInvalidUrlConfirmed = false; 71 67 72 public WMSLayer() { 68 73 this(tr("Blank Layer"), null, null); … … 84 89 85 90 executor = Executors.newFixedThreadPool(3); 91 if (!baseURL.startsWith("html:") && !WMSGrabber.isUrlWithPatterns(baseURL)) { 92 if (!(baseURL.endsWith("&") || baseURL.endsWith("?"))) { 93 if (!confirmMalformedUrl(baseURL)) { 94 System.out.println(tr("Warning: WMS layer deactivated because of malformed base url ''{0}''", baseURL)); 95 usesInvalidUrl = true; 96 setName(getName() + tr("(deactivated)")); 97 return; 98 } else { 99 isInvalidUrlConfirmed = true; 100 } 101 } 102 } 86 103 } 87 104 88 105 @Override 89 public void destroy() { 106 public void destroy() { 90 107 try { 91 executor.shutdown ();108 executor.shutdownNow(); 92 109 // Might not be initalized, so catch NullPointer as well 93 } catch(Exception x) {} 110 } catch(Exception x) { 111 x.printStackTrace(); 112 } 94 113 } 95 114 … … 138 157 @Override public void paint(Graphics g, final MapView mv) { 139 158 if(baseURL == null) return; 159 if (usesInvalidUrl && !isInvalidUrlConfirmed) return; 140 160 141 161 if( !startstop.isSelected() || (pixelPerDegree / getPPD() > minZoom) ){ //don't download when it's too outzoomed … … 155 175 } 156 176 177 protected boolean confirmMalformedUrl(String url) { 178 if (isInvalidUrlConfirmed) 179 return true; 180 String msg = tr("<html>The base URL<br>" 181 + "''{0}''<br>" 182 + "for this WML layer does neither end with a ''&'' nor with a ''?''.<br>" 183 + "This is likely to lead to invalid WMS request. You should check your<br>" 184 + "preference settings.<br>" 185 + "Do you want to fetch WMS tiles anyway?", 186 url); 187 String [] options = new String[] { 188 tr("Yes, fetch images"), 189 tr("No, abort") 190 }; 191 int ret = JOptionPane.showOptionDialog( 192 Main.parent, 193 msg, 194 tr("Invalid URL?"), 195 JOptionPane.YES_NO_OPTION, 196 JOptionPane.WARNING_MESSAGE, 197 null, 198 options, options[1] 199 ); 200 switch(ret) { 201 case JOptionPane.YES_OPTION: return true; 202 default: return false; 203 } 204 } 157 205 protected void downloadAndPaintVisible(Graphics g, final MapView mv){ 206 if (usesInvalidUrl) 207 return; 158 208 ProjectionBounds bounds = mv.getProjectionBounds(); 159 209 int bminx= (int)Math.floor ((bounds.min.east() * pixelPerDegree ) / ImageSize ); … … 170 220 ); 171 221 return; 172 } 173 222 } 223 174 224 for(int x = bminx; x<bmaxx; ++x) { 175 225 for(int y = bminy; y<bmaxy; ++y){
Note:
See TracChangeset
for help on using the changeset viewer.