Top Description Constructors Methods
org.jabref.gui.desktop.os

public abstract Class NativeDesktop

extends Object
Class Inheritance
Known Direct Subclasses
org.jabref.gui.desktop.os.OSX, org.jabref.gui.desktop.os.Windows, org.jabref.gui.desktop.os.DefaultDesktop, org.jabref.gui.desktop.os.Linux
Annotations
@AllowedToUseAwt:Because of moveToTrash() is not available elsewhere.
Imports
java.awt.Desktop, java.io.File, .IOException, java.net.InetAddress, .UnknownHostException, java.nio.file.Files, .Path, org.jabref.Launcher, org.jabref.architecture.AllowedToUseAwt, org.jabref.gui.DialogService, org.jabref.logic.util.BuildInfo, .OS, org.jabref.model.pdf.search.SearchFieldConstants, org.jabref.model.strings.StringUtil, org.jabref.preferences.FilePreferences, net.harawata.appdirs.AppDirsFactory, org.slf4j.LoggerFactory

This class is not meant to be used directly. Use org.jabref.gui.desktop.JabRefDesktop instead.

This class contains bundles OS specific implementations for file directories and file/application open handling methods. In case the default does not work, subclasses provide the correct behavior.

We cannot use a static logger instance here in this class as the Logger first needs to be configured in the Launcher#initLogging. The configuration of tinylog will become immutable as soon as the first log entry is issued.

See Also
https://tinylog.org/v2/configuration

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract String
detectProgramPath(String programName, String directoryName)

public abstract Path

Returns:

the path
getApplicationDirectory
()

Returns the path to the system's applications folder.

public Path
public Path

Returns:

the path
getDefaultFileChooserDirectory
()

Get the user's default file chooser directory

public Path
public String
public Path
public Path
public Path

Returns:

the path
getUserDirectory
()

Returns the path to the system's user directory.

public void
moveToTrash(Path path)

Moves the given file to the trash.

public boolean
public abstract void
openConsole(String absolutePath, DialogService dialogService)

public abstract void
openFile(String filePath, String fileType, FilePreferences filePreferences)

public abstract void
openFileWithApplication(String
The filename.
filePath
,
String
Link to the app that opens the file.
application
)

Opens a file on an Operating System, using the given application.

public abstract void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NativeDesktopback to summary
public NativeDesktop()

Method Detail

detectProgramPathback to summary
public abstract String detectProgramPath(String programName, String directoryName)
getApplicationDirectoryback to summary
public abstract Path getApplicationDirectory()

Returns the path to the system's applications folder.

Returns:Path

the path

getBackupDirectoryback to summary
public Path getBackupDirectory()
getDefaultFileChooserDirectoryback to summary
public Path getDefaultFileChooserDirectory()

Get the user's default file chooser directory

Returns:Path

the path

getFulltextIndexBaseDirectoryback to summary
public Path getFulltextIndexBaseDirectory()
getHostNameback to summary
public String getHostName()
getLogDirectoryback to summary
public Path getLogDirectory()
getSslDirectoryback to summary
public Path getSslDirectory()
getUserDirectoryback to summary
public Path getUserDirectory()

Returns the path to the system's user directory.

Returns:Path

the path

moveToTrashback to summary
public void moveToTrash(Path path)

Moves the given file to the trash.

Exceptions
UnsupportedOperationException:
if the current platform does not support the Desktop.Action#MOVE_TO_TRASH action
See Also
Desktop#moveToTrash(File)
moveToTrashSupportedback to summary
public boolean moveToTrashSupported()
openConsoleback to summary
public abstract void openConsole(String absolutePath, DialogService dialogService) throws IOException
openFileback to summary
public abstract void openFile(String filePath, String fileType, FilePreferences filePreferences) throws IOException
openFileWithApplicationback to summary
public abstract void openFileWithApplication(String filePath, String application) throws IOException

Opens a file on an Operating System, using the given application.

Parameters
filePath:String

The filename.

application:String

Link to the app that opens the file.

openFolderAndSelectFileback to summary
public abstract void openFolderAndSelectFile(Path file) throws IOException