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] - B - Implement merging fields in the three way merge UI #9022

Merged
merged 437 commits into from
Aug 10, 2022

Conversation

HoussemNasri
Copy link
Member

@HoussemNasri HoussemNasri commented Aug 3, 2022

Closes #8024
Depends on #8945
Contributes to #6190

It appears that every time a field changes, an event bus marks the library as edited. The library will remain marked as edited even after I undo groups merging and cancel the merge dialog. Right now, I can't think of a way to fix this.

Edit
Keywords and Comments can be merged too.

bandicam.2022-07-09.04-40-39-815.mp4
  • 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.

- Thus commands can be moved to the view model
- Removed FieldNameCellFactory.java and MergeableFieldCell.java
- Made it easier to add more side buttons in the future
- Initialized the change name column
- Commented out 'getDialogPane().setContent(pane)' because it will be removed later
- Changes are applied only when all changes are resolved (changes table is empty). Like a transaction
}
}

class ActionImpl implements Action {
Copy link
Member

@Siedlerchr Siedlerchr Aug 4, 2022

Choose a reason for hiding this comment

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

Why don't you use the JabRefAction together with the ActionFactory ? It should already cover the cases

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'm not sure how that would work. The idea behind the builder and ActionImpl is to create instances of org.jabref.gui.actions.Action without implementing it; which can be very verbose.

Copy link
Member

Choose a reason for hiding this comment

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

Well, you could either use them as anonymous classes or as separate classes. The latter is probably useful if you are reusing them in multiple placess.

}

public FieldMerger create(Field field) {
if (field.equals(StandardField.GROUPS)) {
Copy link
Member

Choose a reason for hiding this comment

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

Use a switch here?

Copy link
Member

Choose a reason for hiding this comment

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

And also some parts use == other use equal

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 couldn't use a switch expression because Field is an interface. When I changed the type of the parameter to StandardField, it compiled fine but other parts of the codebase broke.

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay, yeah I see. Then field is the correct approach

} else if (StringUtil.isBlank(keywordsB)) {
return keywordsA;
} else {
return Arrays.stream((keywordsA + keywordSeparator + keywordsB).split(keywordSeparator))
Copy link
Member

Choose a reason for hiding this comment

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

Not sure, but maybe you should use KeywordList ? This is relevant for keyword groups


public class UnmergeCommand extends SimpleCommand {

public UnmergeCommand() {
Copy link
Member

Choose a reason for hiding this comment

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

empty default constructor can be removed

public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, String leftHeader, String rightHeader) {
getStylesheets().add(ThreeWayMergeView.class.getResource("ThreeWayMergeView.css").toExternalForm());
viewModel = new ThreeWayMergeViewModel((BibEntry) leftEntry.clone(), (BibEntry) rightEntry.clone(), leftHeader, rightHeader);
// TODO: Inject 'preferenceService' into the constructor
Copy link
Member

@Siedlerchr Siedlerchr Aug 4, 2022

Choose a reason for hiding this comment

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

You can test if you can inject it as field here or in the caller component and pass it to this component in the constructor
@Inject private PreferencesService preferencesService

Copy link
Member Author

@HoussemNasri HoussemNasri Aug 5, 2022

Choose a reason for hiding this comment

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

It throws a null pointer exception. I think this is happening because the injection is handled by mvvmfx but ThreeWayMergeView doesn't use a view loader. I thought that because @Inject is used in other classes and all of them also use view loader.

Copy link
Member

Choose a reason for hiding this comment

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

You need to inject it into DuplicateResolverDialog

Copy link
Member

Choose a reason for hiding this comment

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

And also pass it from the ChangeScanner -> EntryChangeViewModel -> ThreeWayMergeView via constructor

@@ -39,7 +39,7 @@ public enum DuplicateResolverResult {
BREAK
}

private MergeEntries mergeEntries;
private ThreeWayMergeView threeWayMerge;
private final DialogService dialogService;

Copy link
Member

@Siedlerchr Siedlerchr Aug 4, 2022

Choose a reason for hiding this comment

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

Here you can use things with @Inject e.g @Inject PreferencesService preferencesService; and pass that to other

Copy link
Member Author

Choose a reason for hiding this comment

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

Injection doesn't work here either

Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

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

overall looks good to me just a few minor improvements

@Siedlerchr
Copy link
Member

We are thinking of merging this so the early bird users can the new feature, Can PR A and B be merged?

@HoussemNasri
Copy link
Member Author

PR A is complete. This one still needs some nitpicks, but it should be ready today or tomorrow.

@HoussemNasri HoussemNasri added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 6, 2022
# Conflicts:
#	src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java
#	src/main/java/org/jabref/gui/icon/IconTheme.java
#	src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java
#	src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.css
#	src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java
#	src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/FieldNameCell.java
#	src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/FieldValueCell.java
#	src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/HeaderCell.java
#	src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/MergedFieldCell.java
#	src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/OpenExternalLinkAction.java
#	src/main/resources/l10n/JabRef_en.properties
@Siedlerchr Siedlerchr merged commit dcec4e2 into main Aug 10, 2022
@Siedlerchr Siedlerchr deleted the GSOC-merge-fields branch August 10, 2022 19:10
Siedlerchr added a commit to JabRef/jabref-koppor 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
  ...
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.

Merging Entries does not allow to keep groups of all duplicated entries
3 participants