use of org.jabref.gui.importer.UnlinkedPDFFileFilter in project jabref by JabRef.
the class FindUnlinkedFilesDialog method startSearch.
/**
* Starts the search of unlinked files according to the current dialog
* state. <br>
* <br>
* This state is made of: <br>
* <li>The value of the "directory"-input-textfield and <li>The file type
* selection. <br>
* The search will process in a seperate thread and the progress bar behind
* the "search" button will be displayed. <br>
* <br>
* When the search has completed, the
* {@link #searchFinishedHandler(CheckableTreeNode)} handler method is
* invoked.
*/
private void startSearch() {
Path directory = Paths.get(textfieldDirectoryPath.getText());
if (Files.notExists(directory)) {
directory = Paths.get(System.getProperty("user.dir"));
}
if (!Files.isDirectory(directory)) {
directory = directory.getParent();
}
//this addtional statement is needed because for the lamdba the variable must be effetively final
Path dir = directory;
storeLastSelectedDirectory(directory);
progressBarSearching.setMinimumSize(new Dimension(buttonScan.getSize().width, progressBarSearching.getMinimumSize().height));
progressBarSearching.setVisible(true);
progressBarSearching.setString("");
labelSearchingDirectoryInfo.setVisible(true);
buttonScan.setVisible(false);
disOrEnableDialog(false);
labelSearchingDirectoryInfo.setEnabled(true);
final FileFilter selectedFileFilter = (FileFilter) comboBoxFileTypeSelection.getSelectedItem();
threadState.set(true);
JabRefExecutorService.INSTANCE.execute(() -> {
UnlinkedPDFFileFilter unlinkedPDFFileFilter = new UnlinkedPDFFileFilter(selectedFileFilter, databaseContext);
CheckableTreeNode rootNode = crawler.searchDirectory(dir.toFile(), unlinkedPDFFileFilter, threadState, new ChangeListener() {
int counter;
@Override
public void stateChanged(ChangeEvent e) {
counter++;
String message;
if (counter == 1) {
message = Localization.lang("One file found");
} else {
message = Localization.lang("%0 files found", Integer.toString(counter));
}
progressBarSearching.setString(message);
}
});
searchFinishedHandler(rootNode);
});
}
Aggregations