JabRef / jabref

Graphical Java application for managing BibTeX and biblatex (.bib) databases
https://devdocs.jabref.org
MIT License
3.59k stars 2.52k forks source link

Opening bib file in macOS #8617

Open Basem9955 opened 2 years ago

Basem9955 commented 2 years ago

JabRef version

Latest development branch build (please note build date below)

Operating system

macOS

Details on version and operating system

macOS 10.15.7 "Catalina" and Jabref 5.6

Checked with the latest development build

Steps to reproduce the behaviour

Double click on any bib file and the Jabref app will open but the file will not. Only dragging the file to jabref window or opening a file from jabref (file --> open) works with macOS.

Appendix

...

Log File ``` Paste an excerpt of your log file here ```
yogeshvar commented 2 years ago

Just curious, if the drag and drop works as expected. The issue has to be on the application startup (maybe in JabRefGUI.java) If the files are opened via Open With we could try something like this for macOS.

if (System.getProperty("os.name").toLowerCase().contains("os x")) {
            Desktop desktop = Desktop.getDesktop();
            LOGGER.info("Opening files in Finder");
            desktop.setOpenFileHandler(e -> {
                for (File file : e.getFiles()) {
                    try {
                        desktop.open(file.getParentFile());
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    }
                }
            });
        }

Is there any way to build JabRef and get the JabRef.app using Gradle?

Siedlerchr commented 2 years ago

@yogeshvar Yes, you can just execute ./gradlew jpackage

Siedlerchr commented 2 years ago

You can check the JabRefDesktop class, there it already contains methods for opening. You can also check the jpackage doc https://docs.oracle.com/en/java/javase/17/jpackage/support-application-features.html#GUID-8D9F0607-91F4-4070-8823-02FCAB12238D

Siedlerchr commented 1 year ago

I looked a bit more into this and yes one needs to register an open file handler as the filename is not passed as a comandline argument when opening from finder.

I stumbled across this here https://github.com/eschmar/javafx-custom-file-ext-boilerplate and trying to see if this approach works