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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
376760c
Update README.md
HoussemNasri Mar 24, 2022
d898da1
Merge branch 'JabRef:main' into main
HoussemNasri Mar 31, 2022
752954b
Merge branch 'JabRef:main' into main
HoussemNasri Apr 11, 2022
41b499f
Merge branch 'JabRef:main' into main
HoussemNasri Apr 26, 2022
a63045f
Merge branch 'JabRef:main' into main
HoussemNasri May 7, 2022
0901768
Merge branch 'JabRef:main' into main
HoussemNasri May 8, 2022
5874b4e
Merge remote-tracking branch 'origin/main' into main
HoussemNasri May 30, 2022
3c3fb02
Fix Readme
HoussemNasri Jun 7, 2022
81815fa
Merge branch 'JabRef:main' into main
HoussemNasri Jun 7, 2022
18d95c2
Merge branch 'JabRef:main' into main
HoussemNasri Jun 18, 2022
0e08af3
Merge branch 'JabRef:main' into main
HoussemNasri Jun 20, 2022
2bb0b6c
Merge branch 'JabRef:main' into main
HoussemNasri Jun 23, 2022
1b12b75
Create grid cells for rendering field name and field value
HoussemNasri Jul 2, 2022
4c073d3
Implement FieldNameCell and define style class
HoussemNasri Jul 2, 2022
6359058
Make FieldValueCell selectable
HoussemNasri Jul 2, 2022
d45f4a1
Implement MergedFieldCell for rendering editable merged field value
HoussemNasri Jul 2, 2022
7e226e2
Change MergedFieldCell text based on the selected FieldValueCell
HoussemNasri Jul 2, 2022
fb137cb
Style MergedFieldCell
HoussemNasri Jul 2, 2022
8d76e40
Rename ThreeWayMerge css stylesheet
HoussemNasri Jul 2, 2022
98eea59
Create HeadView for rendering left, right and merged entry headers
HoussemNasri Jul 2, 2022
3187365
Fix typo
HoussemNasri Jul 2, 2022
d00bab3
Fix a bug that causes the selection of both left and right field cell…
HoussemNasri Jul 2, 2022
02c0404
Prevent the selection of FieldValueCell when it's disabled
HoussemNasri Jul 2, 2022
05527c6
Display a copy icon inside FieldValueCell
HoussemNasri Jul 2, 2022
b6db346
Disable left or right FieldValueCell when it's empty
HoussemNasri Jul 2, 2022
fa97b59
Update Base CSS style
HoussemNasri Jul 2, 2022
52b5604
Design and implement the merge toolbox
HoussemNasri Jul 2, 2022
b2e5d38
Implement the initial prototype of the new merge UI
HoussemNasri Jul 2, 2022
51c6195
Use ThreeWayMergeView in MergeEntriesDialog
HoussemNasri Jul 2, 2022
e66ae3d
Fix ThreeWayMergeView.css stylesheet not being imported
HoussemNasri Jul 2, 2022
d39171e
Span left field value to 2 columns when left and right field values a…
HoussemNasri Jul 2, 2022
6cdcec7
Wrap the copy icon inside a button
HoussemNasri Jul 2, 2022
c19d46a
Use HAND cursor when hover over FieldValueCell
HoussemNasri Jul 2, 2022
d1983ba
Move field cells styles to ThreeWayMergeView.css
HoussemNasri Jul 2, 2022
5d22e16
Update merge toolbox FXML UI
HoussemNasri Jul 2, 2022
23c6c91
Implement and style HeaderCell
HoussemNasri Jul 2, 2022
d2f8e21
Take row index as an argument in AbstractCell
HoussemNasri Jul 2, 2022
329e2f9
Color cell background based on its row position (odd or even)
HoussemNasri Jul 2, 2022
3df63ae
Bind textArea.textProperty() and textProperty() using BindingsHelper
HoussemNasri Jul 2, 2022
dd28f10
Copy field value to Clipboard user clicks on the copy button
HoussemNasri Jul 2, 2022
8231f75
Implement a more complete HeaderView
HoussemNasri Jul 2, 2022
3575569
Pass left and right headers to HeaderView
HoussemNasri Jul 2, 2022
7aa387f
Create merged entry
HoussemNasri Jul 2, 2022
4a8f1e8
Add the entry type field at the top of the fields list
HoussemNasri Jul 2, 2022
70522eb
Display entry type and bind merged entry
HoussemNasri Jul 2, 2022
9a05277
Minor changes
HoussemNasri Jul 2, 2022
d578b7e
Style CSS
HoussemNasri Jul 2, 2022
27dbcd1
Update ThreeWayMergeToolbox.fxml
HoussemNasri Jul 2, 2022
c9b87de
Remove MergeEntries from MergeEntriesDialog
HoussemNasri Jul 2, 2022
5e306a4
Create EmptyCell for optimization
HoussemNasri Jul 2, 2022
5c5c68a
Update HeaderCell
HoussemNasri Jul 2, 2022
d14cb0f
Rename HeaderView to ThreeWayMergeHeaderView
HoussemNasri Jul 2, 2022
23be621
Add buttons to accept all left or right entry changes to ThreeWayMerg…
HoussemNasri Jul 2, 2022
0fe1f1b
Disable right field cell when it's not visible
HoussemNasri Jul 2, 2022
ae10410
Listen for select all left/right toolbar buttons
HoussemNasri Jul 2, 2022
d26a6bb
Style stuff
HoussemNasri Jul 2, 2022
d89d558
Add DiffHighlighter
HoussemNasri Jul 2, 2022
9c5e623
Create DiffHighlighter.css
HoussemNasri Jul 2, 2022
9e97598
Add left padding to HeaderCell
HoussemNasri Jul 2, 2022
6bad428
Move diff highlighting styles to Dark.css
HoussemNasri Jul 2, 2022
9cc0d18
Show differences between left and right values using a unified diff view
HoussemNasri Jul 2, 2022
c37c3c1
Change MergeEntriesDialog stage style
HoussemNasri Jul 2, 2022
39ee372
Remove BackgroundTone from AbstractCell
HoussemNasri Jul 2, 2022
2ed0062
Move CopyFieldValueCommand
HoussemNasri Jul 2, 2022
3ea5cd1
Make DiffMethod public
HoussemNasri Jul 2, 2022
758c13d
Move CopyFieldValueCommand
HoussemNasri Jul 2, 2022
d815bbe
Implement SplitDiffHighlighter
HoussemNasri Jul 2, 2022
d071fe4
Show diffs when user selects "Show Diff" in the toolbar UI
HoussemNasri Jul 2, 2022
735dc5a
Fix bugs in UnifiedDiffHighlighter
HoussemNasri Jul 2, 2022
ff58de9
Style css stuff
HoussemNasri Jul 2, 2022
7345482
Fix typos
HoussemNasri Jul 2, 2022
d072bab
Refactor SplitDiffHighlighter and fix bugs
HoussemNasri Jul 2, 2022
5187934
Remove redundant constructor from UnifiedDiffHighlighter
HoussemNasri Jul 2, 2022
cc3560f
Allow users to switch between split and unified diff view
HoussemNasri Jul 2, 2022
b56e5d0
Set left and right headers in MergeEntriesDialog
HoussemNasri Jul 2, 2022
d09808b
Refactor ThreeWayMergeHeaderView
HoussemNasri Jul 2, 2022
5c0b51f
Remove wellbehavedfx module dependency
HoussemNasri Jun 28, 2022
0c0db6a
Delete EmptyCell.java
HoussemNasri Jul 2, 2022
d854958
Refactor FieldValueCell
HoussemNasri Jul 2, 2022
1fe1697
Use the new merge UI in DuplicateResolverDialog
HoussemNasri Jul 2, 2022
b09933a
Expose an API to change diff view and highlight method from outside t…
HoussemNasri Jul 2, 2022
2f39c4e
Use the new merge UI when an entry is changed from external
HoussemNasri Jul 2, 2022
a8b2aed
Minor styling
HoussemNasri Jun 29, 2022
aaf77ad
Remove DiffHighlighter.css stylesheet
HoussemNasri Jul 2, 2022
c96b122
Remove unused dependencies
HoussemNasri Jul 2, 2022
f8abc0f
Allow selecting empty field values
HoussemNasri Jul 2, 2022
7af8944
Fix readme :(
HoussemNasri Jul 2, 2022
4e2e2d2
Use a theme color for selection box background
HoussemNasri Jul 2, 2022
30e817b
Refactor FieldValueCell
HoussemNasri Jul 3, 2022
c8a9e31
Add an action to FieldValueCell for opening Urls
HoussemNasri Jul 3, 2022
815d415
Add the ability to open DOI identifier
HoussemNasri Jul 3, 2022
89357c6
Cleanup
HoussemNasri Jul 3, 2022
9973e03
Checkstyle
HoussemNasri Jul 3, 2022
ee64212
Improve URL validation logic
HoussemNasri Jul 4, 2022
5af4864
Use DiffMethod in merge toolbar for consistency
HoussemNasri Jul 4, 2022
ed2a0ac
i18n
HoussemNasri Jul 4, 2022
bcec6a8
Cleanup css
HoussemNasri Jul 4, 2022
be0a7fb
Remove redundant icon style
HoussemNasri Jul 4, 2022
0602237
Rename style class field-value to merge-field-value
HoussemNasri Jul 4, 2022
41cae26
Remove old Merge entries UI
HoussemNasri Jul 4, 2022
ddac224
Merge branch 'main' into GSOC-fully-functional-three-way-merge
HoussemNasri Jul 4, 2022
6859ca4
Fix missing header styles
HoussemNasri Jul 4, 2022
6dcaaa1
Merge remote-tracking branch 'origin/GSOC-fully-functional-three-way-…
HoussemNasri Jul 5, 2022
5df2d50
i18n
HoussemNasri Jul 5, 2022
db706a8
Garbage collect right cell when it's invisible
HoussemNasri Jul 6, 2022
fffc5d1
Fix typo
HoussemNasri Jul 6, 2022
20c181c
Merge remote-tracking branch 'upstream/main' into GSOC-fully-function…
Siedlerchr Aug 3, 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
48 changes: 48 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@


.root {
-jr-row-odd-background: -fx-control-inner-background-alt;
-jr-row-even-background: -fx-control-inner-background;
/*
On light theme, the text is hard to see when it's on top of the accent color. This is an alternative lighter accent color
for better text visibility.
*/
-jr-accent-alt: derive(-jr-accent, 15%);

/*
The theme color and some derived colors from it are used for icons, tab-headers, marking of selected inputs and
Expand All @@ -9,6 +18,7 @@
/* This theme is the original JabRef dark blue color */
-jr-theme: #50618F;
-jr-accent: #a3b7e6;
-jr-transparent-accent: rgba(163, 183, 230, 0.16);
-jr-selected: -jr-accent;
-jr-checked: -jr-theme;
-jr-hover: #0002;
Expand Down Expand Up @@ -245,6 +255,23 @@
-jr-header-height: 3em;
}

.unchanged {
-rtfx-background-color:#0000;
}

.updated {
-rtfx-background-color: rgba(41, 166, 236, 0.66);
}

.addition {
-rtfx-background-color: rgba(29, 209, 161, 0.5);
}

.deletion {
-rtfx-background-color: rgba(255, 107, 107, 0.55);
}


#frame {
-fx-background-color: -jr-background-alt;
}
Expand Down Expand Up @@ -607,6 +634,27 @@ TextFlow > .tooltip-text-monospaced {
-fx-background-insets: 0;
}

