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

[GSOC22] - A - Implement a fully functional three way merge UI #8945

Merged
merged 107 commits into from
Aug 10, 2022
Merged

[GSOC22] - A - Implement a fully functional three way merge UI #8945

merged 107 commits into from
Aug 10, 2022

Conversation

HoussemNasri
Copy link
Member

@HoussemNasri HoussemNasri commented Jul 2, 2022

Contributes to #6190

Summary

The goal of this pr is to complete the first and second milestones listed in my proposal, which include designing and implementing a 3-way merge UI and replacing the existing merge UI with the new one in components that depend on it, which are:

  • Duplicate resolver dialog
  • External changes resolver dialog
  • Merge entries dialog

Notable Changes

An improved diff highlighting logic and visuals

  • Differences are now highlighted by coloring background rather than text, thanks to RichTextFX.
  • Split view and unified view were introduced as more common terminology for viewing differences.
  • Several bugs and pitfalls in the previous implementation were fixed.

Editable Merged Entry

  • Now you can see and edit the merged entry from the dialog
  • The merged entry, as well as the left and right entries, are completely bound, thus selecting a new entry will update the merged entry text, and modifying the merged entry text will update the selection.

Miscellaneous

  • Extracted the merge toolbar into its own class
  • Added a sticky header that doesn't get hidden when you scroll
  • Support light and dark theme

Notes

RichTextFX is heavy + many are used in the same screen

Although RichTextFX's StyleClassedTextArea makes it very easy to change text's background color, it's heavy and can cause performance issues, so I may need to find an alternative in the future. I don't have any data yet, and I'm not sure whether RichTextFX's performance issues are critical, so I need to do some experiments before deciding whether to keep it or look for an alternative.

PDF Metadata merge dialog #7929

For keeping JabRef consistent, I agreed with my mentors to find a good strategy for converting the PDF metadata merge dialog to the new design while reusing as much of the existing code as possible. But that's for another pr.

Screenshots

Light Theme

Plain Text

image

Unified Diff View - Highlighting Words

image

Split Diff View - Highlighting Words

image

Dark Theme

image

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

- Defined style class
- Defined pseudo class for the selected state
- Created the selection box UI
…s simultaneously.

- Added a style class for field value cell
- A cell is disabled when it's either empty or not visible e.g. when the left cell spans 2 columns, right cell is disabled because it's not visible
- Added comments
- It will be added to the top of the merge dialog
- Renamed ThreeWayMerge.java to ThreeWayMergeView
- At this stage headers aren't updated and merged bib entry is not created
@HoussemNasri HoussemNasri marked this pull request as ready for review July 5, 2022 01:20
- When both the left and right cells have the same value, only the left value is displayed, making it unnecessary to keep allocating memory for the right cell.

import org.fxmisc.richtext.StyleClassedTextArea;

