OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 182 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 182 Rev 185
Line 89... Line 89...
89
    }
89
    }
90
 
90
 
91
    private static void browse(URI uri, final File f) throws IOException {
91
    private static void browse(URI uri, final File f) throws IOException {
92
        assert (uri == null) != (f == null);
92
        assert (uri == null) != (f == null);
93
        boolean handled = false;
93
        boolean handled = false;
-
 
94
        IOException exn = null;
94
        final Desktop.Action action = Desktop.Action.BROWSE;
95
        final Desktop.Action action = Desktop.Action.BROWSE;
95
        if (isDesktopDesirable(action) && Desktop.isDesktopSupported()) {
96
        if (isDesktopDesirable(action) && Desktop.isDesktopSupported()) {
96
            final Desktop d = Desktop.getDesktop();
97
            final Desktop d = Desktop.getDesktop();
97
            if (d.isSupported(action)) {
98
            if (d.isSupported(action)) {
98
                if (uri == null)
99
                if (uri == null)
Line 118... Line 119...
118
                        } catch (InterruptedException e) {
119
                        } catch (InterruptedException e) {
119
                            throw new RTInterruptedException("Interrupted while waiting on mount for " + uri, e);
120
                            throw new RTInterruptedException("Interrupted while waiting on mount for " + uri, e);
120
                        }
121
                        }
121
                    }
122
                    }
122
                }
123
                }
-
 
124
                try {
123
                d.browse(uri);
125
                    d.browse(uri);
124
                handled = true;
126
                    handled = true;
-
 
127
                } catch (IOException e) {
-
 
128
                    // On Ubuntu, we sometimes get spurious errors, so retry
-
 
129
                    exn = e;
-
 
130
                }
125
            }
131
            }
126
        }
132
        }
127
        if (!handled) {
133
        if (!handled) {
-
 
134
            try {
128
            // if the caller passed a file use it instead of our converted URI
135
                // if the caller passed a file use it instead of our converted URI
129
            if (f != null)
136
                if (f != null)
130
                openNative(f);
137
                    openNative(f);
131
            else
138
                else
132
                openNative(uri);
139
                    openNative(uri);
-
 
140
            } catch (IOException | RuntimeException e) {
-
 
141
                if (exn != null) {
-
 
142
                    exn.addSuppressed(e);
-
 
143
                    throw exn;
-
 
144
                } else {
-
 
145
                    throw e;
-
 
146
                }
-
 
147
            }
133
        }
148
        }
134
    }
149
    }
135
 
150
 
136
    public static boolean isDesktopDesirable(Desktop.Action action) {
151
    public static boolean isDesktopDesirable(Desktop.Action action) {
137
        // apparently the JRE just checks if gnome libs are available (e.g. open Nautilus in XFCE)
152
        // apparently the JRE just checks if gnome libs are available (e.g. open Nautilus in XFCE)