diff --git a/CHANGELOG.md b/CHANGELOG.md index e443c7ae84d..b5913812321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -128,6 +128,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the blue and red text colors in the Merge entries dialog were not quite visible [#6334](https://github.com/JabRef/jabref/issues/6334) - We fixed an issue where underscore character was removed from the file name in the Recent Libraries list in File menu [#6383](https://github.com/JabRef/jabref/issues/6383) - We fixed an issue where few keyboard shortcuts regarding new entries were missing [#6403](https://github.com/JabRef/jabref/issues/6403) +- We fixed an issue that showing teh duplicate information more clear. [#6488](https://github.com/JabRef/jabref/issues/6488) ### Removed - Ampersands are no longer escaped by default in the `bib` file. If you want to keep the current behaviour, you can use the new "Escape Ampersands" formatter as a save action. [#5869](https://github.com/JabRef/jabref/issues/5869) @@ -370,3 +371,4 @@ The changelog of JabRef 2.11 and all previous versions is available as [text fil [5.0-alpha]: https://github.com/JabRef/jabref/compare/v4.3...v5.0-alpha + diff --git a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java index 4ae14f8b324..15e3314104b 100644 --- a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java +++ b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java @@ -33,11 +33,15 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibtexString; import org.jabref.model.entry.LinkedFile; +import org.jabref.model.entry.field.Field; +import org.jabref.model.entry.field.InternalField; +import org.jabref.model.entry.field.StandardField; import org.jabref.model.groups.GroupTreeNode; import org.jabref.model.metadata.MetaData; import org.jabref.model.util.FileUpdateMonitor; import org.jabref.preferences.PreferencesService; +import com.google.common.collect.Sets; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,6 +60,8 @@ public class ImportEntriesViewModel extends AbstractViewModel { private ObservableList entries; private PreferencesService preferences; + private Optional internalDuplicate; + private Optional datasetDuplicate; /** * @param databaseContext the database to import into * @param task the task executed for parsing the selected files(s). @@ -92,10 +98,16 @@ public ObservableList getEntries() { return entries; } - public boolean hasDuplicate(BibEntry entry) { + /*public boolean hasDuplicate(BibEntry entry) { return findInternalDuplicate(entry).isPresent() || new DuplicateCheck(Globals.entryTypesManager).containsDuplicate(databaseContext.getDatabase(), entry, databaseContext.getMode()).isPresent(); + }*/ + public boolean hasDuplicate(BibEntry entry) { + + this.internalDuplicate = findInternalDuplicate(entry); + this.datasetDuplicate = new DuplicateCheck(Globals.entryTypesManager).containsDuplicate(databaseContext.getDatabase(), entry, databaseContext.getMode()); + return this.internalDuplicate.isPresent() || this.datasetDuplicate.isPresent(); } /** @@ -110,8 +122,21 @@ public void importEntries(List entriesToImport, boolean downloadFiles) BackgroundTask.wrap(() -> entriesToImport.stream() .anyMatch(this::hasDuplicate)).onSuccess(duplicateFound -> { if (duplicateFound) { + StringBuffer duplicateInfo = new StringBuffer("There are possible duplicates (") ; + if (this.datasetDuplicate.isPresent()){ + duplicateInfo.append("duplicate to the entry in the database whose Bibtexkey is : "); + duplicateInfo.append(this.datasetDuplicate.get().getField(InternalField.KEY_FIELD).get()); + } + else if (this.internalDuplicate.isPresent()){ + duplicateInfo.append("duplicate to the entry in the list of entries to be imported whose title is : "); + duplicateInfo.append(this.internalDuplicate.get().getField(StandardField.TITLE).get()); + + } + duplicateInfo.append(") that haven't been resolved. Continue?"); + boolean continueImport = dialogService.showConfirmationDialogWithOptOutAndWait(Localization.lang("Duplicates found"), - Localization.lang("There are possible duplicates (marked with an icon) that haven't been resolved. Continue?"), + //Localization.lang("There are possible duplicates (marked with an icon) that haven't been resolved. Continue?"), + Localization.lang(duplicateInfo.toString()), Localization.lang("Continue with import"), Localization.lang("Cancel import"), Localization.lang("Disable this confirmation dialog"), diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java index c66a530f5fe..dc1949b1622 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java @@ -1,11 +1,16 @@ + + + package org.jabref.gui.maintable; import java.io.IOException; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import javax.swing.undo.UndoManager; @@ -183,15 +188,19 @@ private Node createGroupColorRegion(BibEntryTableViewModel entry, List colorSet = new HashSet<>(); for (Color groupColor : groupColors) { - Rectangle groupRectangle = new Rectangle(); - groupRectangle.getStyleClass().add("groupColumnBackground"); - groupRectangle.setWidth(3); - groupRectangle.setHeight(18); - groupRectangle.setFill(groupColor); - groupRectangle.setStrokeWidth(1); - - container.getChildren().add(groupRectangle); + if (!colorSet.contains(groupColor)) { + Rectangle groupRectangle = new Rectangle(); + groupRectangle.getStyleClass().add("groupColumnBackground"); + groupRectangle.setWidth(3); + groupRectangle.setHeight(18); + groupRectangle.setFill(groupColor); + groupRectangle.setStrokeWidth(1); + + container.getChildren().add(groupRectangle); + colorSet.add(groupColor); + } } String matchedGroupsString = matchedGroups.stream()