-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Conversation
…ionsTab. - Added localization key for 'Compare with duplicate entries'.
For opening the compare window check out the MergeDialogEntriesDialog |
…r comparing and merging duplicate entries. - Updated changelog for compare button feature.
CHANGELOG.md
Outdated
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"We added" 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂 I will fix that
Button compareButton = IconTheme.JabRefIcons.MERGE_ENTRIES.asButton(); | ||
compareButton.setTooltip(new Tooltip(Localization.lang("Compare with duplicate entries"))); | ||
compareButton.setOnMouseClicked(event -> { | ||
openPossibleDuplicateEntriesWindow(entry); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?😅
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… into fix-for-issue-11192
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good first step.
After clicking "merge", the current entry should be kept selected - and not the merged entry be selected.
However, does not always work. It uses the entry of the citation relation if the entry was added to the library before
- Open citationr relations for paper P1
- Add citing paper P2 to library
- Edit P2 using JabRef
- Go back toi P1: Citatoin relations
- See that P2 is used - and not the paper retrieved by citation relatations
This could be another issue -- if you don't see how to fix it. - I think, there "only" needs to be a clone
made when adding an entry to the library.
@@ -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"))); |
There was a problem hiding this comment.
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
compareButton.setTooltip(new Tooltip(Localization.lang("Compare with duplicate entries"))); | |
compareButton.setTooltip(new Tooltip(Localization.lang("Compare with existing entries"))); |
- Fixed bug that when adding an entry to the library from Citation Relations Tab by adding the entry's clone instead of itself. - Optimised openPossibleDuplicateEntriesWindow function in CitationRelationsTab.java to show result of undo and redo. - Implemented that After clicking "merge", the current entry will be kept selected - and not the merged entry be selected.
Hi@koppor, I think my approach to change focus is a bit stupid, by reading the code in the LibraryTab.java and MainTable.java, it seems like that new added entry will always be selected, and my approach won't affect other functionalities. Any better suggestions? Thank you very much for your help! |
test failed, I will try to fix🥲 |
…ationsRelationsTabViewModelTest with clone entries.
… into fix-for-issue-11192
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO you should add code comments on the "why" of some things. I think, the five lines I commented on can just be removed without any change in functionality.
BibEntry current = libraryTab.getEntryEditor().getCurrentlyEditedEntry(); | ||
stateManager.getActiveDatabase().get().getDatabase().removeEntry(current); | ||
stateManager.getActiveDatabase().get().getDatabase().insertEntry(current); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this? These three lines remove and add the same entry? Can these lines just be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅As I said, this is a stupid method to change selected entry from merged entry to original one. And I have tested that org.jabref.gui.LibraryTab#clearAndSelect seems to have nothing to do with merge entries, the operation of merge entries should be related to Maintable#clearAndSelect, which will clear the current selection and select the entry just added. So I remove and add the original entry to make sure the original entry be selected after merge. I think I have found a better way. I'm working on it!🥰
@@ -194,6 +195,7 @@ public void importEntries(List<BibEntry> entries) { | |||
} | |||
|
|||
public void importCleanedEntries(List<BibEntry> entries) { | |||
entries = entries.stream().map(entry -> (BibEntry) entry.clone()).filter(Objects::nonNull).toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this filter(Objects::nonNull)
? I think, this can be removed. -- the list of entries should not contain null
(This code fragment seems to be AI generated - otherwise, it is OK)
libraryTab.showAndEdit(current); | ||
libraryTab.clearAndSelect(current); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you change to the new entry. What happens if you remove these two lines?
This is part of the journey! Suggestion add a breakpoint at |
…t original entry be selected after citation item merge. - Modified MainTable#clearAndSelect to ensure original entry be selected after citation item merge. - Added some comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things; I think, they correlate. If one is fixed, the other might be fixed, too.
Jumping to an entry does not work any more
Cllick on the button just scrolls to another position in the "Citation relations".
Keep scroll position
After merging of an entry, the scroll bar of "Citation relations" moves up.
Before:
After:
My test entry:
@Article{Thames2016,
author = {Thames, Lane and Schaefer, Dirk},
date = {2016},
journaltitle = {Procedia CIRP},
title = {Software-defined Cloud Manufacturing for Industry 4.0},
doi = {10.1016/j.procir.2016.07.041},
issn = {2212-8271},
pages = {12--17},
volume = {52},
abstract = {Procedia CIRP, 52 (2016) 12-17. doi:10.1016/j.procir.2016.07.041},
publisher = {Elsevier BV},
}
…in MainTable.java to let original entry get selected after merge instead of selecting new merged entry.
… changed to new merged entry, need to refresh selected citation relation item to ensure that the item link to current local entry instead of the old one.
@@ -238,6 +250,18 @@ 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 existing entries"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, it compares with a single entry – string should be adapted!
MergeEntriesDialog dialog = new MergeEntriesDialog(localEntry, duplicateEntry, preferences); | ||
dialog.setTitle(Localization.lang("Possible duplicate entries")); | ||
|
||
Optional<EntriesMergeResult> mergeResultOpt = dialogService.showCustomDialogAndWait(dialog); |
There was a problem hiding this comment.
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.
|
||
Optional<EntriesMergeResult> mergeResultOpt = dialogService.showCustomDialogAndWait(dialog); | ||
mergeResultOpt.ifPresentOrElse(entriesMergeResult -> { | ||
entriesMerge = entriesMergeResult.mergedEntry(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename to mergedEntry
. -- The variable name should state what's stored inside. It are not multiple entries. Moreover, consistency with a method name is nice.
@@ -82,6 +82,7 @@ public class MainTable extends TableView<BibEntryTableViewModel> { | |||
|
|||
private long lastKeyPressTime; | |||
private String columnSearchTerm; | |||
private boolean citationMerge = false; // citation merge flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment could be directed from the variable name. The "why" is missing. Either add a comment why this is required - or remove the comment (both is OK for me)
Name the variable citationMergeMode
.
@@ -492,4 +500,8 @@ private Optional<BibEntryTableViewModel> findEntry(BibEntry entry) { | |||
.filter(viewModel -> viewModel.getEntry().equals(entry)) | |||
.findFirst(); | |||
} | |||
|
|||
public void setCitationMerge(boolean merge) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe name it setCitationMergeMode
BibDatabase database = stateManager.getActiveDatabase().get().getDatabase(); | ||
|
||
database.removeEntry(entriesMergeResult.originalLeftEntry()); | ||
database.insertEntry(entriesMergeResult.mergedEntry()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right before this line, the setCitationMergeMode
should be called.
// let main table know this is a citation merge | ||
libraryTab.getMainTable().setCitationMerge(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong position - because if I click "cancel" on the merge, the mode is not reset - I show you a better position in the code below.
- fixed wrong position codes: codes that updating citation relation item and setting state of citationMergeMode now be moved into CitationRelationsTab#openPossibleDuplicateEntriesWindow - modified some comments and Java doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The column headings of the merge entries dialog are not self-explanatory
What is "left", what is "right"?`
Proposal:
- Swap left and right - because the left is the new thing flowing into the middle thing and then the output is the merged entry
- Set "Citation" and "Library" as titles for the columns
I hope this is possible with the current base offered by JabRef
I moved the statement libraryTab.getMainTable().setCitationMergeMode(true);
close to insertEntry
, because it is needed right before there. (fbbd5f0)
Other
… more self-explanatory.
Finally approved. Thank you for the fast follow-ups! I hope you will take another issue to improve JabRef even more! |
@koppor Thank you for the approval and your continuous support throughout the process! 🙌 It was a pleasure contributing to JabRef, and I appreciate your helpful guidance along the way. I look forward to tackling more issues and helping improve JabRef even further! 🚀 |
) * - Added a "Compare" button for duplicate entries in the CitationRelationsTab. - Added localization key for 'Compare with duplicate entries'. * - Implemented functionality to open a "Possible duplicate entries" for comparing and merging duplicate entries. - Updated changelog for compare button feature. * Updated changelog * - Updated localization key for compare button tooltip. - Fixed bug that when adding an entry to the library from Citation Relations Tab by adding the entry's clone instead of itself. - Optimised openPossibleDuplicateEntriesWindow function in CitationRelationsTab.java to show result of undo and redo. - Implemented that After clicking "merge", the current entry will be kept selected - and not the merged entry be selected. * Modified CitationsRelationsTabViewModel and ImportHandler to pass CitationsRelationsTabViewModelTest with clone entries. * - Deleted old code in CitationRelationTab.java which to implement that original entry be selected after citation item merge. - Modified MainTable#clearAndSelect to ensure original entry be selected after citation item merge. - Added some comments. * Optimised citation relations item merge: Added a citation merge flag in MainTable.java to let original entry get selected after merge instead of selecting new merged entry. * Optimised MainTable#clearAndSelect: make the code look more concise. * Fixed bug: As original local entry of citation relation item has been changed to new merged entry, need to refresh selected citation relation item to ensure that the item link to current local entry instead of the old one. * Adapted tool tip of compare button. * - renamed some variables to make them more understandable - fixed wrong position codes: codes that updating citation relation item and setting state of citationMergeMode now be moved into CitationRelationsTab#openPossibleDuplicateEntriesWindow - modified some comments and Java doc * Move statement closer to intended use * Modified the column headings of the merge entries dialog to make them more self-explanatory. --------- Co-authored-by: Oliver Kopp <[email protected]>
) * - Added a "Compare" button for duplicate entries in the CitationRelationsTab. - Added localization key for 'Compare with duplicate entries'. * - Implemented functionality to open a "Possible duplicate entries" for comparing and merging duplicate entries. - Updated changelog for compare button feature. * Updated changelog * - Updated localization key for compare button tooltip. - Fixed bug that when adding an entry to the library from Citation Relations Tab by adding the entry's clone instead of itself. - Optimised openPossibleDuplicateEntriesWindow function in CitationRelationsTab.java to show result of undo and redo. - Implemented that After clicking "merge", the current entry will be kept selected - and not the merged entry be selected. * Modified CitationsRelationsTabViewModel and ImportHandler to pass CitationsRelationsTabViewModelTest with clone entries. * - Deleted old code in CitationRelationTab.java which to implement that original entry be selected after citation item merge. - Modified MainTable#clearAndSelect to ensure original entry be selected after citation item merge. - Added some comments. * Optimised citation relations item merge: Added a citation merge flag in MainTable.java to let original entry get selected after merge instead of selecting new merged entry. * Optimised MainTable#clearAndSelect: make the code look more concise. * Fixed bug: As original local entry of citation relation item has been changed to new merged entry, need to refresh selected citation relation item to ensure that the item link to current local entry instead of the old one. * Adapted tool tip of compare button. * - renamed some variables to make them more understandable - fixed wrong position codes: codes that updating citation relation item and setting state of citationMergeMode now be moved into CitationRelationsTab#openPossibleDuplicateEntriesWindow - modified some comments and Java doc * Move statement closer to intended use * Modified the column headings of the merge entries dialog to make them more self-explanatory. --------- Co-authored-by: Oliver Kopp <[email protected]>
) * - Added a "Compare" button for duplicate entries in the CitationRelationsTab. - Added localization key for 'Compare with duplicate entries'. * - Implemented functionality to open a "Possible duplicate entries" for comparing and merging duplicate entries. - Updated changelog for compare button feature. * Updated changelog * - Updated localization key for compare button tooltip. - Fixed bug that when adding an entry to the library from Citation Relations Tab by adding the entry's clone instead of itself. - Optimised openPossibleDuplicateEntriesWindow function in CitationRelationsTab.java to show result of undo and redo. - Implemented that After clicking "merge", the current entry will be kept selected - and not the merged entry be selected. * Modified CitationsRelationsTabViewModel and ImportHandler to pass CitationsRelationsTabViewModelTest with clone entries. * - Deleted old code in CitationRelationTab.java which to implement that original entry be selected after citation item merge. - Modified MainTable#clearAndSelect to ensure original entry be selected after citation item merge. - Added some comments. * Optimised citation relations item merge: Added a citation merge flag in MainTable.java to let original entry get selected after merge instead of selecting new merged entry. * Optimised MainTable#clearAndSelect: make the code look more concise. * Fixed bug: As original local entry of citation relation item has been changed to new merged entry, need to refresh selected citation relation item to ensure that the item link to current local entry instead of the old one. * Adapted tool tip of compare button. * - renamed some variables to make them more understandable - fixed wrong position codes: codes that updating citation relation item and setting state of citationMergeMode now be moved into CitationRelationsTab#openPossibleDuplicateEntriesWindow - modified some comments and Java doc * Move statement closer to intended use * Modified the column headings of the merge entries dialog to make them more self-explanatory. --------- Co-authored-by: Oliver Kopp <[email protected]>
screenshot before:
screenshot after:
screen recording preview:
preview.mov
This PR fixes #11192
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)