Skip to content

Commit d938a3e

Browse files
mpeleSiedlerchr
authored andcommitted
Import dialog when fetch (#3025)
* If new fetched entity is duplicate starts ImportInspectionDialog * Corrected white space * Corrected whitespace * Added a changelog entry
1 parent 3a90664 commit d938a3e

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
1111
## [Unreleased]
1212

1313
### Changed
14+
If fetched article is already in database the ImportInspectionDialog is started
1415

1516
### Fixed
1617
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)

src/main/java/org/jabref/gui/EntryTypeDialog.java

+17-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import javax.swing.SwingWorker;
2727

2828
import org.jabref.Globals;
29+
import org.jabref.gui.importer.ImportInspectionDialog;
2930
import org.jabref.gui.keyboard.KeyBinding;
31+
import org.jabref.logic.bibtex.DuplicateCheck;
3032
import org.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil;
3133
import org.jabref.logic.importer.FetcherException;
3234
import org.jabref.logic.importer.IdBasedFetcher;
@@ -305,10 +307,22 @@ protected void done() {
305307
Optional<BibEntry> result = get();
306308
if (result.isPresent()) {
307309
final BibEntry bibEntry = result.get();
308-
// Regenerate CiteKey of imported BibEntry
309-
BibtexKeyPatternUtil.makeAndSetLabel(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern(), frame.getCurrentBasePanel().getDatabase(), bibEntry, Globals.prefs.getBibtexKeyPatternPreferences());
310+
if ((DuplicateCheck.containsDuplicate(frame.getCurrentBasePanel().getDatabase(), bibEntry, frame.getCurrentBasePanel().getBibDatabaseContext().getMode()).isPresent())) {
311+
//If there are duplicates starts ImportInspectionDialog
312+
final BasePanel panel = (BasePanel) frame.getTabbedPane().getSelectedComponent();
313+
314+
ImportInspectionDialog diag = new ImportInspectionDialog(frame, panel, Localization.lang("Import"), false);
315+
diag.addEntry(bibEntry);
316+
diag.entryListComplete();
317+
diag.setLocationRelativeTo(frame);
318+
diag.setVisible(true);
319+
diag.toFront();
320+
} else {
321+
// Regenerate CiteKey of imported BibEntry
322+
BibtexKeyPatternUtil.makeAndSetLabel(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern(), frame.getCurrentBasePanel().getDatabase(), bibEntry, Globals.prefs.getBibtexKeyPatternPreferences());
323+
frame.getCurrentBasePanel().insertEntry(bibEntry);
324+
}
310325

311-
frame.getCurrentBasePanel().insertEntry(bibEntry);
312326
dispose();
313327
} else if (searchID.trim().isEmpty()) {
314328
JOptionPane.showMessageDialog(frame, Localization.lang("The given search ID was empty."), Localization.lang("Empty search ID"), JOptionPane.WARNING_MESSAGE);

0 commit comments

Comments
 (0)