Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening the OS-supplied File Manager (other than Nautilus) fail #674

Closed
tudogeorge opened this issue Jan 26, 2024 · 2 comments · Fixed by #711
Closed

Opening the OS-supplied File Manager (other than Nautilus) fail #674

tudogeorge opened this issue Jan 26, 2024 · 2 comments · Fixed by #711
Assignees
Labels
bug Something isn't working
Milestone

Comments

@tudogeorge
Copy link

Commands that require launching the OS File Manager fail with the following exception:
java.io.IOException: Cannot run program "nautilus": error=2, No such file or directory.

I tried

  • File > Reveal on Desktop
  • File > Include > Reveal in Explorer

Expected Behavior

The OS-supplied File Manager application should open at that file's location and with that file selected.

Current Behavior

The following exception is thrown: java.io.IOException: Cannot run program "nautilus": error=2, No such file or directory.
The error message popping up at "Reveal in Explorer" is misleading (it says "File cannot be found" instead of "Could not reveal / ".

Steps to Reproduce

  • On a Linux distribution with a file manager other than Nautilus, open the Scene Builder application
  • Create and save an FXML file (CHILD_FILE.FXML) - do not close Scene Builder
  • Reproduce the issue on "Reveal on Desktop" by accessing File > Reveal on Desktop
  • Create and save another FXML file (PARENT_FILE.FXML) - this instance can be closed
  • Include CHILD_FILE.FXML into PARENT_FILE.FXML
  • In the left-hand side of the editor, in the Document > Hierarchy section, select the included file
  • Reproduce the issue on "Reveal in Explorer" by accessing File > Include > Edit 'CHILD_FILE.FXML' in Explorer

Environment

OS: Kubuntu 22.04; file manager: Dolphin 21.12.3

Scene Builder Product Version
JavaFX Scene Builder 21.0.0

Build Information
Version 21.0.0
Date: 2023-10-05 12:11:04
JavaFX Version: 21
Java Version: 21, OpenJDK Runtime Environment

@tudogeorge tudogeorge added the bug Something isn't working label Jan 26, 2024
@Oliver-Loeffler
Copy link
Collaborator

Besides making the file browser configurable, we could try following approach for Linux:

  • check if nautilus exists (e.g. using which nautilus) and then prefer the first occurance of it
  • check if dolphin exists (on Kubuntu) and then prefer the first occurance of it

If neither nautilus or dolphin are found, we could try to find xdg-open. If that exists, we could run xdg-open /directory.

That would at least solve this particular issue on Kubuntu.

@Oliver-Loeffler
Copy link
Collaborator

Experiment

I've just collected how the error messages look like for the case an exception is raised.

  • 1: File / Reveal in Explorer - (DocumentWindowController.performRevealAction())
    grafik

grafik

  • 2: File / Include / Reveal <xyz.fxml> in Explorer - (EditorController.performRevealIncludedFile())

grafik

grafik

If a file was properly included, it cannot be missing at all.

There is a 3rd occasion for this pattern in ResourceController.performRevealResource(). Same thing here (it uses EditorPlatform.revealInFileBrowser()).

Conclusion:

Bad things:

  • Both dialogs lack the application icon.
  • Despite the same error caused the problem, both dialogs show a different explanation whereas the message in case 2 is mislieading.
  • Besides dialogs, the exit code of the process launched is not evaluated. An exit code !=0 can be assumed as an indication of an error without a related exception. Hence its useful to catch the exit code and to evaluate it accordingly.

Good things:

  • The errors are catched and handled.
  • The stacktrace is provided to the details view.

Aproach:

  • The user must be able to figure out, what went wrong. Hence the relevant details must be passed into the log.
  • The system call might fail for various reasons. One is, the actual program to be launched is missing. Another one is that the program is launched the wrong way. Or the directory to be revealed is missing.

Oliver-Loeffler added a commit that referenced this issue Oct 1, 2024
…711)

Instead of Nautilus, xdg-utils xdg-open command is now used for opening directories in Linux. Also the related error dialogs have been reworked to have a unified look and feel and one can look into the details of the related command line call in case of error. Furthermore, the exit code if the command line call is evaluated. Added proper error dialog for CSS Panel Controller in case revealing a CSS fails.
@Oliver-Loeffler Oliver-Loeffler self-assigned this Oct 1, 2024
@Oliver-Loeffler Oliver-Loeffler added this to the 24 milestone Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants