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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
437 commits
Select commit Hold shift + click to select a range
f6a281a
Encode the resulting string from merging files
HoussemNasri Jul 25, 2022
470bc8b
Refactor merge/unmerge fields command handling
HoussemNasri Jul 25, 2022
7354264
Declare Actions with the builder design pattern
HoussemNasri Jul 25, 2022
c9b6db7
Remove MergeableFieldCell dependency from the merge/unmerge commands
HoussemNasri Jul 25, 2022
dab2813
Add logs
HoussemNasri Jul 25, 2022
705e8cc
Disable field's merge button when field values are equal
HoussemNasri Jul 25, 2022
0e9a784
Update code documentation
HoussemNasri Jul 25, 2022
2a512c5
Rename 'AbstractCell' to 'ThreeWayMergeCell'
HoussemNasri Jul 25, 2022
8081bc5
Pass arguments to Localization.lang using '%0' not '%'
HoussemNasri Jul 27, 2022
235a243
Decompose the ToggleMergeUnmergeButton into its own class (or component)
HoussemNasri Jul 27, 2022
891feb6
Include original left and right entries in EntriesMergeResult
HoussemNasri Aug 2, 2022
feb0628
Make entries merging logic reusable
HoussemNasri Aug 2, 2022
328ce97
Rename ChangeDisplayDialog.java to ExternalChangesResolverDialog.java
HoussemNasri Aug 2, 2022
b8ce549
Create ExternalChangesResolverViewModel
HoussemNasri Aug 2, 2022
588db57
Design the ExternalChangesResolverDialog
HoussemNasri Aug 2, 2022
0af8175
Implement a method for opening an advanced merge dialog for modified …
HoussemNasri Aug 2, 2022
0e128d2
Wrap the UI in a dialog pane
HoussemNasri Aug 2, 2022
0f1366a
Convert change name to a StringProperty instead of a raw string
HoussemNasri Aug 2, 2022
241ae86
Populate table view with changes
HoussemNasri Aug 2, 2022
b3ddc88
Remove 'Accept changes' and 'Dismiss' buttons from the dialog
HoussemNasri Aug 2, 2022
6bf045b
Allow selecting multiple changes
HoussemNasri Aug 2, 2022
0be74a6
Rename 'Accept Theirs' to 'Accept' and 'Accept Yours' to 'Deny'
HoussemNasri Aug 2, 2022
5cd88eb
Apply changes when before the dialog
HoussemNasri Aug 2, 2022
fe4b582
Cleanup FXML
HoussemNasri Aug 2, 2022
fc656d9
Remove old UI code
HoussemNasri Aug 2, 2022
12ec6c5
Close dialog when all changes are resolved
HoussemNasri Aug 2, 2022
f9292de
Enable the 'Merge...' button only if the selected change has an advan…
HoussemNasri Aug 3, 2022
dd46057
Select the first change after opening the dialog
HoussemNasri Aug 3, 2022
57062ce
Open the advanced merge dialog when 'Merge...' is clicked
HoussemNasri Aug 3, 2022
d90c418
Don't open the advanced merge dialog when 'makeChange()' is called on…
HoussemNasri Aug 3, 2022
ea33534
Display a preview of the deleted entry
HoussemNasri Aug 3, 2022
c4274a9
Display information about the selected change in the bottom detail node
HoussemNasri Aug 3, 2022
f0d8cb3
Merge branch 'JabRef:main' into GSOC-merge-groups
HoussemNasri Aug 3, 2022
ca627bc
Merge branch 'GSOC-merge-groups' into GSOC-improve-collab-dialog
HoussemNasri Aug 3, 2022
5b8e97a
Merge remote-tracking branch 'origin/main' into GSOC-merge-fields
HoussemNasri Aug 3, 2022
3ad3a83
Merge remote-tracking branch 'upstream/main' into GSOC-improve-collab…
Siedlerchr Aug 3, 2022
8ecf890
Update README.md
HoussemNasri Mar 24, 2022
ee988f9
Fix Readme
HoussemNasri Jun 7, 2022
0b9a345
Create grid cells for rendering field name and field value
HoussemNasri Jul 2, 2022
93a17c6
Implement FieldNameCell and define style class
HoussemNasri Jul 2, 2022
2d2c1ff
Make FieldValueCell selectable
HoussemNasri Jul 2, 2022
5329e29
Implement MergedFieldCell for rendering editable merged field value
HoussemNasri Jul 2, 2022
f184ed2
Change MergedFieldCell text based on the selected FieldValueCell
HoussemNasri Jul 2, 2022
111a211
Style MergedFieldCell
HoussemNasri Jul 2, 2022
e30db74
Rename ThreeWayMerge css stylesheet
HoussemNasri Jul 2, 2022
1c7e012
Create HeadView for rendering left, right and merged entry headers
HoussemNasri Jul 2, 2022
249bec9
Fix typo
HoussemNasri Jul 2, 2022
c12a352
Fix a bug that causes the selection of both left and right field cell…
HoussemNasri Jul 2, 2022
fa86607
Prevent the selection of FieldValueCell when it's disabled
HoussemNasri Jul 2, 2022
e8fef63
Display a copy icon inside FieldValueCell
HoussemNasri Jul 2, 2022
70180f2
Disable left or right FieldValueCell when it's empty
HoussemNasri Jul 2, 2022
d90fcf2
Update Base CSS style
HoussemNasri Jul 2, 2022
a3091c6
Design and implement the merge toolbox
HoussemNasri Jul 2, 2022
e9a410e
Implement the initial prototype of the new merge UI
HoussemNasri Jul 2, 2022
180493d
Use ThreeWayMergeView in MergeEntriesDialog
HoussemNasri Jul 2, 2022
f80aa41
Fix ThreeWayMergeView.css stylesheet not being imported
HoussemNasri Jul 2, 2022
819ac4e
Span left field value to 2 columns when left and right field values a…
HoussemNasri Jul 2, 2022
7f4cd2f
Wrap the copy icon inside a button
HoussemNasri Jul 2, 2022
823125c
Use HAND cursor when hover over FieldValueCell
HoussemNasri Jul 2, 2022
ca5d4f3
Move field cells styles to ThreeWayMergeView.css
HoussemNasri Jul 2, 2022
ec78eec
Update merge toolbox FXML UI
HoussemNasri Jul 2, 2022
5c093e0
Implement and style HeaderCell
HoussemNasri Jul 2, 2022
9d6a921
Take row index as an argument in AbstractCell
HoussemNasri Jul 2, 2022
db5f3a0
Color cell background based on its row position (odd or even)
HoussemNasri Jul 2, 2022
0918e79
Bind textArea.textProperty() and textProperty() using BindingsHelper
HoussemNasri Jul 2, 2022
32ad571
Copy field value to Clipboard user clicks on the copy button
HoussemNasri Jul 2, 2022
7ed7250
Implement a more complete HeaderView
HoussemNasri Jul 2, 2022
0197257
Pass left and right headers to HeaderView
HoussemNasri Jul 2, 2022
95ea40f
Create merged entry
HoussemNasri Jul 2, 2022
8becfc1
Add the entry type field at the top of the fields list
HoussemNasri Jul 2, 2022
6042d69
Display entry type and bind merged entry
HoussemNasri Jul 2, 2022
390762b
Minor changes
HoussemNasri Jul 2, 2022
91dd860
Style CSS
HoussemNasri Jul 2, 2022
32a9ffb
Update ThreeWayMergeToolbox.fxml
HoussemNasri Jul 2, 2022
0a5fb15
Remove MergeEntries from MergeEntriesDialog
HoussemNasri Jul 2, 2022
4267cf6
Create EmptyCell for optimization
HoussemNasri Jul 2, 2022
ef3271c
Update HeaderCell
HoussemNasri Jul 2, 2022
cac4f11
Rename HeaderView to ThreeWayMergeHeaderView
HoussemNasri Jul 2, 2022
0f3e154
Add buttons to accept all left or right entry changes to ThreeWayMerg…
HoussemNasri Jul 2, 2022
91b9cd9
Disable right field cell when it's not visible
HoussemNasri Jul 2, 2022
d6a7a82
Listen for select all left/right toolbar buttons
HoussemNasri Jul 2, 2022
5a37259
Style stuff
HoussemNasri Jul 2, 2022
3a2f7c4
Add DiffHighlighter
HoussemNasri Jul 2, 2022
48f46c9
Create DiffHighlighter.css
HoussemNasri Jul 2, 2022
6f8d19a
Add left padding to HeaderCell
HoussemNasri Jul 2, 2022
d7f91c3
Move diff highlighting styles to Dark.css
HoussemNasri Jul 2, 2022
4716f4b
Show differences between left and right values using a unified diff view
HoussemNasri Jul 2, 2022
e7817eb
Change MergeEntriesDialog stage style
HoussemNasri Jul 2, 2022
a1f7ac1
Remove BackgroundTone from AbstractCell
HoussemNasri Jul 2, 2022
17787f9
Move CopyFieldValueCommand
HoussemNasri Jul 2, 2022
46fd34e
Make DiffMethod public
HoussemNasri Jul 2, 2022
980a85e
Move CopyFieldValueCommand
HoussemNasri Jul 2, 2022
2ef153b
Implement SplitDiffHighlighter
HoussemNasri Jul 2, 2022
ea56047
Show diffs when user selects "Show Diff" in the toolbar UI
HoussemNasri Jul 2, 2022
8a5b534
Fix bugs in UnifiedDiffHighlighter
HoussemNasri Jul 2, 2022
1a25db6
Style css stuff
HoussemNasri Jul 2, 2022
0cf68c7
Fix typos
HoussemNasri Jul 2, 2022
2142192
Refactor SplitDiffHighlighter and fix bugs
HoussemNasri Jul 2, 2022
868f314
Remove redundant constructor from UnifiedDiffHighlighter
HoussemNasri Jul 2, 2022
a1fb604
Allow users to switch between split and unified diff view
HoussemNasri Jul 2, 2022
6043305
Set left and right headers in MergeEntriesDialog
HoussemNasri Jul 2, 2022
d8d2246
Refactor ThreeWayMergeHeaderView
HoussemNasri Jul 2, 2022
e27d8f9
Remove wellbehavedfx module dependency
HoussemNasri Jun 28, 2022
4891fdc
Delete EmptyCell.java
HoussemNasri Jul 2, 2022
3f57163
Refactor FieldValueCell
HoussemNasri Jul 2, 2022
fb3509e
Use the new merge UI in DuplicateResolverDialog
HoussemNasri Jul 2, 2022
6bb8f2c
Expose an API to change diff view and highlight method from outside t…
HoussemNasri Jul 2, 2022
a9f3254
Use the new merge UI when an entry is changed from external
HoussemNasri Jul 2, 2022
30b4f74
Minor styling
HoussemNasri Jun 29, 2022
7022b74
Remove DiffHighlighter.css stylesheet
HoussemNasri Jul 2, 2022
6fee209
Remove unused dependencies
HoussemNasri Jul 2, 2022
23223de
Allow selecting empty field values
HoussemNasri Jul 2, 2022
f9c4a18
Fix readme :(
HoussemNasri Jul 2, 2022
a5bc689
Use a theme color for selection box background
HoussemNasri Jul 2, 2022
4bd99c2
Refactor FieldValueCell
HoussemNasri Jul 3, 2022
e2d4f76
Add an action to FieldValueCell for opening Urls
HoussemNasri Jul 3, 2022
b8a3575
Add the ability to open DOI identifier
HoussemNasri Jul 3, 2022
28fbefb
Cleanup
HoussemNasri Jul 3, 2022
a471e20
Checkstyle
HoussemNasri Jul 3, 2022
03ee8c0
Improve URL validation logic
HoussemNasri Jul 4, 2022
06df19e
Use DiffMethod in merge toolbar for consistency
HoussemNasri Jul 4, 2022
ddee09c
i18n
Siedlerchr Aug 3, 2022
f69c76c
Cleanup css
HoussemNasri Jul 4, 2022
4f6d227
Remove redundant icon style
HoussemNasri Jul 4, 2022
baeb1dc
Rename style class field-value to merge-field-value
HoussemNasri Jul 4, 2022
9905fe0
Remove old Merge entries UI
HoussemNasri Jul 4, 2022
c37fbd3
Fix missing header styles
HoussemNasri Jul 4, 2022
7dcc348
i18n
Siedlerchr Aug 3, 2022
0434687
Garbage collect right cell when it's invisible
HoussemNasri Jul 6, 2022
a4049ba
Fix typo
HoussemNasri Jul 6, 2022
516ca2f
Create GroupsFieldNameCell
HoussemNasri Jul 9, 2022
c4ff603
Create MergedGroups to record the state of the groups before and afte…
HoussemNasri Jul 9, 2022
8bd1ccb
Create a factory class for creating field name cells
HoussemNasri Jul 9, 2022
6ace504
Perform experiments for implementing groups merging
HoussemNasri Jul 9, 2022
6187c26
Delegate field name cells creation to ThreeWayMergeView
HoussemNasri Jul 9, 2022
8580d35
Improve groups merging function
HoussemNasri Jul 9, 2022
5703cd4
Implement updateFieldValues to redraw the field row when left or righ…
HoussemNasri Jul 9, 2022
4043a6d
Write a draft version of the logic to merge groups
HoussemNasri Jul 9, 2022
9c152c6
Refactoring
HoussemNasri Jul 8, 2022
4bf7b2e
More Refactoring
HoussemNasri Jul 8, 2022
4dceb2e
Merge groups only when left and right entries have different groups
HoussemNasri Jul 8, 2022
8cf5bc4
Add row constraints to fix UI lagging when updating field values
HoussemNasri Jul 8, 2022
ffe4f04
Minor refactoring
HoussemNasri Jul 8, 2022
c7edbe3
Don't merge common groups between left and right entries
HoussemNasri Jul 8, 2022
2f59a69
Refactor GroupsFieldNameCell constructor
HoussemNasri Jul 8, 2022
5ba051b
Allow groups field row to grow in height
HoussemNasri Jul 8, 2022
fcc0667
Fix select all left/right not working properly
HoussemNasri Jul 8, 2022
99dd862
Update diff when a field value changes
HoussemNasri Jul 8, 2022
754d20f
Add the merge icon and style css
HoussemNasri Jul 8, 2022
9561db2
Extract merge and unmerge commands into their own classes
HoussemNasri Jul 8, 2022
b161536
Refactoring
HoussemNasri Jul 9, 2022
1519bb1
Record groups merging operation using CompoundEdit
HoussemNasri Jul 9, 2022
228f56e
Cancel groups merge when user choose 'Cancel' in the merge entries di…
HoussemNasri Jul 9, 2022
a9d7a7f
Make FieldNameCell take only one action
HoussemNasri Jul 9, 2022
2bf5f66
Set groups merge action to MERGE by default
HoussemNasri Jul 9, 2022
7e25fe5
Fix Unmerge button always disabled
HoussemNasri Jul 9, 2022
1af0bc4
Cleanup
HoussemNasri Jul 9, 2022
43f8aca
Almost f**** everything up. I deleted GroupsFieldNameCell content by …
HoussemNasri Jul 9, 2022
9faebb6
Checkstyle
HoussemNasri Jul 9, 2022
650fddf
Remove unused MergedGroups class
HoussemNasri Jul 10, 2022
1a599f5
Register groups merge edit into UndoManager
HoussemNasri Jul 10, 2022
fde0bb7
Cancel merge groups edit in the DuplicateResolverDialog when user cho…
HoussemNasri Jul 10, 2022
008e7ea
i18n
Siedlerchr Aug 3, 2022
5bf4ad9
Introduce ThreeFieldValuesViewModel
HoussemNasri Jul 16, 2022
73ddbc8
Merge clones of left & right entry rather than the original ones
HoussemNasri Jul 16, 2022
d05373b
Optimize imports
HoussemNasri Jul 16, 2022
6522f94
Refactor DuplicateResolverDialog to merge clones of left and right entry
HoussemNasri Jul 16, 2022
b7ab235
Select the other entry groups when one entry has no group
HoussemNasri Jul 16, 2022
4212cc7
Remove unused property
HoussemNasri Jul 17, 2022
c8d47b4
[WIP] Convert ThreeFieldValues to MVVM
HoussemNasri Jul 17, 2022
884aa53
Move business logic to the view-model and update UI via binding
HoussemNasri Jul 18, 2022
ae6babd
Consider equal left and right fields as merged
HoussemNasri Jul 18, 2022
f0c1f1c
Move initial selection code to the view model
HoussemNasri Jul 18, 2022
ae99ef4
Refactor
HoussemNasri Jul 18, 2022
e16ae47
Hide rightValueCell and extend leftValueCell to 2 columns when fields…
HoussemNasri Jul 18, 2022
737045a
Prepare for adding the ability to merge fields other than groups
HoussemNasri Jul 18, 2022
acf63ee
Rename ThreeFieldValues to ThreeFieldValuesView
HoussemNasri Jul 18, 2022
1dfe8a4
Delegate FieldNameCell creation to ThreeFieldValuesView
HoussemNasri Jul 18, 2022
0210d71
Pass Bib entries to ThreeFieldValuesView rather than raw string
HoussemNasri Jul 18, 2022
6a768eb
Move merge/unmerge commands to ThreeFieldValuesView
HoussemNasri Jul 18, 2022
e48bcbe
Bind field value cell text property
HoussemNasri Jul 18, 2022
12e6f40
Create an undoable edit for undoing fields merging
HoussemNasri Jul 18, 2022
75260de
Update bib entries when left and right field value properties change
HoussemNasri Jul 18, 2022
f3efc40
Update left and right field value properties when merging fields rath…
HoussemNasri Jul 18, 2022
6d3e7cd
Unbind MergedFieldValue property because it can't be edited when bound
HoussemNasri Jul 18, 2022
184cd1a
Cleanup
HoussemNasri Jul 18, 2022
874952e
Move merged entry update logic to ThreeFieldValuesViewModel
HoussemNasri Jul 18, 2022
3541cd5
Implement algorithms for merging groups and keywords
HoussemNasri Jul 19, 2022
075da2b
Pass FieldMergerFactory to ThreeFieldValuesView
HoussemNasri Jul 19, 2022
b2ddc8a
Move isMergeableField method to FieldMergerFactory
HoussemNasri Jul 19, 2022
fb40879
Delete cancelGroupsEdit()
HoussemNasri Jul 19, 2022
2c7339a
Fix KeywordMerger implementation
HoussemNasri Jul 19, 2022
11fb4f1
Fix a bug that deselects both fields after they are unmerged
HoussemNasri Jul 19, 2022
ef212c0
Rename 'ThreeFieldValues' to 'FieldRow'
HoussemNasri Jul 19, 2022
3752f16
Cleanup
HoussemNasri Jul 19, 2022
0a8f9d7
Hide diffs when both values are equal
HoussemNasri Jul 19, 2022
6eea335
Fix typos
HoussemNasri Jul 20, 2022
e1667d9
Select LEFT value after merging fields
HoussemNasri Jul 20, 2022
383dd76
Logging
HoussemNasri Jul 20, 2022
2f58d9b
Implement merging comments
HoussemNasri Jul 20, 2022
4aaabf0
Improve groups and keywords merger implementation
HoussemNasri Jul 20, 2022
ecf1eeb
Change merge/unmerge buttons tooltip text based on the field to merge
HoussemNasri Jul 22, 2022
b1e2951
Implement file merging
HoussemNasri Jul 25, 2022
dd8457c
Encode the resulting string from merging files
HoussemNasri Jul 25, 2022
8c3a1e0
Refactor merge/unmerge fields command handling
HoussemNasri Jul 25, 2022
15f3de3
Declare Actions with the builder design pattern
HoussemNasri Jul 25, 2022
eb8429c
Remove MergeableFieldCell dependency from the merge/unmerge commands
HoussemNasri Jul 25, 2022
09b6073
Add logs
HoussemNasri Jul 25, 2022
2ef9a52
Disable field's merge button when field values are equal
HoussemNasri Jul 25, 2022
c3c76cb
Update code documentation
HoussemNasri Jul 25, 2022
4829168
Rename 'AbstractCell' to 'ThreeWayMergeCell'
HoussemNasri Jul 25, 2022
fa3927d
Pass arguments to Localization.lang using '%0' not '%'
HoussemNasri Jul 27, 2022
d707561
Decompose the ToggleMergeUnmergeButton into its own class (or component)
HoussemNasri Jul 27, 2022
94626dc
Include original left and right entries in EntriesMergeResult
HoussemNasri Aug 2, 2022
dc9293d
Make entries merging logic reusable
HoussemNasri Aug 2, 2022
a984a97
Rename ChangeDisplayDialog.java to ExternalChangesResolverDialog.java
HoussemNasri Aug 2, 2022
fce5ff9
Create ExternalChangesResolverViewModel
HoussemNasri Aug 2, 2022
b9d7bc1
Design the ExternalChangesResolverDialog
HoussemNasri Aug 2, 2022
3811561
Implement a method for opening an advanced merge dialog for modified …
HoussemNasri Aug 2, 2022
00722e1
Wrap the UI in a dialog pane
HoussemNasri Aug 2, 2022
ba86932
Convert change name to a StringProperty instead of a raw string
HoussemNasri Aug 2, 2022
1f908f6
Populate table view with changes
HoussemNasri Aug 2, 2022
71c2144
Remove 'Accept changes' and 'Dismiss' buttons from the dialog
HoussemNasri Aug 2, 2022
97a5f1d
Allow selecting multiple changes
HoussemNasri Aug 2, 2022
bad443b
Rename 'Accept Theirs' to 'Accept' and 'Accept Yours' to 'Deny'
HoussemNasri Aug 2, 2022
3b31d58
Apply changes when before the dialog
HoussemNasri Aug 2, 2022
54daebb
Cleanup FXML
HoussemNasri Aug 2, 2022
3e9cd28
Remove old UI code
HoussemNasri Aug 2, 2022
c5599b7
Close dialog when all changes are resolved
HoussemNasri Aug 2, 2022
16bb186
Enable the 'Merge...' button only if the selected change has an advan…
HoussemNasri Aug 3, 2022
263aa60
Select the first change after opening the dialog
HoussemNasri Aug 3, 2022
f0fbd87
Open the advanced merge dialog when 'Merge...' is clicked
HoussemNasri Aug 3, 2022
0d33e57
Don't open the advanced merge dialog when 'makeChange()' is called on…
HoussemNasri Aug 3, 2022
358b235
Display a preview of the deleted entry
HoussemNasri Aug 3, 2022
76f8849
Display information about the selected change in the bottom detail node
HoussemNasri Aug 3, 2022
698b801
Merge branch 'GSOC-improve-collab-dialog' of github.com:JabRef/jabref…
Siedlerchr Aug 3, 2022
681edea
Merge remote-tracking branch 'upstream/main' into GSOC-merge-fields
Siedlerchr Aug 3, 2022
20c181c
Merge remote-tracking branch 'upstream/main' into GSOC-fully-function…
Siedlerchr Aug 3, 2022
6178ccb
Merge remote-tracking branch 'upstream/GSOC-improve-collab-dialog' in…
Siedlerchr Aug 3, 2022
0a62304
Revert "[WIP] [GSOC22] Improve the external changes resolver dialog" …
Siedlerchr Aug 3, 2022
d43c3f9
Merge branch 'GSOC-fully-functional-three-way-merge' into GSOC-merge-…
HoussemNasri Aug 3, 2022
ec992a2
Use '==' to compare enums
HoussemNasri Aug 5, 2022
bd7a01c
Merge branch 'GSOC-merge-fields' of https://github.com/JabRef/jabref …
HoussemNasri Aug 5, 2022
11d87a6
Move keyword merging logic to KeywordList class
HoussemNasri Aug 6, 2022
331725a
Remove default constructor
HoussemNasri Aug 6, 2022
5e7a474
Compare keywords equality without considering order
HoussemNasri Aug 6, 2022
4224dab
Test KeywordList#merge
HoussemNasri Aug 6, 2022
a4d9d22
Merge remote-tracking branch 'upstream/main' into GSOC-merge-fields
HoussemNasri Aug 10, 2022
ad14469
Fix I10n
HoussemNasri Aug 10, 2022
d381e9e
Fix I10n
HoussemNasri Aug 10, 2022
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
68 changes: 68 additions & 0 deletions src/main/java/org/jabref/gui/actions/Action.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jabref.gui.actions;

import java.util.Objects;
import java.util.Optional;

import org.jabref.gui.icon.JabRefIcon;
Expand All @@ -19,4 +20,71 @@ default Optional<KeyBinding> getKeyBinding() {
default String getDescription() {
return "";
}

class Builder {
private final ActionImpl actionImpl;

public Builder(String text) {
this.actionImpl = new ActionImpl();
setText(text);
}

public Builder() {
this("");
}

public Action setIcon(JabRefIcon icon) {
Objects.requireNonNull(icon);
actionImpl.icon = icon;
return actionImpl;
}

public Action setText(String text) {
Objects.requireNonNull(text);
actionImpl.text = text;
return actionImpl;
}

public Action setKeyBinding(KeyBinding keyBinding) {
Objects.requireNonNull(keyBinding);
actionImpl.keyBinding = keyBinding;
return actionImpl;
}

public Action setDescription(String description) {
Objects.requireNonNull(description);
actionImpl.description = description;
return actionImpl;
}
}

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.

private JabRefIcon icon;
private KeyBinding keyBinding;
private String text;
private String description;

private ActionImpl() {
}

@Override
public Optional<JabRefIcon> getIcon() {
return Optional.ofNullable(icon);
}

@Override
public Optional<KeyBinding> getKeyBinding() {
return Optional.ofNullable(keyBinding);
}

@Override
public String getText() {
return text != null ? text : "";
}

@Override
public String getDescription() {
return description != null ? description : "";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,12 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) {
public BibEntry getMergedEntry() {
return threeWayMerge.getMergedEntry();
}

public BibEntry getNewLeftEntry() {
return threeWayMerge.getLeftEntry();
}

public BibEntry getNewRightEntry() {
return threeWayMerge.getRightEntry();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,21 @@ private void askResolveStrategy(DuplicateSearchResult result, BibEntry first, Bi
if ((resolverResult == DuplicateResolverResult.KEEP_LEFT)
|| (resolverResult == DuplicateResolverResult.AUTOREMOVE_EXACT)) {
result.remove(second);
result.replace(first, dialog.getNewLeftEntry());
if (resolverResult == DuplicateResolverResult.AUTOREMOVE_EXACT) {
autoRemoveExactDuplicates.set(true); // Remember choice
}
} else if (resolverResult == DuplicateResolverResult.KEEP_RIGHT) {
result.remove(first);
result.replace(second, dialog.getNewRightEntry());
} else if (resolverResult == DuplicateResolverResult.BREAK) {
libraryAnalyzed.set(true);
duplicates.clear();
} else if (resolverResult == DuplicateResolverResult.KEEP_MERGE) {
result.replace(first, second, dialog.getMergedEntry());
} else if (resolverResult == DuplicateResolverResult.KEEP_BOTH) {
result.replace(first, dialog.getNewLeftEntry());
result.replace(second, dialog.getNewRightEntry());
}
}

Expand Down Expand Up @@ -225,6 +230,11 @@ public synchronized void replace(BibEntry first, BibEntry second, BibEntry repla
duplicates++;
}

public synchronized void replace(BibEntry entry, BibEntry replacement) {
remove(entry);
getToAdd().add(replacement);
}

public synchronized boolean isToRemove(BibEntry entry) {
return toRemove.containsKey(System.identityHashCode(entry));
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/icon/IconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ public enum JabRefIcons implements JabRefIcon {

ACCEPT_LEFT(MaterialDesignS.SUBDIRECTORY_ARROW_LEFT),

ACCEPT_RIGHT(MaterialDesignS.SUBDIRECTORY_ARROW_RIGHT);
ACCEPT_RIGHT(MaterialDesignS.SUBDIRECTORY_ARROW_RIGHT),

MERGE_GROUPS(MaterialDesignS.SOURCE_MERGE);

private final JabRefIcon icon;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void showMergeDialog(BibEntry originalEntry, BibEntry fetchedEntry, WebF
dialog.setTitle(Localization.lang("Merge entry with %0 information", fetcher.getName()));
dialog.setLeftHeaderText(Localization.lang("Original entry"));
dialog.setRightHeaderText(Localization.lang("Entry from %0", fetcher.getName()));
Optional<BibEntry> mergedEntry = dialogService.showCustomDialogAndWait(dialog);
Optional<BibEntry> mergedEntry = dialogService.showCustomDialogAndWait(dialog).map(MergeResult::mergedEntry);
if (mergedEntry.isPresent()) {
NamedCompound ce = new NamedCompound(Localization.lang("Merge entry with %0 information", fetcher.getName()));

Expand Down
22 changes: 9 additions & 13 deletions src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,24 @@ public void execute() {
second = one;
}

MergeEntriesDialog dlg = new MergeEntriesDialog(first, second);
dlg.setTitle(Localization.lang("Merge entries"));
Optional<BibEntry> mergedEntry = dialogService.showCustomDialogAndWait(dlg);
if (mergedEntry.isPresent()) {
// ToDo: BibDatabase::insertEntry does not contain logic to mark the BasePanel as changed and to mark
MergeEntriesDialog dialog = new MergeEntriesDialog(first, second);
dialog.setTitle(Localization.lang("Merge entries"));
Optional<MergeResult> mergeResultOpt = dialogService.showCustomDialogAndWait(dialog);
mergeResultOpt.ifPresentOrElse(mergeResult -> {
// TODO: BibDatabase::insertEntry does not contain logic to mark the BasePanel as changed and to mark
// entries with a timestamp, only BasePanel::insertEntry does. Workaround for the moment is to get the
// BasePanel from the constructor injected JabRefFrame. Should be refactored and extracted!
frame.getCurrentLibraryTab().insertEntry(mergedEntry.get());
frame.getCurrentLibraryTab().insertEntry(mergeResult.mergedEntry());

// Create a new entry and add it to the undo stack
// Remove the other two entries and add them to the undo stack (which is not working...)
NamedCompound ce = new NamedCompound(Localization.lang("Merge entries"));
ce.addEdit(new UndoableInsertEntries(databaseContext.getDatabase(), mergedEntry.get()));
ce.addEdit(new UndoableInsertEntries(databaseContext.getDatabase(), mergeResult.mergedEntry()));
List<BibEntry> entriesToRemove = Arrays.asList(one, two);
ce.addEdit(new UndoableRemoveEntries(databaseContext.getDatabase(), entriesToRemove));
databaseContext.getDatabase().removeEntries(entriesToRemove);
ce.end();
Globals.undoManager.addEdit(ce); // ToDo: Rework UndoManager and extract Globals
Globals.undoManager.addEdit(ce);

dialogService.notify(Localization.lang("Merged entries"));
} else {
dialogService.notify(Localization.lang("Canceled merging entries"));
}
}, () -> dialogService.notify(Localization.lang("Canceled merging entries")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntry;

public class MergeEntriesDialog extends BaseDialog<BibEntry> {
public class MergeEntriesDialog extends BaseDialog<MergeResult> {
private final ThreeWayMergeView threeWayMergeView;

public MergeEntriesDialog(BibEntry one, BibEntry two) {
Expand All @@ -31,7 +31,7 @@ private void init() {
this.getDialogPane().getButtonTypes().setAll(ButtonType.CANCEL, replaceEntries);
this.setResultConverter(buttonType -> {
if (buttonType.equals(replaceEntries)) {
return threeWayMergeView.getMergedEntry();
return new MergeResult(threeWayMergeView.getLeftEntry(), threeWayMergeView.getRightEntry(), threeWayMergeView.getMergedEntry());
} else {
return null;
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/jabref/gui/mergeentries/MergeResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.jabref.gui.mergeentries;

import org.jabref.model.entry.BibEntry;

public record MergeResult(
BibEntry leftEntry, BibEntry rightEntry, BibEntry mergedEntry
) {
}
Loading