Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate check/merge entries dialog not triggered on import from… #10914

Merged
merged 10 commits into from
Feb 27, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed the colors of the icon on hover for unset special fields. [#10431](https://github.com/JabRef/jabref/issues/10431)
- We fixed an issue where the CrossRef field did not work if autocompletion was disabled [#8145](https://github.com/JabRef/jabref/issues/8145)
- We fixed an issue where exporting`@electronic` and `@online` entry types to the Office XMl would duplicate the field `title` [#10807](https://github.com/JabRef/jabref/issues/10807)
- We fixed an issue where importing using JabRef's browser extension would not trigger the merge dialog [#10914](https://github.com/JabRef/jabref/pull/10914)

### Removed

Expand Down
30 changes: 3 additions & 27 deletions src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,31 +142,6 @@ public String getSourceString(BibEntry entry) {
* @param entriesToImport subset of the entries contained in parserResult
*/
public void importEntries(List<BibEntry> entriesToImport, boolean shouldDownloadFiles) {
// Check if we are supposed to warn about duplicates.
// If so, then see if there are duplicates, and warn if yes.
if (preferences.getImporterPreferences().shouldWarnAboutDuplicatesOnImport()) {
BackgroundTask.wrap(() -> entriesToImport.stream()
.anyMatch(this::hasDuplicate)).onSuccess(duplicateFound -> {
if (duplicateFound) {
boolean continueImport = dialogService.showConfirmationDialogWithOptOutAndWait(Localization.lang("Duplicates found"),
Localization.lang("There are possible duplicates that haven't been resolved. Continue?"),
Localization.lang("Continue with import"),
Localization.lang("Cancel import"),
Localization.lang("Do not ask again"),
optOut -> preferences.getImporterPreferences().setWarnAboutDuplicatesOnImport(!optOut));

if (!continueImport) {
dialogService.notify(Localization.lang("Import canceled"));
} else {
buildImportHandlerThenImportEntries(entriesToImport);
}
} else {
buildImportHandlerThenImportEntries(entriesToImport);
}
}).executeWith(taskExecutor);
} else {
buildImportHandlerThenImportEntries(entriesToImport);
}

// Remember the selection in the dialog
preferences.getFilePreferences().setDownloadLinkedFiles(shouldDownloadFiles);
Expand All @@ -193,7 +168,8 @@ public void importEntries(List<BibEntry> entriesToImport, boolean shouldDownload
parserResult.getPath().map(path -> path.getFileName().toString()).orElse("unknown"),
parserResult.getDatabase().getEntries());

// JabRefGUI.getMainFrame().getCurrentLibraryTab().markBaseChanged();
buildImportHandlerThenImportEntries(entriesToImport);
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved

}

private void buildImportHandlerThenImportEntries(List<BibEntry> entriesToImport) {
Expand All @@ -205,7 +181,7 @@ private void buildImportHandlerThenImportEntries(List<BibEntry> entriesToImport)
stateManager,
dialogService,
taskExecutor);
importHandler.importEntries(entriesToImport);
importHandler.importEntriesWithDuplicateCheck(selectedDb.getValue(), entriesToImport);
dialogService.notify(Localization.lang("Number of entries successfully imported") + ": " + entriesToImport.size());
}

Expand Down
Loading