Search in sources :

Example 1 with PdfContentImporter

use of org.jabref.logic.importer.fileformat.PdfContentImporter in project jabref by JabRef.

the class ImporterTest method instancesToTest.

@Parameters(name = "{index}: {0}")
public static Collection<Object[]> instancesToTest() {
    // all classes implementing {@link Importer}
    // sorted alphabetically
    ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class);
    XMPPreferences xmpPreferences = mock(XMPPreferences.class);
    // @formatter:off
    return Arrays.asList(new Object[] { new BiblioscapeImporter() }, new Object[] { new BibtexImporter(importFormatPreferences) }, new Object[] { new BibTeXMLImporter() }, new Object[] { new CopacImporter() }, new Object[] { new EndnoteImporter(importFormatPreferences) }, new Object[] { new FreeCiteImporter(importFormatPreferences) }, new Object[] { new InspecImporter() }, new Object[] { new IsiImporter() }, new Object[] { new MedlineImporter() }, new Object[] { new MedlinePlainImporter() }, new Object[] { new ModsImporter() }, new Object[] { new MsBibImporter() }, new Object[] { new OvidImporter() }, new Object[] { new PdfContentImporter(importFormatPreferences) }, new Object[] { new PdfXmpImporter(xmpPreferences) }, new Object[] { new RepecNepImporter(importFormatPreferences) }, new Object[] { new RisImporter() }, new Object[] { new SilverPlatterImporter() });
// @formatter:on
}
Also used : BiblioscapeImporter(org.jabref.logic.importer.fileformat.BiblioscapeImporter) IsiImporter(org.jabref.logic.importer.fileformat.IsiImporter) RisImporter(org.jabref.logic.importer.fileformat.RisImporter) MsBibImporter(org.jabref.logic.importer.fileformat.MsBibImporter) RepecNepImporter(org.jabref.logic.importer.fileformat.RepecNepImporter) EndnoteImporter(org.jabref.logic.importer.fileformat.EndnoteImporter) SilverPlatterImporter(org.jabref.logic.importer.fileformat.SilverPlatterImporter) CopacImporter(org.jabref.logic.importer.fileformat.CopacImporter) ModsImporter(org.jabref.logic.importer.fileformat.ModsImporter) OvidImporter(org.jabref.logic.importer.fileformat.OvidImporter) PdfContentImporter(org.jabref.logic.importer.fileformat.PdfContentImporter) XMPPreferences(org.jabref.logic.xmp.XMPPreferences) MedlinePlainImporter(org.jabref.logic.importer.fileformat.MedlinePlainImporter) BibTeXMLImporter(org.jabref.logic.importer.fileformat.BibTeXMLImporter) InspecImporter(org.jabref.logic.importer.fileformat.InspecImporter) BibtexImporter(org.jabref.logic.importer.fileformat.BibtexImporter) MedlineImporter(org.jabref.logic.importer.fileformat.MedlineImporter) PdfXmpImporter(org.jabref.logic.importer.fileformat.PdfXmpImporter) FreeCiteImporter(org.jabref.logic.importer.fileformat.FreeCiteImporter) Parameters(org.junit.runners.Parameterized.Parameters)

Example 2 with PdfContentImporter

use of org.jabref.logic.importer.fileformat.PdfContentImporter in project jabref by JabRef.

the class ImportFormatReader method resetImportFormats.

public void resetImportFormats(ImportFormatPreferences newImportFormatPreferences, XMPPreferences xmpPreferences) {
    this.importFormatPreferences = newImportFormatPreferences;
    formats.clear();
    formats.add(new BiblioscapeImporter());
    formats.add(new BibtexImporter(importFormatPreferences));
    formats.add(new BibTeXMLImporter());
    formats.add(new CopacImporter());
    formats.add(new EndnoteImporter(importFormatPreferences));
    formats.add(new FreeCiteImporter(importFormatPreferences));
    formats.add(new InspecImporter());
    formats.add(new IsiImporter());
    formats.add(new MedlineImporter());
    formats.add(new MedlinePlainImporter());
    formats.add(new ModsImporter());
    formats.add(new MsBibImporter());
    formats.add(new OvidImporter());
    formats.add(new PdfContentImporter(importFormatPreferences));
    formats.add(new PdfXmpImporter(xmpPreferences));
    formats.add(new RepecNepImporter(importFormatPreferences));
    formats.add(new RisImporter());
    formats.add(new SilverPlatterImporter());
    // Get custom import formats
    for (CustomImporter importer : importFormatPreferences.getCustomImportList()) {
        formats.add(importer);
    }
}
Also used : BiblioscapeImporter(org.jabref.logic.importer.fileformat.BiblioscapeImporter) IsiImporter(org.jabref.logic.importer.fileformat.IsiImporter) RisImporter(org.jabref.logic.importer.fileformat.RisImporter) CustomImporter(org.jabref.logic.importer.fileformat.CustomImporter) MsBibImporter(org.jabref.logic.importer.fileformat.MsBibImporter) RepecNepImporter(org.jabref.logic.importer.fileformat.RepecNepImporter) EndnoteImporter(org.jabref.logic.importer.fileformat.EndnoteImporter) SilverPlatterImporter(org.jabref.logic.importer.fileformat.SilverPlatterImporter) CopacImporter(org.jabref.logic.importer.fileformat.CopacImporter) ModsImporter(org.jabref.logic.importer.fileformat.ModsImporter) OvidImporter(org.jabref.logic.importer.fileformat.OvidImporter) PdfContentImporter(org.jabref.logic.importer.fileformat.PdfContentImporter) MedlinePlainImporter(org.jabref.logic.importer.fileformat.MedlinePlainImporter) BibTeXMLImporter(org.jabref.logic.importer.fileformat.BibTeXMLImporter) InspecImporter(org.jabref.logic.importer.fileformat.InspecImporter) BibtexImporter(org.jabref.logic.importer.fileformat.BibtexImporter) MedlineImporter(org.jabref.logic.importer.fileformat.MedlineImporter) PdfXmpImporter(org.jabref.logic.importer.fileformat.PdfXmpImporter) FreeCiteImporter(org.jabref.logic.importer.fileformat.FreeCiteImporter)