.merge-field-value .action-icon {
-fx-blend-mode: multiply;
-fx-opacity: 69%;
-fx-icon-size: 14;
-fx-icon-color: -fx-text-background-color;
}

.merge-field-value:disabled .action-icon {
-fx-opacity: 0%;
}

.merge-header-cell {
-fx-border-width: 0 0 1 0;
-fx-border-color: -jr-gray-1;
-fx-background-color: -jr-row-even-background;
}

.merge-header {
-fx-background-color: -jr-row-even-background;
}

.table-view .groupColumnBackground {
-fx-stroke: -jr-gray-2;
}
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/org/jabref/gui/Dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
-jr-selected: -jr-accent;
-jr-hover: #fff1;

-jr-row-odd-background: #272b38;
-jr-row-even-background: #212330;
-jr-accent-alt: -jr-accent;

-jr-red: #b71c1f;
-jr-light-red: #db1d2b;
Expand Down Expand Up @@ -60,6 +63,18 @@
-js-summary-text-color-selected: derive( -fx-dark-text-color, 70%);
}

.unchanged {

}

.addition {
-rtfx-background-color: -jr-green;
}

.deletion {
-rtfx-background-color: -jr-red;
}

#previewBody {
background-color: #272b38; /* -fx-control-inner-background*/
color: #7d8591; /* -fx-mid-text-color*/
Expand All @@ -82,6 +97,21 @@
-fx-background-color: -jr-hover;
}

