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 for issue 9091 - store merge entries toolbar configuration #9712

Merged
merged 23 commits into from
Apr 2, 2023

Conversation

dragos222
Copy link
Contributor

@dragos222 dragos222 commented Mar 28, 2023

Fixes #9091
The Merge Entries toolbar configuration now gets saved once the user hits 'Merge entries' button. More specifically, the plainTextOrDiff combo box, diffView combo box, and highlight words/highlight characters values are being stored using the GuiPreferences, and JabRefPreferences objects respectively. The 'Only show changed fields' check box was already handled, therefore I did not change its implementation.
I have a question regarding the showDiff method from ThreeWayMergeView class: should this method be left the way it is now, or should it get updated so that the user's preferences are loaded when invoking the showDiff method?

image

Compulsory checks

Preview Give feedback

@dragos222 dragos222 changed the title Fix for issue 9091 group3 Fix for issue 9091 Mar 28, 2023
@dragos222 dragos222 changed the title Fix for issue 9091 Fix for issue 9091 - store merge entries toolbar configuration Mar 28, 2023
@HoussemNasri
Copy link
Member

I couldn't assign @ssrpro to the PR, but so you know he is working on this PR with @dragos222 on the same team.

@HoussemNasri
Copy link
Member

should this method be left the way it is now, or should it get updated so that the user's preferences are loaded when invoking the showDiff method?

Stored configuration should be loaded when the UI is created, e.g. at the constructor. Have a look at ThreeWayMergeView#initializeToolbar

@dragos222
Copy link
Contributor Author

Thank you for your feedback. The saveGuiPreferences has been delegated to the ThreeWayMergeView object and the MergeEntriesDialog object does not get access to the toolbar object.
The preferences are indeed loaded when the UI gets created. More specifically, these values are loaded in their according combo box/radio button in ThreeWayMergeToolbar#initialize.

@dragos222 dragos222 marked this pull request as ready for review March 29, 2023 10:05
@@ -185,6 +196,14 @@ public enum PlainTextOrDiff {
this.value = value;
}

public static PlainTextOrDiff parse(String name) {
try {
return PlainTextOrDiff.valueOf(name);
Copy link
Member

Choose a reason for hiding this comment

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

You can use Guava's https://guava.dev/releases/15.0/api/docs/com/google/common/base/Enums.html#getIfPresent(java.lang.Class,%20java.lang.String) here, it's a little improvement as it does not throw an exception

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 29, 2023
Siedlerchr
Siedlerchr previously approved these changes Mar 29, 2023
@Siedlerchr Siedlerchr requested a review from HoussemNasri March 29, 2023 17:09
@@ -176,6 +180,14 @@ public void setOnSelectRightEntryValuesButtonClicked(Runnable onClick) {
selectRightEntryValuesButton.setOnMouseClicked(e -> onClick.run());
}

public void saveGuiPreferences() {
preferencesService.getGuiPreferences().setMergePlainTextOrDiff(plainTextOrDiffComboBox.getValue());
Copy link
Member

Choose a reason for hiding this comment

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

When I created the PlainTextOrDiff enum type, I thought it would be useful because I can embed the "Plain Text" and "Show Diff" texts in there, and display the labels in UI. In preferences, I think a boolean should suffice. Maybe a boolean property named shouldShowDiffs?

Copy link
Member

Choose a reason for hiding this comment

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

This would have the advantage that you can then use bidrectional binding

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented this for both PlainTextOrDiff and DiffView enums.

Copy link
Member

@HoussemNasri HoussemNasri left a comment

Choose a reason for hiding this comment

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

The merge configurations are being saved perfectly in the MergeEntriesDialog, however, in the DuplicateResolverDialog they are not. This is a complication, because the three-way merge UI is being used in multiple dialogs, so it's not obvious when the user is done with the UI and thus when to save the configuration.

I would start by doing the same changes you did to MergeEntriesDialog to the DuplicateResolverDialog, but this time, you want to save the configurations on all actions but the "Cancel" one.

Overall, I think you did a good job implementing this. Once the duplicate resolver dialog is updated, I think we can merge.

@Siedlerchr Siedlerchr added status: changes required Pull requests that are not yet complete and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Mar 31, 2023
@dragos222
Copy link
Contributor Author

The three way merge view toolbar preferences are now saved in DuplicateResolverDialog as well, on all actions but the "Cancel" one. There is a failing test, but it's not related to this PR and I notice that it also fails for other PRs.

HoussemNasri
HoussemNasri previously approved these changes Apr 1, 2023
Copy link
Member

@HoussemNasri HoussemNasri left a comment

Choose a reason for hiding this comment

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

I took the courtesy to adjust some names and restructure the code.

Also, while using the merge dialog, I expected the configuration to be saved even if I clicked "Cancel", so I changed that for both dialogs.

Thanks again for working on this enhancement. It would significantly improve the merging user experience, especially when resolving duplicates.

@Siedlerchr Siedlerchr merged commit 77ea49c into JabRef:main Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preferences status: changes required Pull requests that are not yet complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge entry interface: view options are not saved
4 participants