Ignore:
Timestamp:
2013-10-06T17:26:37+02:00 (13 years ago)
Author:
Don-vip
Message:

Improve feedback when clicking a web marker pointing to a local file fails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/OpenBrowser.java

    r6248 r6299  
    2929
    3030    /**
     31     * Displays an external URI using platform associated software.
     32     * A web resource will launch platform's browser, an audio file URI will launch audio player, etc.
     33     * @param uri The URI to display
    3134     * @return <code>null</code> for success or a string in case of an error.
    3235     * @throws IllegalStateException thrown if no platform is set to which opening the URL can be dispatched,
     
    3437     */
    3538    public static String displayUrl(URI uri) {
     39        CheckParameterUtil.ensureParameterNotNull(uri, "uri");
    3640        if (Main.applet) {
    3741            try {
     
    4347            }
    4448        }
     49       
     50        Main.info(tr("Opening URL: {0}", uri));
    4551
    4652        if (Desktop.isDesktopSupported()) {
    4753            try {
    48                 try {
     54                if (Main.platform instanceof PlatformHookWindows) {
     55                    // Desktop API works fine under Windows, so we don't try any fallback in case of I/O exceptions because it's not API's fault
    4956                    Desktop.getDesktop().browse(uri);
    50                 } catch (IOException e) {
    51                     // Workaround for KDE (Desktop API is severely flawed)
    52                     // see http://bugs.sun.com/view_bug.do?bug_id=6486393
    53                     Main.warn("Desktop class failed. Platform dependent fall back for open url in browser.");
    54                     displayUrlFallback(uri);
     57                } else {
     58                    // This is not the case with some Linux environments (see below), and not sure about Mac OS X, so we need to handle API failure
     59                    try {
     60                        Desktop.getDesktop().browse(uri);
     61                    } catch (IOException e) {
     62                        // Workaround for KDE (Desktop API is severely flawed)
     63                        // see https://bugs.openjdk.java.net/browse/JDK-6486393
     64                        Main.warn("Desktop class failed. Platform dependent fall back for open url in browser.");
     65                        displayUrlFallback(uri);
     66                    }
    5567                }
    5668            } catch (Exception e) {
    57                 e.printStackTrace();
     69                Main.warn(e);
    5870                return e.getMessage();
    5971            }
     
    6981    }
    7082
     83    /**
     84     * Displays an external URL using platform associated software.
     85     * A web resource will launch platform's browser, an audio file URL will launch audio player, etc.
     86     * @param url The URL to display
     87     * @return <code>null</code> for success or a string in case of an error.
     88     * @throws IllegalStateException thrown if no platform is set to which opening the URL can be dispatched,
     89     * {@link Main#platform}
     90     */
    7191    public static String displayUrl(String url) {
    7292        try {
Note: See TracChangeset for help on using the changeset viewer.