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 6488 #6535

Closed
wants to merge 14 commits into from
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

<!-- markdownlint-disable-file MD024 MD033 -->

29 changes: 27 additions & 2 deletions src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -56,6 +60,8 @@ public class ImportEntriesViewModel extends AbstractViewModel {
private ObservableList<BibEntry> entries;
private PreferencesService preferences;

private Optional<BibEntry> internalDuplicate;
private Optional<BibEntry> datasetDuplicate;
/**
* @param databaseContext the database to import into
* @param task the task executed for parsing the selected files(s).
Expand Down Expand Up @@ -92,10 +98,16 @@ public ObservableList<BibEntry> 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();
}

/**
Expand All @@ -110,8 +122,21 @@ public void importEntries(List<BibEntry> 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"),
Expand Down
25 changes: 17 additions & 8 deletions src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -183,15 +188,19 @@ private Node createGroupColorRegion(BibEntryTableViewModel entry, List<AbstractG
container.setAlignment(Pos.CENTER_LEFT);
container.setPadding(new Insets(0, 2, 0, 2));

Set< Color > 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()
Expand Down