diff --git a/CHANGELOG.md b/CHANGELOG.md index 960465f900b..261646e2b47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We added keybindings for setting and clearing the read status. [#7264](https://github.com/JabRef/jabref/issues/7264) - We added two new fields to track the creation and most recent modification date and time for each entry. [koppor#130](https://github.com/koppor/jabref/issues/130) - We added a feature that allows the user to copy highlighted text in the preview window. [#6962](https://github.com/JabRef/jabref/issues/6962) +- We added a feature that allows you to create new BibEntry via paste arxivId [#2292](https://github.com/JabRef/jabref/issues/2292) ### Changed diff --git a/src/main/java/org/jabref/gui/ClipBoardManager.java b/src/main/java/org/jabref/gui/ClipBoardManager.java index d66db4c34a7..290cb774c72 100644 --- a/src/main/java/org/jabref/gui/ClipBoardManager.java +++ b/src/main/java/org/jabref/gui/ClipBoardManager.java @@ -27,10 +27,12 @@ import org.jabref.logic.importer.ImportFormatReader; import org.jabref.logic.importer.ImportFormatReader.UnknownFormatImport; import org.jabref.logic.importer.ParseException; +import org.jabref.logic.importer.fetcher.ArXiv; import org.jabref.logic.importer.fetcher.DoiFetcher; import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.identifier.ArXivIdentifier; import org.jabref.model.entry.identifier.DOI; import org.jabref.model.util.OptionalUtil; import org.jabref.preferences.PreferencesService; @@ -194,6 +196,10 @@ private List handleStringData(String data) { if (doi.isPresent()) { return fetchByDOI(doi.get()); } + Optional arXiv = ArXivIdentifier.parse(data); + if (arXiv.isPresent()) { + return fetchByArXiv(arXiv.get()); + } return tryImportFormats(data); } @@ -217,4 +223,15 @@ private List fetchByDOI(DOI doi) { return Collections.emptyList(); } } + + private List fetchByArXiv(ArXivIdentifier arXivIdentifier) { + LOGGER.info("Found arxiv identifier in clipboard"); + try { + Optional entry = new ArXiv(preferencesService.getImportFormatPreferences()).performSearchById(arXivIdentifier.getNormalizedWithoutVersion()); + return OptionalUtil.toList(entry); + } catch (FetcherException ex) { + LOGGER.error("Error while fetching", ex); + return Collections.emptyList(); + } + } }