Search in sources :

Example 1 with FulltextFetchers

use of org.jabref.logic.importer.FulltextFetchers in project jabref by JabRef.

the class LinkedFilesEditorViewModel method fetchFulltext.

public void fetchFulltext() {
    if (entry.isPresent()) {
        FulltextFetchers fetcher = new FulltextFetchers(Globals.prefs.getImportFormatPreferences());
        BackgroundTask.wrap(() -> fetcher.findFullTextPDF(entry.get())).onRunning(() -> fulltextLookupInProgress.setValue(true)).onFinished(() -> fulltextLookupInProgress.setValue(false)).onSuccess(url -> {
            if (url.isPresent()) {
                addFromURL(url.get());
            } else {
                dialogService.notify(Localization.lang("Full text document download failed"));
            }
        }).executeWith(taskExecutor);
    }
}
Also used : FulltextFetchers(org.jabref.logic.importer.FulltextFetchers) URL(java.net.URL) BindingsHelper(org.jabref.gui.util.BindingsHelper) FXCollections(javafx.collections.FXCollections) DialogService(org.jabref.gui.DialogService) SimpleListProperty(javafx.beans.property.SimpleListProperty) JabRefPreferences(org.jabref.preferences.JabRefPreferences) FileDownloadTask(org.jabref.gui.externalfiles.FileDownloadTask) LinkedFile(org.jabref.model.entry.LinkedFile) ArrayList(java.util.ArrayList) URLDownload(org.jabref.logic.net.URLDownload) FulltextFetchers(org.jabref.logic.importer.FulltextFetchers) UnknownExternalFileType(org.jabref.gui.externalfiletype.UnknownExternalFileType) Localization(org.jabref.logic.l10n.Localization) FileFieldWriter(org.jabref.model.entry.FileFieldWriter) ListProperty(javafx.beans.property.ListProperty) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Path(java.nio.file.Path) ExternalFileType(org.jabref.gui.externalfiletype.ExternalFileType) FileFinders(org.jabref.logic.util.io.FileFinders) FileUtil(org.jabref.logic.util.io.FileUtil) FileDialogConfiguration(org.jabref.gui.util.FileDialogConfiguration) MalformedURLException(java.net.MalformedURLException) BibEntry(org.jabref.model.entry.BibEntry) DownloadExternalFile(org.jabref.gui.externalfiles.DownloadExternalFile) BackgroundTask(org.jabref.gui.util.BackgroundTask) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Globals(org.jabref.Globals) FileFinder(org.jabref.logic.util.io.FileFinder) FileHelper(org.jabref.model.util.FileHelper) TaskExecutor(org.jabref.gui.util.TaskExecutor) FileFieldParser(org.jabref.model.entry.FileFieldParser) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Paths(java.nio.file.Paths) OS(org.jabref.logic.util.OS) Optional(java.util.Optional) Log(org.apache.commons.logging.Log) ObservableList(javafx.collections.ObservableList) ExternalFileTypes(org.jabref.gui.externalfiletype.ExternalFileTypes) LogFactory(org.apache.commons.logging.LogFactory)

Example 2 with FulltextFetchers

use of org.jabref.logic.importer.FulltextFetchers in project jabref by JabRef.

the class FindFullTextAction method run.

@Override
public void run() {
    if (basePanel.getSelectedEntries().size() >= warningLimit) {
        String[] options = new String[] { Localization.lang("Look up full text documents"), Localization.lang("Cancel") };
        int answer = JOptionPane.showOptionDialog(basePanel.frame(), Localization.lang("You are about to look up full text documents for %0 entries.", String.valueOf(basePanel.getSelectedEntries().size())) + "\n" + Localization.lang("JabRef will send at least one request per entry to a publisher.") + "\n" + Localization.lang("Do you still want to continue?"), Localization.lang("Look up full text documents"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
        if (answer != JOptionPane.OK_OPTION) {
            basePanel.output(Localization.lang("Operation canceled."));
            return;
        }
    }
    for (BibEntry entry : basePanel.getSelectedEntries()) {
        FulltextFetchers fft = new FulltextFetchers(Globals.prefs.getImportFormatPreferences());
        downloads.put(fft.findFullTextPDF(entry), entry);
    }
}
Also used : FulltextFetchers(org.jabref.logic.importer.FulltextFetchers) BibEntry(org.jabref.model.entry.BibEntry)

Aggregations

FulltextFetchers (org.jabref.logic.importer.FulltextFetchers)2 BibEntry (org.jabref.model.entry.BibEntry)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 BooleanProperty (javafx.beans.property.BooleanProperty)1 ListProperty (javafx.beans.property.ListProperty)1 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)1 SimpleListProperty (javafx.beans.property.SimpleListProperty)1 FXCollections (javafx.collections.FXCollections)1 ObservableList (javafx.collections.ObservableList)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 Globals (org.jabref.Globals)1