diff --git a/CHANGELOG.md b/CHANGELOG.md index 558e2ac8107..715c7a1e8a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ## [Unreleased] ### Changed +If fetched article is already in database the ImportInspectionDialog is started ### Fixed We fixed an issue where the fetcher for the Astrophysics Data System (ADS) added some non-bibtex data to the entry returned from the search [#3035](https://github.com/JabRef/jabref/issues/3035) diff --git a/src/main/java/org/jabref/gui/EntryTypeDialog.java b/src/main/java/org/jabref/gui/EntryTypeDialog.java index 27c0e5f1d55..f9b09fea886 100644 --- a/src/main/java/org/jabref/gui/EntryTypeDialog.java +++ b/src/main/java/org/jabref/gui/EntryTypeDialog.java @@ -26,7 +26,9 @@ import javax.swing.SwingWorker; import org.jabref.Globals; +import org.jabref.gui.importer.ImportInspectionDialog; import org.jabref.gui.keyboard.KeyBinding; +import org.jabref.logic.bibtex.DuplicateCheck; import org.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil; import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.IdBasedFetcher; @@ -305,10 +307,22 @@ protected void done() { Optional result = get(); if (result.isPresent()) { final BibEntry bibEntry = result.get(); - // Regenerate CiteKey of imported BibEntry - BibtexKeyPatternUtil.makeAndSetLabel(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern(), frame.getCurrentBasePanel().getDatabase(), bibEntry, Globals.prefs.getBibtexKeyPatternPreferences()); + if ((DuplicateCheck.containsDuplicate(frame.getCurrentBasePanel().getDatabase(), bibEntry, frame.getCurrentBasePanel().getBibDatabaseContext().getMode()).isPresent())) { + //If there are duplicates starts ImportInspectionDialog + final BasePanel panel = (BasePanel) frame.getTabbedPane().getSelectedComponent(); + + ImportInspectionDialog diag = new ImportInspectionDialog(frame, panel, Localization.lang("Import"), false); + diag.addEntry(bibEntry); + diag.entryListComplete(); + diag.setLocationRelativeTo(frame); + diag.setVisible(true); + diag.toFront(); + } else { + // Regenerate CiteKey of imported BibEntry + BibtexKeyPatternUtil.makeAndSetLabel(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern(), frame.getCurrentBasePanel().getDatabase(), bibEntry, Globals.prefs.getBibtexKeyPatternPreferences()); + frame.getCurrentBasePanel().insertEntry(bibEntry); + } - frame.getCurrentBasePanel().insertEntry(bibEntry); dispose(); } else if (searchID.trim().isEmpty()) { JOptionPane.showMessageDialog(frame, Localization.lang("The given search ID was empty."), Localization.lang("Empty search ID"), JOptionPane.WARNING_MESSAGE);