.merge-field-value .action-icon {
-fx-blend-mode: none;
-fx-opacity: 90%;
}

.merge-header-cell {
-fx-border-width: 0 0 1 0;
-fx-border-color: -fx-outer-border;
-fx-background-color: -jr-row-odd-background;
}

.merge-header {
-fx-background-color: -jr-row-odd-background;
}

.table-view .groupColumnBackground {
-fx-stroke: -jr-gray-3;
}
Expand Down
22 changes: 13 additions & 9 deletions src/main/java/org/jabref/gui/collab/EntryChangeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;

import org.jabref.gui.mergeentries.MergeEntries;
import org.jabref.gui.mergeentries.MergeEntries.DefaultRadioButtonSelectionMode;
import org.jabref.gui.mergeentries.newmergedialog.ShowDiffConfig;
import org.jabref.gui.mergeentries.newmergedialog.ThreeWayMergeView;
import org.jabref.gui.mergeentries.newmergedialog.diffhighlighter.DiffHighlighter;
import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.undo.UndoableInsertEntries;
import org.jabref.logic.l10n.Localization;
Expand All @@ -17,7 +19,7 @@ class EntryChangeViewModel extends DatabaseChangeViewModel {

private final BibEntry oldEntry;
private final BibEntry newEntry;
private MergeEntries mergePanel;
private ThreeWayMergeView threeWayMergeView;

public EntryChangeViewModel(BibEntry entry, BibEntry newEntry) {
super();
Expand All @@ -37,17 +39,17 @@ public EntryChangeViewModel(BibEntry entry, BibEntry newEntry) {
public void setAccepted(boolean accepted) {
super.setAccepted(accepted);
if (accepted) {
mergePanel.selectAllRightRadioButtons();
threeWayMergeView.selectRightEntryValues();
} else {
mergePanel.selectAllLeftRadioButtons();
threeWayMergeView.selectLeftEntryValues();
}
}

@Override
public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) {
this.description(); // Init dialog to prevent NPE
database.getDatabase().removeEntry(oldEntry);
BibEntry mergedEntry = mergePanel.getMergedEntry();
BibEntry mergedEntry = threeWayMergeView.getMergedEntry();
mergedEntry.setId(oldEntry.getId()); // Keep ID
database.getDatabase().insertEntry(mergedEntry);
undoEdit.addEdit(new UndoableInsertEntries(database.getDatabase(), oldEntry));
Expand All @@ -56,13 +58,15 @@ public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) {

@Override
public Node description() {
mergePanel = new MergeEntries(oldEntry, newEntry, Localization.lang("In JabRef"), Localization.lang("On disk"), DefaultRadioButtonSelectionMode.LEFT);
threeWayMergeView = new ThreeWayMergeView(oldEntry, newEntry, Localization.lang("In JabRef"), Localization.lang("On disk"));
threeWayMergeView.selectLeftEntryValues();
threeWayMergeView.showDiff(new ShowDiffConfig(ThreeWayMergeToolbar.DiffView.SPLIT, DiffHighlighter.DiffMethod.WORDS));
VBox container = new VBox(10);
Label header = new Label(name);
header.getStyleClass().add("sectionHeader");
container.getChildren().add(header);
container.getChildren().add(mergePanel);
VBox.setMargin(mergePanel, new Insets(5, 5, 5, 5));
container.getChildren().add(threeWayMergeView);
VBox.setMargin(threeWayMergeView, new Insets(5, 5, 5, 5));
return container;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.jabref.gui.StateManager;
import org.jabref.gui.duplicationFinder.DuplicateResolverDialog.DuplicateResolverResult;
import org.jabref.gui.help.HelpAction;
import org.jabref.gui.mergeentries.MergeEntries;
import org.jabref.gui.mergeentries.newmergedialog.ThreeWayMergeView;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.DialogWindowState;
import org.jabref.logic.help.HelpFile;
Expand Down Expand Up @@ -39,7 +39,7 @@ public enum DuplicateResolverResult {
BREAK
}

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

public DuplicateResolverDialog(BibEntry one, BibEntry two, DuplicateResolverType type, BibDatabaseContext database, StateManager stateManager, DialogService dialogService) {
Expand Down Expand Up @@ -69,14 +69,14 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) {
first = new ButtonType(Localization.lang("Keep left"), ButtonData.APPLY);
second = new ButtonType(Localization.lang("Keep right"), ButtonData.APPLY);
both = new ButtonType(Localization.lang("Keep both"), ButtonData.APPLY);
mergeEntries = new MergeEntries(one, two);
threeWayMerge = new ThreeWayMergeView(one, two);
break;
case INSPECTION:
first = new ButtonType(Localization.lang("Remove old entry"), ButtonData.APPLY);
second = new ButtonType(Localization.lang("Remove entry from import"), ButtonData.APPLY);
both = new ButtonType(Localization.lang("Keep both"), ButtonData.APPLY);
mergeEntries = new MergeEntries(one, two, Localization.lang("Old entry"),
Localization.lang("From import"));
threeWayMerge = new ThreeWayMergeView(one, two, Localization.lang("Old entry"),
Localization.lang("From import"));
break;
case DUPLICATE_SEARCH_WITH_EXACT:
first = new ButtonType(Localization.lang("Keep left"), ButtonData.APPLY);
Expand All @@ -85,14 +85,14 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) {

removeExactVisible = true;

mergeEntries = new MergeEntries(one, two);
threeWayMerge = new ThreeWayMergeView(one, two);
break;
default:
first = new ButtonType(Localization.lang("Import and remove old entry"), ButtonData.APPLY);
second = new ButtonType(Localization.lang("Do not import entry"), ButtonData.APPLY);
both = new ButtonType(Localization.lang("Import and keep old entry"), ButtonData.APPLY);
mergeEntries = new MergeEntries(one, two, Localization.lang("Old entry"),
Localization.lang("From import"));
threeWayMerge = new ThreeWayMergeView(one, two, Localization.lang("Old entry"),
Localization.lang("From import"));
break;
}
if (removeExactVisible) {
Expand All @@ -109,7 +109,7 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) {
this.setY(state.getY());
}

BorderPane borderPane = new BorderPane(mergeEntries);
BorderPane borderPane = new BorderPane(threeWayMerge);
borderPane.setBottom(options);

this.setResultConverter(button -> {
Expand All @@ -136,6 +136,6 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) {
}

public BibEntry getMergedEntry() {
return mergeEntries.getMergedEntry();
return threeWayMerge.getMergedEntry();
}
}
7 changes: 6 additions & 1 deletion src/main/java/org/jabref/gui/fieldeditors/URLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ public static String cleanGoogleSearchURL(String url) {
* @return true if <c>url</c> contains a valid URL
*/
public static boolean isURL(String url) {
return url.contains("://");
try {
new URL(url);
return true;
} catch (MalformedURLException e) {
return false;
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/jabref/gui/icon/IconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,11 @@ public enum JabRefIcons implements JabRefIcon {
KEEP_SEARCH_STRING(MaterialDesignE.EARTH),
KEEP_ON_TOP(MaterialDesignP.PIN),
KEEP_ON_TOP_OFF(MaterialDesignP.PIN_OFF_OUTLINE),
OPEN_GLOBAL_SEARCH(MaterialDesignO.OPEN_IN_NEW);
OPEN_GLOBAL_SEARCH(MaterialDesignO.OPEN_IN_NEW),

ACCEPT_LEFT(MaterialDesignS.SUBDIRECTORY_ARROW_LEFT),

ACCEPT_RIGHT(MaterialDesignS.SUBDIRECTORY_ARROW_RIGHT);

private final JabRefIcon icon;

Expand Down
12 changes: 0 additions & 12 deletions src/main/java/org/jabref/gui/mergeentries/MergeEntries.css

This file was deleted.

Loading