Fixed issues with making sure that Desktop.* methods do not block
the current UI when running from the Swing EDT.
This commit is contained in:
parent
61554d3f75
commit
8a1ce599a2
@ -80,12 +80,17 @@ class Desktop {
|
||||
}
|
||||
else if (java.awt.Desktop.isDesktopSupported() && java.awt.Desktop.getDesktop()
|
||||
.isSupported(java.awt.Desktop.Action.BROWSE)) {
|
||||
EventQueue.invokeLater(() -> {
|
||||
// make sure this doesn't block the current UI
|
||||
SwingUtil.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public
|
||||
void run() {
|
||||
try {
|
||||
java.awt.Desktop.getDesktop()
|
||||
.browse(uri);
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -140,8 +145,19 @@ class Desktop {
|
||||
}
|
||||
else if (java.awt.Desktop.isDesktopSupported() && java.awt.Desktop.getDesktop()
|
||||
.isSupported(java.awt.Desktop.Action.MAIL)) {
|
||||
// make sure this doesn't block the current UI
|
||||
SwingUtil.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public
|
||||
void run() {
|
||||
try {
|
||||
java.awt.Desktop.getDesktop()
|
||||
.mail(uri);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw new IOException("Current OS and desktop configuration does not support launching an email client");
|
||||
@ -188,8 +204,21 @@ class Desktop {
|
||||
}
|
||||
else if (java.awt.Desktop.isDesktopSupported() && java.awt.Desktop.getDesktop()
|
||||
.isSupported(java.awt.Desktop.Action.OPEN)) {
|
||||
final String finalPath = path;
|
||||
|
||||
// make sure this doesn't block the current UI
|
||||
SwingUtil.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public
|
||||
void run() {
|
||||
try {
|
||||
java.awt.Desktop.getDesktop()
|
||||
.open(new File(path));
|
||||
.open(new File(finalPath));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw new IOException("Current OS and desktop configuration does not support opening a directory to browse");
|
||||
|
Loading…
Reference in New Issue
Block a user