Skip to content

Commit

Permalink
Import dialog when fetch (#3025)
Browse files Browse the repository at this point in the history
* If new fetched entity is duplicate starts ImportInspectionDialog

* Corrected white space

* Corrected whitespace

* Added a changelog entry
  • Loading branch information
mpele authored and Siedlerchr committed Aug 1, 2017
1 parent 3a90664 commit d938a3e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 17 additions & 3 deletions src/main/java/org/jabref/gui/EntryTypeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -305,10 +307,22 @@ protected void done() {
Optional<BibEntry> 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);
Expand Down

0 comments on commit d938a3e

Please sign in to comment.