RFR: 8214158: Implement HostServices.showDocument on macOS without calling AWT
Michael Paus
mpaus at openjdk.java.net
Tue Sep 28 18:05:31 UTC 2021
On Tue, 28 Sep 2021 16:06:30 GMT, Michael Paus <mpaus at openjdk.org> wrote:
> Fixes the issue by using the "open" command as discussed before.
> See: https://bugs.openjdk.java.net/browse/JDK-8214158
To answer your questions:
1. I have no idea about LSOpenURLsWithRole. I am not a Mac developer.
2. I have manually tested the change:
Button showHtml = new Button("HTML");
showHtml.setOnAction(e -> {this.getHostServices().showDocument(new File("data/test.html").toURI().toString());});
Button showTxt = new Button("TXT");
showTxt.setOnAction(e -> {this.getHostServices().showDocument(new File("data/test.txt").toURI().toString());});
Button showCsv = new Button("CSV");
showCsv.setOnAction(e -> {this.getHostServices().showDocument(new File("data/test.csv").toURI().toString());});
The code fragment above reliably opens the HTML document in Firefox (my default browser), the text document in BBEdit (my default text editor) and the CSV document in LibreOffice (my default Excel :-)
This also works if you just use the plain strings without conversion to an URI.
Here are the printed Java/FX version strings for completness:
java.runtime.version: 18-ea+16-926
javafx.runtime.version: 18-internal+0-2021-09-28-174132
-------------
PR: https://git.openjdk.java.net/jfx/pull/634
More information about the openjfx-dev
mailing list