From 0b9f8a587c289f09ab35b0dc244c1eea70f166c6 Mon Sep 17 00:00:00 2001 From: "predrag.milanovicMin" Date: Tue, 18 Jul 2017 11:07:09 +0200 Subject: [PATCH 1/4] If new fetched entity is duplicate starts ImportInspectionDialog --- .../java/org/jabref/gui/EntryTypeDialog.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/EntryTypeDialog.java b/src/main/java/org/jabref/gui/EntryTypeDialog.java index 27c0e5f1d55..4f98d36177e 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; @@ -304,11 +306,24 @@ protected void done() { try { 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()); + final BibEntry bibEntry = result.get(); + 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); From bd6f1d2620c2b026dff29d33e73058f19cc17ccf Mon Sep 17 00:00:00 2001 From: pmilanovicMin Date: Wed, 19 Jul 2017 10:25:41 +0200 Subject: [PATCH 2/4] Corrected white space --- .../java/org/jabref/gui/EntryTypeDialog.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/jabref/gui/EntryTypeDialog.java b/src/main/java/org/jabref/gui/EntryTypeDialog.java index 4f98d36177e..b81b4e5179c 100644 --- a/src/main/java/org/jabref/gui/EntryTypeDialog.java +++ b/src/main/java/org/jabref/gui/EntryTypeDialog.java @@ -306,23 +306,23 @@ protected void done() { try { Optional result = get(); if (result.isPresent()) { - final BibEntry bibEntry = result.get(); - if((DuplicateCheck.containsDuplicate(frame.getCurrentBasePanel().getDatabase(), bibEntry, frame.getCurrentBasePanel().getBibDatabaseContext().getMode()).isPresent())){ + final BibEntry bibEntry = result.get(); + 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{ + 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); - } + BibtexKeyPatternUtil.makeAndSetLabel(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern(), frame.getCurrentBasePanel().getDatabase(), bibEntry, Globals.prefs.getBibtexKeyPatternPreferences()); + frame.getCurrentBasePanel().insertEntry(bibEntry); + } dispose(); } else if (searchID.trim().isEmpty()) { From eeb73a1e59a26bd3ec284184746308e1cd8b0983 Mon Sep 17 00:00:00 2001 From: pmilanovicMin Date: Tue, 1 Aug 2017 15:08:47 +0200 Subject: [PATCH 3/4] Corrected whitespace --- src/main/java/org/jabref/gui/EntryTypeDialog.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/EntryTypeDialog.java b/src/main/java/org/jabref/gui/EntryTypeDialog.java index b81b4e5179c..f9b09fea886 100644 --- a/src/main/java/org/jabref/gui/EntryTypeDialog.java +++ b/src/main/java/org/jabref/gui/EntryTypeDialog.java @@ -307,7 +307,7 @@ protected void done() { Optional result = get(); if (result.isPresent()) { final BibEntry bibEntry = result.get(); - if((DuplicateCheck.containsDuplicate(frame.getCurrentBasePanel().getDatabase(), bibEntry, frame.getCurrentBasePanel().getBibDatabaseContext().getMode()).isPresent())) { + 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(); @@ -317,8 +317,7 @@ protected void done() { diag.setLocationRelativeTo(frame); diag.setVisible(true); diag.toFront(); - } - else { + } else { // Regenerate CiteKey of imported BibEntry BibtexKeyPatternUtil.makeAndSetLabel(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern(), frame.getCurrentBasePanel().getDatabase(), bibEntry, Globals.prefs.getBibtexKeyPatternPreferences()); frame.getCurrentBasePanel().insertEntry(bibEntry); From 8b08bda0c5f84e79d3f6172d52abd1a4680a832b Mon Sep 17 00:00:00 2001 From: pmilanovicMin Date: Tue, 1 Aug 2017 15:40:32 +0200 Subject: [PATCH 4/4] Added a changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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)