Package io.github.jbastgen.stemma.app.io
Class FileManager
java.lang.Object
io.github.jbastgen.stemma.app.io.FileManager
Shows a repository, a folder or a file in the system's file manager (Explorer, Finder, the Files application of the
Linux desktop).
The platform's own command is tried first (explorer /select,…, open -R, xdg-open): it can
select the file, and it does not need AWT, which shares the main thread with JavaFX on macOS. If that command is
missing or fails, java.awt.Desktop is asked. A command from the settings replaces both and is never
replaced by something else when it fails. Commands run without a shell, so file names with spaces or quotes are
safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe second way: ask the desktop.static enumThe operating systems that have their own way to show a file.static final recordThe outcome ofshow(io.github.jbastgen.stemma.app.io.FileManager.Os, java.nio.file.Path, java.lang.String, java.lang.String, io.github.jbastgen.stemma.app.io.FileManager.Runner, io.github.jbastgen.stemma.app.io.FileManager.Fallback):messagesays what went wrong whenokis false.static interfaceStarts a command.static final recordWhat to show: a path that exists, and whether it is a file (to be selected) or a folder (to be opened). -
Method Summary
Modifier and TypeMethodDescriptioncommand(FileManager.Os os, FileManager.Target target, String override) The command that shows the target.static FileManager.Resultshow(FileManager.Os os, Path repo, String relPath, String override, FileManager.Runner runner, FileManager.Fallback fallback) Shows the file (or the repository) in the file manager.static FileManager.ResultShows the file (or the repository) with the real system: the platform's command, thenjava.awt.Desktop.static FileManager.TargetThe path to show for a file of the repository.
-
Method Details
-
target
The path to show for a file of the repository. A file that exists is selected; a file that is not there (deleted, or from an old commit) shows its nearest folder that is; no file, or a path that leaves the repository, shows the repository itself.- Parameters:
relPath- the path inside the repository with/as separator, or null / empty for the repository
-
command
The command that shows the target. A non-blankoverride(from the settings) is used instead of the platform's command; in it$DIRis the folder to show (the file's folder for a file) and$FILEthe file to select (the folder itself when a folder is shown).${DIR}and${FILE}work too. -
show
public static FileManager.Result show(FileManager.Os os, Path repo, String relPath, String override, FileManager.Runner runner, FileManager.Fallback fallback) Shows the file (or the repository) in the file manager. Blocks for at most a few seconds: call it off the UI thread.- Parameters:
relPath- the file inside the repository, or null for the repository's folderoverride- the command line of the settings, or empty for the platform's way
-
show
Shows the file (or the repository) with the real system: the platform's command, thenjava.awt.Desktop.
-