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

Add compare button to duplicates in Citation relations tab #11915

Merged
merged 23 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c0f54ec
- Added a "Compare" button for duplicate entries in the CitationRelat…
KumaLuo Oct 11, 2024
2edb8b6
- Implemented functionality to open a "Possible duplicate entries" fo…
KumaLuo Oct 12, 2024
e3c759c
Merge branch 'main' into fix-for-issue-11192
KumaLuo Oct 12, 2024
ea4bb0e
Updated changelog
KumaLuo Oct 12, 2024
a708875
Merge branch 'fix-for-issue-11192' of https://github.com/KumaLuo/jabr…
KumaLuo Oct 12, 2024
09a35b0
- Updated localization key for compare button tooltip.
KumaLuo Oct 13, 2024
95c1362
Merge branch 'main' into fix-for-issue-11192
KumaLuo Oct 13, 2024
8bec936
Modified CitationsRelationsTabViewModel and ImportHandler to pass Cit…
KumaLuo Oct 13, 2024
8fc4f91
Merge branch 'fix-for-issue-11192' of https://github.com/KumaLuo/jabr…
KumaLuo Oct 13, 2024
5eed679
- Deleted old code in CitationRelationTab.java which to implement tha…
KumaLuo Oct 13, 2024
99fa500
Merge branch 'main' into fix-for-issue-11192
KumaLuo Oct 13, 2024
4bd4872
Optimised citation relations item merge: Added a citation merge flag …
KumaLuo Oct 14, 2024
4bf1f44
Optimised MainTable#clearAndSelect: make the code look more concise.
KumaLuo Oct 14, 2024
0710c3d
Merge branch 'main' into fix-for-issue-11192
KumaLuo Oct 14, 2024
9566980
Fixed bug: As original local entry of citation relation item has been…
KumaLuo Oct 14, 2024
272e686
Merge branch 'main' into fix-for-issue-11192
KumaLuo Oct 14, 2024
f8736fc
Adapted tool tip of compare button.
KumaLuo Oct 15, 2024
6cfb3b9
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
KumaLuo Oct 15, 2024
447f220
Merge branch 'main' into fix-for-issue-11192
koppor Oct 15, 2024
080e80f
- renamed some variables to make them more understandable
KumaLuo Oct 15, 2024
5f4264c
Merge branch 'main' into fix-for-issue-11192
koppor Oct 16, 2024
fbbd5f0
Move statement closer to intended use
koppor Oct 16, 2024
2631280
Modified the column headings of the merge entries dialog to make them…
KumaLuo Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added a different background color to the search bar to indicate when the search syntax is wrong. [#11658](https://github.com/JabRef/jabref/pull/11658)
- We added a setting which always adds the literal "Cited on pages" text before each JStyle citation. [#11691](https://github.com/JabRef/jabref/pull/11732)
- We added a new plain citation parser that uses LLMs. [#11825](https://github.com/JabRef/jabref/issues/11825)
- Added a compare button to the duplicates in the citation relations tab to open the "Possible duplicate entries" window. [#11192](https://github.com/JabRef/jabref/issues/11192)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"We added" 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 I will fix that


### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import javax.swing.undo.UndoManager;

Expand Down Expand Up @@ -39,6 +40,9 @@
import org.jabref.gui.entryeditor.citationrelationtab.semanticscholar.CitationFetcher;
import org.jabref.gui.entryeditor.citationrelationtab.semanticscholar.SemanticScholarFetcher;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.mergeentries.EntriesMergeResult;
import org.jabref.gui.mergeentries.MergeEntriesDialog;
import org.jabref.gui.mergeentries.MergeTwoEntriesAction;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.gui.util.NoSelectionModel;
import org.jabref.gui.util.ViewModelListCellFactory;
Expand Down Expand Up @@ -89,6 +93,8 @@ public class CitationRelationsTab extends EntryEditorTab {
private final CitationsRelationsTabViewModel citationsRelationsTabViewModel;
private final DuplicateCheck duplicateCheck;
private final BibEntryTypesManager entryTypesManager;
private final StateManager stateManager;
private final UndoManager undoManager;

public CitationRelationsTab(DialogService dialogService,
BibDatabaseContext databaseContext,
Expand All @@ -104,6 +110,8 @@ public CitationRelationsTab(DialogService dialogService,
this.preferences = preferences;
this.libraryTab = libraryTab;
this.taskExecutor = taskExecutor;
this.undoManager = undoManager;
this.stateManager = stateManager;
setText(Localization.lang("Citation relations"));
setTooltip(new Tooltip(Localization.lang("Show articles related by citation")));

Expand Down Expand Up @@ -238,6 +246,13 @@ private void styleFetchedListView(CheckListView<CitationRelationItem> listView)
libraryTab.clearAndSelect(entry.localEntry());
});
vContainer.getChildren().add(jumpTo);

Button compareButton = IconTheme.JabRefIcons.MERGE_ENTRIES.asButton();
compareButton.setTooltip(new Tooltip(Localization.lang("Compare with duplicate entries")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "duplicate" is not a good term. It is about an existing entry in the library

Suggested change
compareButton.setTooltip(new Tooltip(Localization.lang("Compare with duplicate entries")));
compareButton.setTooltip(new Tooltip(Localization.lang("Compare with existing entries")));

compareButton.setOnMouseClicked(event -> {
openPossibleDuplicateEntriesWindow(entry);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that every entry is potentially a duplicate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the broader context of the code, there’s a DuplicateCheck object that checks if an entry in the database has a duplicate. When the comparison button is created, the button is only shown when a potential duplicate is detected. This happens because of the duplicateCheck.containsDuplicate() method. If this method detects a duplicate for a given entry, the compareButton will allow the user to compare the entries. I'm sorry.I may not understand the point of the question, do I need to make any changes?😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, CitationRelationItem.isLocal() returns whether it's a duplicate or not?

Copy link
Contributor Author

@KumaLuo KumaLuo Oct 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think CitationRelationItem.isLocal() returns true if entries in citation relations tab have been detected there is a possible duplicate entry in local current database.
image

});
vContainer.getChildren().add(compareButton);
} else {
ToggleButton addToggle = IconTheme.JabRefIcons.ADD.asToggleButton();
addToggle.setTooltip(new Tooltip(Localization.lang("Select entry")));
Expand Down Expand Up @@ -504,4 +519,24 @@ private void importEntries(List<CitationRelationItem> entriesToImport, CitationF

dialogService.notify(Localization.lang("Number of entries successfully imported") + ": " + entriesToImport.size());
}

/**
* Function to open possible duplicate entries window to compare duplicate entries
*
* @param duplicateItem duplicate in the citation relations tab
*/
private void openPossibleDuplicateEntriesWindow(CitationRelationItem duplicateItem) {
BibEntry localEntry = duplicateItem.localEntry();
BibEntry duplicateEntry = duplicateItem.entry();

MergeEntriesDialog dialog = new MergeEntriesDialog(localEntry, duplicateEntry, preferences);
dialog.setTitle(Localization.lang("Possible duplicate entries"));

Optional<EntriesMergeResult> mergeResultOpt = dialogService.showCustomDialogAndWait(dialog);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need the Opt suffix? - You can name it entriesMergeResult and one line below use mergeResult if you like shorter variables.

mergeResultOpt.ifPresentOrElse(entriesMergeResult -> {
new MergeTwoEntriesAction(entriesMergeResult, stateManager, undoManager).execute();

dialogService.notify(Localization.lang("Merged entries"));
}, () -> dialogService.notify(Localization.lang("Canceled merging entries")));
}
}
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2797,3 +2797,5 @@ Warning\:\ The\ selected\ directory\ is\ not\ a\ valid\ directory.=Warning: The
Currently\ selected\ JStyle\:\ '%0' = Currently selected JStyle: '%0'
Currently\ selected\ CSL\ Style\:\ '%0' = Currently selected CSL Style: '%0'
Store\ url\ for\ downloaded\ file=Store url for downloaded file

Compare\ with\ duplicate\ entries=Compare with duplicate entries
Loading