Add awt native open commands#7037
Conversation
|
As suspected, you need to add an annotation to the class java.lang.AssertionError: Architecture Violation [Priority: MEDIUM] - Rule 'no classes that are not annotated with @AllowedToUseAwt should access classes that reside in a package 'java.awt..'' was violated (3 times): |
|
Added. |
|
java.awt.desktop is part of java.desktop module and that is included. For me jpackage builds fine in your branch under osx. |
|
The flatpak works with the .tar.gz built with the change. |
|
You could try to test if System.err.println or System.out.println produces a better error message |
|
I'll try that. If I were to make a random guess I'd say that the Thread part is failing in the snap.. |
|
Try replacing the new Thread part with Swingutilities.invokeLater( () - > { |
|
The problem wasn't the thread.. where filepath is not utf-8 decoded (it shows %20 instead of a space), but that might be fine I have a few things to test, since it might be simply a missing dependency to add to the snap |
|
Ah I see. I think you need to call toAbsolutePath before Desktop.open(file.getAbsolutePath()) Also seems to be buggy on linux in general: |
|
Solved. In the snap I had to set it to use the new gtk-portal. |
|
This probably needs some more refactoring. jabref/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java Lines 139 to 154 in 3123090 I guess it would make sense to implement a method openBrowser in NativeDesktop interface as default method, e.g.
default void openBrowser(String url) throws IOException {
this.openFile(url, "");
}Then in the LinuxDesktop class you can simply overide the implementation. |
|
The confined packages do not support the browse function (to open URLs). 👿 😡 |
This is used in the confined linux packages to open URLs
|
Try reverting to a thread to avoid incurring in the unittest for swing dependency. |
|
Thanks for the work, if it works now it should be good |
|
It should be good to go, I didn't end up doing the refactoring, although I think that in the future it might be a good step. |
|
It works. |
|
Regarding the thread, I think it would make sense to use our JabRefExecutorService instead, because it is based on a ThreadPool and will stop all running threads when you exit Jabref. Regarding the Logger output, does not make sense to use them if they don't work correctly. |
|
|
||
| if (type.isPresent() && !type.get().getOpenWithApplication().isEmpty()) { | ||
| viewer = type.get().getOpenWithApplication(); | ||
| ProcessBuilder processBuilder = new ProcessBuilder(viewer, filePath); |
There was a problem hiding this comment.
@Siedlerchr
Can we not remove this part and replace it with
Runtime.getRuntime().exec?
The code would be a lot cleaner..both here and in the openFileWithApplication methods..
There was a problem hiding this comment.
This method is used when you have defined a specific app in JabRef (Manage external file types in the Settings dialog -> External programs)
At least we need this StreamGobblers which read the input and error streams, otherwise it could lead to hanging
https://www.infoworld.com/article/2071275/when-runtime-exec---won-t.html
|
The openFolder function can also be simplified to use the new nativeOpen... |
|
EDIT: Nope.. |
|
@Siedlerchr for me this PR is concluded. |
|
Okay, that sounds good! Just waiting for someone else to take a look as well, so I don't miss anything ;) |
* upstream/master: Fix 4040 link Bump java-diff-utils from 4.8 to 4.9 (#7061) Bump bcprov-jdk15on from 1.66 to 1.67 (#7063) Bump checkstyle from 8.36.2 to 8.37 (#7064) Bump mockito-core from 3.5.15 to 3.6.0 (#7067) Bump controlsfx from 11.0.2 to 11.0.3 (#7066) Squashed 'src/main/resources/csl-styles/' changes from 5297abd..5c376b8 add short date formatter (#7039) Add awt native open commands (#7037) Add online-link detection to FileFieldParser (#7043)
Fixes flathub/org.jabref.jabref#3
As discussed in gitter the confined releases do not play nicely with xdg-open.
The flatpak fails directly, and the snap asks for confirmation every time.
If we introduce awt.open it works as intended with native commands/windows.
It works in confined and unconfined releases.
At the moment this is a draft pending further tests