Changeset 3524 in josm
- Timestamp:
- 2010-09-13T21:40:18+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/OpenBrowser.java
r2748 r3524 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Desktop; 6 7 import java.io.IOException; 7 8 import java.net.MalformedURLException; 9 import java.net.URI; 8 10 import java.net.URL; 9 11 … … 26 28 * {@see Main#platform} 27 29 */ 28 public static String displayUrl( String url) throws IllegalStateException{30 public static String displayUrl(URI uri) { 29 31 if (Main.applet) { 30 32 try { 31 33 JApplet applet = (JApplet) Main.parent; 32 applet.getAppletContext().showDocument( new URL(url));34 applet.getAppletContext().showDocument(uri.toURL()); 33 35 return null; 34 36 } catch (MalformedURLException mue) { … … 37 39 } 38 40 39 if (Main.platform == null) 40 throw new IllegalStateException(tr("Failed to open URL. There is currently no platform set. Please set a platform first.")); 41 try { 42 Main.platform.openUrl(url); 43 } catch (IOException e) { 44 return e.getMessage(); 41 if (Desktop.isDesktopSupported()) { 42 try { 43 Desktop.getDesktop().browse(uri); 44 } catch (Exception e) { 45 e.printStackTrace(); 46 return e.getMessage(); 47 } 48 } else { 49 System.err.println("Warning: Desktop class is not supported. Platform dependent fall back for open url in browser."); 50 51 if (Main.platform == null) 52 throw new IllegalStateException(tr("Failed to open URL. There is currently no platform set. Please set a platform first.")); 53 try { 54 Main.platform.openUrl(uri.toString()); 55 } catch (IOException e) { 56 return e.getMessage(); 57 } 45 58 } 46 59 return null; 47 60 } 48 61 62 public static String displayUrl(String url) { 63 try { 64 return displayUrl(new URI(url)); 65 } catch (Exception e) { 66 return e.getMessage(); 67 } 68 } 49 69 }
Note:
See TracChangeset
for help on using the changeset viewer.