public class FieldRowController {
Copy link
Member

Choose a reason for hiding this comment

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

A controller? Doesn't this conflict with the mvvm pattern we are using?

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea was that a field row would take model data (left and right field values), create the views and bind the model to it. A controller would do exactly that. It cannot be a view-model because it contains a reference to the view, and it cannot be a view because it doesn't inherit the Node class.

Also, JabRef architecture docs state that because FXML is not powerful enough and it can't do all the binding, we need a controller. So a controller does have a place in our architecture. The only new thing that I'm introducing here is the controller keyword, which I plan to remove and I removed while implementing the merging groups feature.

Other than that, I'll appreciate any ideas or hints you have about making the current design better.

Copy link
Member

Choose a reason for hiding this comment

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

I was just wondering about the word.
Yes sometimes we do more in the java view class beyond binding nodes from the parsed fxml to the viewmodel (see https://www.ctan.org/tex-archive/biblio/bibtex/contrib/doc/ ), because fxml is not powerful enough and there are architectural limitations in java/javafx. However, I still see some business logic in the controller, that can be pushed into a viewmodel to be able to test it, like keeping the values of the cells and hasEqualLeftAndRightValues. It would just be great to be able to test the logic of your custom row.
Btw, not using FXML is totally ok with me, because parsing FXML takes time - a lot of time. So I think you already did it right not to introduce an FXML for the row, since parsing 10+ fxml files is wasting too much cpu time.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with Carl, rename this, just call it FieldRow
and create a new class FieldRowViewModel where you put the logic.
You would bind it then e.g fieldNameCell.text().bindBidirectional(viewModel.fieldNameText)

/**
*
*/
public abstract class AbstractCell extends HBox {
Copy link
Member

Choose a reason for hiding this comment

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

MergableCell? AbstractCell sounds somewhat ... abstract ... 😅

Copy link
Member

@calixtus calixtus Jul 11, 2022

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I kind of want to avoid using the merge keyword because there is already a class called MergedFieldCell. However, BandedRowCell sounds good; although I had to put Banded in google translate to understand it :^)

Another option could be ThreeWayMergeCell? Since the ThreeWayMerge prefix is used in other places too.

I could also use JavaFX Cell which already provide odd and even states. In addition, it has selectedProperty() and textProperty(). It is however a control so I need to implement a custom layout.

@ThiloteE ThiloteE added the ui label Jul 15, 2022
…al-three-way-merge

* upstream/main: (39 commits)
  New Crowdin updates (#9016)
  New Crowdin updates (#9013)
  try to gather more output from LO exception (#9002)
  Improve Automatic Field Editor Dialog (#8973)
  Update BST VM to Antlr4 (#8934)
  Support biblatex apa citation for legal entry types (#8966)
  Bump junit-jupiter from 5.8.2 to 5.9.0 (#9012)
  Bump lucene-core from 9.2.0 to 9.3.0 (#9009)
  Bump checkstyle from 10.3.1 to 10.3.2 (#9006)
  Bump appleboy/ssh-action from 0.1.4 to 0.1.5 (#9005)
  New translations JabRef_en.properties (Spanish) (#9003)
  Squashed 'buildres/csl/csl-locales/' changes from 55459cd79f..e637746677
  Squashed 'buildres/csl/csl-styles/' changes from 3d3573c..c750b6e
  Autosave folder and checkbox is remembered (#9000)
  New Crowdin updates (#8999)
  Sync group view mode and main table (#8993)
  Bump unoloader from 7.3.4 to 7.3.5 (#8996)
  Bump libreoffice from 7.3.4 to 7.3.5 (#8997)
  Bump java-diff-utils from 4.11 to 4.12 (#8998)
  Fix external group metadata changes are not merged (#8994)
  ...
@calixtus calixtus changed the title [WIP][GSOC22] Implement a fully functional three way merge UI [GSOC22] - A - Implement a fully functional three way merge UI Aug 3, 2022
}

public boolean hasEqualLeftAndRightValues() {
return isRightValueCellHidden() || (!StringUtil.isNullOrEmpty(leftValueCell.getText()) &&
Copy link
Member

Choose a reason for hiding this comment

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

This should be moved to a separate viewModel

Copy link
Member Author

Choose a reason for hiding this comment

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

It is moved in pr B

@HoussemNasri HoussemNasri added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 6, 2022
@Siedlerchr Siedlerchr merged commit a90b868 into JabRef:main Aug 10, 2022
Siedlerchr added a commit to koppor/jabref that referenced this pull request Aug 14, 2022
* upstream/main: (31 commits)
  Citavi Importer - Import all knowledge items (JabRef#9043)
  Fixed table update in eft preferences (JabRef#9051)
  Keep EOL setting at backups (JabRef#9048)
  ExternalFileTypes singleton refactor (JabRef#9044)
  Fix dead link (JabRef#9047)
  Fix performance regresssion (JabRef#9045)
  Update javafx to 18.02
  import citavi knowledge items (JabRef#9033)
  Fix .gitattributes for CHANGELOG.md
  [GSOC22] - B - Implement merging fields in the three way merge UI (JabRef#9022)
  [GSOC22] - A - Implement a fully functional three way merge UI (JabRef#8945)
  Change button label from "Return to JabRef" to "Return to library" (JabRef#9039)
  Bump postgresql from 42.4.0 to 42.4.1 (JabRef#9036)
  Bump org.javamodularity.moduleplugin from 1.8.11 to 1.8.12 (JabRef#9037)
  Bump slf4j-api from 2.0.0-alpha7 to 2.0.0-beta1 (JabRef#9035)
  Bump slf4j-api from 2.0.0-alpha7 to 2.0.0-beta1 in /buildSrc (JabRef#9038)
  Update Gradle Wrapper from 7.5 to 7.5.1. (JabRef#9034)
  Refactor of DOI import failure dialog, import format reader and clipboard manager (JabRef#8839)
  Snapcraft and issue template
  Show development information\n\n+semver: minor
  ...
@wujastyk
Copy link

wujastyk commented Nov 1, 2022

This is a wonderful feature. I use it often, now. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicateFinder project: GSoC status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants