Top Description Fields Constructors Methods
org.jabref.gui.externalfiles

public Class UnlinkedFilesCrawler

extends BackgroundTask<FileNodeViewModel>
Class Inheritance
Imports
java.io.File, .IOException, java.nio.file.DirectoryStream.Filter, .Files, .Path, java.util.ArrayList, .List, .Map, java.util.stream.Collectors, .Stream, .StreamSupport, javafx.scene.control.CheckBoxTreeItem, org.jabref.gui.util.BackgroundTask, .FileNodeViewModel, org.jabref.model.database.BibDatabase, .BibDatabaseContext, org.jabref.preferences.FilePreferences, org.slf4j.Logger, .LoggerFactory

Util class for searching files on the file system which are not linked to a provided BibDatabase.

Field Summary

Modifier and TypeField and Description
private final BibDatabaseContext
private final DateRange
private final Path
private final DirectoryStream.Filter<Path>
private final FilePreferences
private static final Logger
private final ExternalFileSorter
Inherited from org.jabref.gui.util.BackgroundTask:
iconMap

Constructor Summary

AccessConstructor and Description
public
UnlinkedFilesCrawler(Path directory, DirectoryStream.Filter<Path> fileFilter, DateRange dateFilter, ExternalFileSorter sorter, BibDatabaseContext databaseContext, FilePreferences filePreferences)

Method Summary

Modifier and TypeMethod and Description
protected FileNodeViewModel
pack-priv FileNodeViewModel

Returns:

FileNodeViewModel containing the data of the current directory and all subdirectories
searchDirectory
(Path directory, UnlinkedPDFFileFilter
contains a BibDatabaseContext which is used to determine whether the file is linked
unlinkedPDFFileFilter
)

Searches recursively all files in the specified directory.

Inherited from org.jabref.gui.util.BackgroundTask:
cancelexecuteWithgetIcongetProgressgetWorkDonePercentageisCanceledisCanceledPropertymessagePropertyonFailureonFinishedonRunningonSuccessprogressPropertyscheduleWithshowToUsershowToUserthenthenRunthenRuntitlePropertyupdateMessageupdateProgressupdateProgresswillBeRecoveredAutomaticallywillBeRecoveredAutomaticallywithInitialMessageworkDonePercentagePropertywrapwrap

Field Detail

databaseContextback to summary
private final BibDatabaseContext databaseContext
dateFilterback to summary
private final DateRange dateFilter
directoryback to summary
private final Path directory
fileFilterback to summary
private final DirectoryStream.Filter<Path> fileFilter
filePreferencesback to summary
private final FilePreferences filePreferences
LOGGERback to summary
private static final Logger LOGGER

Hides org.jabref.gui.util.BackgroundTask.LOGGER.

sorterback to summary
private final ExternalFileSorter sorter

Constructor Detail

UnlinkedFilesCrawlerback to summary
public UnlinkedFilesCrawler(Path directory, DirectoryStream.Filter<Path> fileFilter, DateRange dateFilter, ExternalFileSorter sorter, BibDatabaseContext databaseContext, FilePreferences filePreferences)

Method Detail

callback to summary
protected FileNodeViewModel call() throws IOException

Implements abstract org.jabref.gui.util.BackgroundTask.call.

Annotations
@Override
searchDirectoryback to summary
pack-priv FileNodeViewModel searchDirectory(Path directory, UnlinkedPDFFileFilter unlinkedPDFFileFilter) throws IOException

Searches recursively all files in the specified directory.

All files matched by the given UnlinkedPDFFileFilter are taken into the resulting tree.

The result will be a tree structure of nodes of the type CheckBoxTreeItem.

The user objects that are attached to the nodes is the FileNodeViewModel, which wraps the File-Object.

For ensuring the capability to cancel the work of this recursive method, the first position in the integer array 'state' must be set to 1, to keep the recursion running. When the states value changes, the method will resolve its recursion and return what it has saved so far.
The files are filtered according to the DateRange filter value and then sorted according to the ExternalFileSorter value.

Parameters
unlinkedPDFFileFilter:UnlinkedPDFFileFilter

contains a BibDatabaseContext which is used to determine whether the file is linked

Returns:FileNodeViewModel

FileNodeViewModel containing the data of the current directory and all subdirectories

Exceptions
IOException:
if directory is not a directory or empty