Changeset 6474 in josm
- Timestamp:
- 2013-12-16T00:22:44+01:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.settings/org.eclipse.jdt.ui.prefs
r2899 r6474 1 #Wed Jan 27 11:53:40 EST 20102 1 cleanup_settings_version=2 3 2 eclipse.preferences.version=1 … … 14 13 sp_cleanup.add_missing_nls_tags=false 15 14 sp_cleanup.add_missing_override_annotations=true 15 sp_cleanup.add_missing_override_annotations_interface_methods=false 16 16 sp_cleanup.add_serial_version_id=false 17 17 sp_cleanup.always_use_blocks=false … … 51 51 sp_cleanup.sort_members=false 52 52 sp_cleanup.sort_members_all=false 53 sp_cleanup.use_blocks= true53 sp_cleanup.use_blocks=false 54 54 sp_cleanup.use_blocks_only_for_return_and_throw=true 55 55 sp_cleanup.use_parentheses_in_expressions=false -
trunk/src/org/openstreetmap/josm/Main.java
r6471 r6474 212 212 */ 213 213 public static int logLevel = 3; 214 214 215 215 /** 216 216 * Prints an error message if logging is on. … … 223 223 System.err.println(tr("ERROR: {0}", msg)); 224 224 } 225 225 226 226 /** 227 227 * Prints a warning message if logging is on. … … 233 233 System.err.println(tr("WARNING: {0}", msg)); 234 234 } 235 235 236 236 /** 237 237 * Prints an informational message if logging is on. … … 243 243 System.out.println(tr("INFO: {0}", msg)); 244 244 } 245 245 246 246 /** 247 247 * Prints a debug message if logging is on. … … 253 253 System.out.println(tr("DEBUG: {0}", msg)); 254 254 } 255 255 256 256 /** 257 257 * Prints a formated error message if logging is on. Calls {@link MessageFormat#format} … … 264 264 error(MessageFormat.format(msg, objects)); 265 265 } 266 266 267 267 /** 268 268 * Prints a formated warning message if logging is on. Calls {@link MessageFormat#format} … … 274 274 warn(MessageFormat.format(msg, objects)); 275 275 } 276 276 277 277 /** 278 278 * Prints a formated informational message if logging is on. Calls {@link MessageFormat#format} … … 284 284 info(MessageFormat.format(msg, objects)); 285 285 } 286 286 287 287 /** 288 288 * Prints a formated debug message if logging is on. Calls {@link MessageFormat#format} … … 294 294 debug(MessageFormat.format(msg, objects)); 295 295 } 296 296 297 297 /** 298 298 * Prints an error message for the given Throwable. … … 303 303 error(getErrorMessage(t)); 304 304 } 305 305 306 306 /** 307 307 * Prints a warning message for the given Throwable. … … 312 312 warn(getErrorMessage(t)); 313 313 } 314 314 315 315 private static String getErrorMessage(Throwable t) { 316 316 StringBuilder sb = new StringBuilder(t.getClass().getName()); … … 318 318 if (msg != null) { 319 319 sb.append(": ").append(msg.trim()); 320 } 321 Throwable cause = t.getCause(); 322 if (cause != null && !cause.equals(t)) { 323 sb.append(". ").append(tr("Cause: ")).append(getErrorMessage(cause)); 320 324 } 321 325 return sb.toString(); -
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r6380 r6474 183 183 if (!tasks.isEmpty()) { 184 184 // TODO: handle multiple suitable tasks ? 185 future = tasks.iterator().next().loadUrl(new_layer, url, monitor); 185 try { 186 future = tasks.iterator().next().loadUrl(new_layer, url, monitor); 187 } catch (IllegalArgumentException e) { 188 Main.error(e); 189 } 186 190 } 187 191 if (future != null) { -
trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
r6380 r6474 11 11 import org.openstreetmap.josm.data.osm.DataSet; 12 12 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 13 import org.openstreetmap.josm.tools.CheckParameterUtil; 13 14 import org.openstreetmap.josm.tools.Utils; 14 15 import org.xml.sax.SAXException; … … 34 35 */ 35 36 public BoundingBoxDownloader(Bounds downloadArea) { 37 CheckParameterUtil.ensureParameterNotNull(downloadArea, "downloadArea"); 36 38 this.lat1 = downloadArea.getMinLat(); 37 39 this.lon1 = downloadArea.getMinLon(); -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r6453 r6474 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.awt.HeadlessException; … … 15 17 public final class OsmUrlToBounds { 16 18 private static final String SHORTLINK_PREFIX = "http://osm.org/go/"; 17 19 18 20 private OsmUrlToBounds() { 19 21 // Hide default constructor for utils classes 20 22 } 21 23 22 public static Bounds parse(String url) {24 public static Bounds parse(String url) throws IllegalArgumentException { 23 25 try { 24 26 // a percent sign indicates an encoded URL (RFC 1738). … … 86 88 * @param url string for parsing 87 89 * @return Bounds if hashurl, {@code null} otherwise 88 */ 89 private static Bounds parseHashURLs(String url) { 90 * @throws IllegalArgumentException if URL is invalid 91 */ 92 private static Bounds parseHashURLs(String url) throws IllegalArgumentException { 90 93 int startIndex = url.indexOf("#map="); 91 94 if (startIndex == -1) return null; 92 95 int endIndex = url.indexOf('&', startIndex); 93 96 if (endIndex == -1) endIndex = url.length(); 94 try { 95 String coordPart = url.substring(startIndex+5, endIndex); 96 String[] parts = coordPart.split("/"); 97 Bounds b = positionToBounds(Double.parseDouble(parts[1]), 98 Double.parseDouble(parts[2]), 99 Integer.parseInt(parts[0])); 100 return b; 101 } catch (Exception ex) { 102 Main.debug(ex.getMessage()); 103 return null; 104 } 97 String coordPart = url.substring(startIndex+5, endIndex); 98 String[] parts = coordPart.split("/"); 99 if (parts.length < 3) { 100 throw new IllegalArgumentException(tr("URL does not contain {0}/{1}/{2}", tr("zoom"), tr("latitude"), tr("longitude"))); 101 } 102 int zoom; 103 double lat, lon; 104 try { 105 zoom = Integer.parseInt(parts[0]); 106 } catch (NumberFormatException e) { 107 throw new IllegalArgumentException(tr("URL does not contain valid {0}", tr("zoom")), e); 108 } 109 try { 110 lat = Double.parseDouble(parts[1]); 111 } catch (NumberFormatException e) { 112 throw new IllegalArgumentException(tr("URL does not contain valid {0}", tr("latitude")), e); 113 } 114 try { 115 lon = Double.parseDouble(parts[2]); 116 } catch (NumberFormatException e) { 117 throw new IllegalArgumentException(tr("URL does not contain valid {0}", tr("longitude")), e); 118 } 119 return positionToBounds(lat, lon, zoom); 105 120 } 106 121
Note:
See TracChangeset
for help on using the changeset viewer.