Example 3 with PdfContentImporter

use of org.jabref.logic.importer.fileformat.PdfContentImporter in project jabref by JabRef.

the class PdfImporter method doContentImport.

private void doContentImport(String fileName, List<BibEntry> res) {
    PdfContentImporter contentImporter = new PdfContentImporter(Globals.prefs.getImportFormatPreferences());
    Path filePath = Paths.get(fileName);
    ParserResult result = contentImporter.importDatabase(filePath, Globals.prefs.getDefaultEncoding());
    if (result.hasWarnings()) {
        frame.showMessage(result.getErrorMessage());
    }
    if (!result.getDatabase().hasEntries()) {
        // import failed -> generate default entry
        createNewBlankEntry(fileName).ifPresent(res::add);
        return;
    }
    // only one entry is imported
    BibEntry entry = result.getDatabase().getEntries().get(0);
    // insert entry to database and link file
    panel.getDatabase().insertEntry(entry);
    panel.markBaseChanged();
    BibtexKeyPatternUtil.makeAndSetLabel(panel.getBibDatabaseContext().getMetaData().getCiteKeyPattern(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern()), panel.getDatabase(), entry, Globals.prefs.getBibtexKeyPatternPreferences());
    DroppedFileHandler dfh = new DroppedFileHandler(frame, panel);
    dfh.linkPdfToEntry(fileName, entry);
    SwingUtilities.invokeLater(() -> panel.highlightEntry(entry));
    if (Globals.prefs.getBoolean(JabRefPreferences.AUTO_OPEN_FORM)) {
        EntryEditor editor = panel.getEntryEditor(entry);
        panel.showEntryEditor(editor);
    }
    res.add(entry);
}
Also used : Path(java.nio.file.Path) ParserResult(org.jabref.logic.importer.ParserResult) BibEntry(org.jabref.model.entry.BibEntry) EntryEditor(org.jabref.gui.entryeditor.EntryEditor) PdfContentImporter(org.jabref.logic.importer.fileformat.PdfContentImporter) DroppedFileHandler(org.jabref.gui.externalfiles.DroppedFileHandler)

Aggregations

PdfContentImporter (org.jabref.logic.importer.fileformat.PdfContentImporter)3 BibTeXMLImporter (org.jabref.logic.importer.fileformat.BibTeXMLImporter)2 BiblioscapeImporter (org.jabref.logic.importer.fileformat.BiblioscapeImporter)2 BibtexImporter (org.jabref.logic.importer.fileformat.BibtexImporter)2 CopacImporter (org.jabref.logic.importer.fileformat.CopacImporter)2 EndnoteImporter (org.jabref.logic.importer.fileformat.EndnoteImporter)2 FreeCiteImporter (org.jabref.logic.importer.fileformat.FreeCiteImporter)2 InspecImporter (org.jabref.logic.importer.fileformat.InspecImporter)2 IsiImporter (org.jabref.logic.importer.fileformat.IsiImporter)2 MedlineImporter (org.jabref.logic.importer.fileformat.MedlineImporter)2 MedlinePlainImporter (org.jabref.logic.importer.fileformat.MedlinePlainImporter)2 ModsImporter (org.jabref.logic.importer.fileformat.ModsImporter)2 MsBibImporter (org.jabref.logic.importer.fileformat.MsBibImporter)2 OvidImporter (org.jabref.logic.importer.fileformat.OvidImporter)2 PdfXmpImporter (org.jabref.logic.importer.fileformat.PdfXmpImporter)2 RepecNepImporter (org.jabref.logic.importer.fileformat.RepecNepImporter)2 RisImporter (org.jabref.logic.importer.fileformat.RisImporter)2 SilverPlatterImporter (org.jabref.logic.importer.fileformat.SilverPlatterImporter)2 Path (java.nio.file.Path)1 EntryEditor (org.jabref.gui.entryeditor.EntryEditor)1