diff --git a/CHANGELOG.md b/CHANGELOG.md index 3529222a37f..329bc243c07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the command line export using `--exportMatches` flag does not create an output bib file [#9581](https://github.com/JabRef/jabref/issues/9581) - We fixed an issue where custom field in the custom entry types could not be set to mulitline [#9609](https://github.com/JabRef/jabref/issues/9609) - We fixed an issue where the Office XML exporter did not resolve BibTeX-Strings when exporting entries [forum#3741](https://discourse.jabref.org/t/exporting-bibtex-constant-strings-to-ms-office-2007-xml/3741) +- We fixed an issue where the Merge Entries Toolbar configuration was not saved after hitting 'Merge Entries' button [#9091](https://github.com/JabRef/jabref/issues/9091) - We fixed an issue where the password is saved locally if user wants to use proxy with authentication [#8055](https://github.com/JabRef/jabref/issues/8055) - JabRef is now more relaxed when parsing field content: In case a field content ended with `\`, the combination `\}` was treated as plain `}`. [#9668](https://github.com/JabRef/jabref/issues/9668) - We resolved an issue that cut off the number of group entries when it exceedet four digits. [#8797](https://github.com/JabRef/jabref/issues/8797) diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java index 205e4df75de..15a27d4f810 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java @@ -122,6 +122,7 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { this.setResultConverter(button -> { // Updates the window state on button press stateManager.setDialogWindowState(getClass().getSimpleName(), new DialogWindowState(this.getX(), this.getY(), this.getDialogPane().getHeight(), this.getDialogPane().getWidth())); + threeWayMerge.saveConfiguration(); if (button.equals(first)) { return DuplicateResolverResult.KEEP_LEFT; diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java index 23a82a1ddde..8be99e1bfee 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java @@ -36,6 +36,7 @@ private void init() { ButtonType replaceEntries = new ButtonType(Localization.lang("Merge entries"), ButtonBar.ButtonData.OK_DONE); this.getDialogPane().getButtonTypes().setAll(ButtonType.CANCEL, replaceEntries); this.setResultConverter(buttonType -> { + threeWayMergeView.saveConfiguration(); if (buttonType.equals(replaceEntries)) { return new EntriesMergeResult(one, two, threeWayMergeView.getLeftEntry(), threeWayMergeView.getRightEntry(), threeWayMergeView.getMergedEntry()); } else { diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java index 5767d747a4c..fd2b1b3105f 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java @@ -191,4 +191,8 @@ public BibEntry getLeftEntry() { public BibEntry getRightEntry() { return viewModel.getRightEntry(); } + + public void saveConfiguration() { + toolbar.saveToolbarConfiguration(); + } } diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index 8a656830e4d..03a595741e5 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -17,9 +17,11 @@ import org.jabref.gui.mergeentries.newmergedialog.DiffMethod; import org.jabref.gui.mergeentries.newmergedialog.diffhighlighter.DiffHighlighter.BasicDiffMethod; import org.jabref.logic.l10n.Localization; +import org.jabref.preferences.GuiPreferences; import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; +import com.google.common.base.Enums; import com.tobiasdiez.easybind.EasyBind; import com.tobiasdiez.easybind.EasyBinding; import jakarta.inject.Inject; @@ -66,7 +68,7 @@ public ThreeWayMergeToolbar() { public void initialize() { showDiff = EasyBind.map(plainTextOrDiffComboBox.valueProperty(), plainTextOrDiff -> plainTextOrDiff == PlainTextOrDiff.Diff); plainTextOrDiffComboBox.getItems().addAll(PlainTextOrDiff.values()); - plainTextOrDiffComboBox.getSelectionModel().select(PlainTextOrDiff.Diff); + plainTextOrDiffComboBox.setConverter(new StringConverter<>() { @Override public String toString(PlainTextOrDiff plainTextOrDiff) { @@ -81,7 +83,7 @@ public PlainTextOrDiff fromString(String string) { diffViewComboBox.disableProperty().bind(notShowDiffProperty()); diffViewComboBox.getItems().addAll(DiffView.values()); - diffViewComboBox.getSelectionModel().select(DiffView.UNIFIED); + diffViewComboBox.setConverter(new StringConverter<>() { @Override public String toString(DiffView diffView) { @@ -105,11 +107,30 @@ public DiffView fromString(String string) { } })); - diffHighlightingMethodToggleGroup.selectToggle(highlightWordsRadioButton); - plainTextOrDiffComboBox.valueProperty().set(PlainTextOrDiff.Diff); - onlyShowChangedFieldsCheck.selectedProperty().bindBidirectional(preferencesService.getGuiPreferences().mergeShowChangedFieldOnlyProperty()); onlyShowChangedFields.bind(onlyShowChangedFieldsCheck.selectedProperty()); + + loadSavedConfiguration(); + } + + private void loadSavedConfiguration() { + GuiPreferences guiPreferences = preferencesService.getGuiPreferences(); + + PlainTextOrDiff plainTextOrDiffPreference = guiPreferences.getMergeShouldShowDiff() ? PlainTextOrDiff.Diff : PlainTextOrDiff.PLAIN_TEXT; + plainTextOrDiffComboBox.getSelectionModel().select(plainTextOrDiffPreference); + + DiffView diffViewPreference = guiPreferences.getMergeShouldShowUnifiedDiff() ? DiffView.UNIFIED : DiffView.SPLIT; + diffViewComboBox.getSelectionModel().select(diffViewPreference); + + diffHighlightingMethodToggleGroup.selectToggle(guiPreferences.getMergeHighlightWords() ? highlightWordsRadioButton : highlightCharactersRadioButtons); + } + + public void saveToolbarConfiguration() { + preferencesService.getGuiPreferences().setMergeShouldShowDiff(plainTextOrDiffComboBox.getValue() == PlainTextOrDiff.Diff); + preferencesService.getGuiPreferences().setMergeShouldShowUnifiedDiff(diffViewComboBox.getValue() == DiffView.UNIFIED); + + boolean highlightWordsRadioButtonValue = diffHighlightingMethodToggleGroup.getSelectedToggle().equals(highlightWordsRadioButton); + preferencesService.getGuiPreferences().setMergeHighlightWords(highlightWordsRadioButtonValue); } public ObjectProperty diffViewProperty() { @@ -185,6 +206,10 @@ public enum PlainTextOrDiff { this.value = value; } + public static PlainTextOrDiff parse(String name) { + return Enums.getIfPresent(PlainTextOrDiff.class, name).or(Diff); + } + public String getValue() { return value; } @@ -203,6 +228,10 @@ public enum DiffView { this.value = value; } + public static DiffView parse(String name) { + return Enums.getIfPresent(DiffView.class, name).or(UNIFIED); + } + public String getValue() { return value; } diff --git a/src/main/java/org/jabref/preferences/GuiPreferences.java b/src/main/java/org/jabref/preferences/GuiPreferences.java index fc0bd899286..c868ba3d751 100644 --- a/src/main/java/org/jabref/preferences/GuiPreferences.java +++ b/src/main/java/org/jabref/preferences/GuiPreferences.java @@ -33,6 +33,9 @@ public class GuiPreferences { private final StringProperty lastSelectedIdBasedFetcher; private final ObjectProperty mergeDiffMode; + private final BooleanProperty mergeShouldShowDiff; + private final BooleanProperty mergeShouldShowUnifiedDiff; + private final BooleanProperty mergeHighlightWords; private final BooleanProperty mergeShowChangedFieldsOnly; private final DoubleProperty sidePaneWidth; @@ -46,6 +49,9 @@ public GuiPreferences(double positionX, FileHistory fileHistory, String lastSelectedIdBasedFetcher, DiffMode mergeDiffMode, + boolean mergeShouldShowDiff, + boolean mergeShouldShowUnifiedDiff, + boolean mergeHighlightWords, double sidePaneWidth, boolean mergeShowChangedFieldsOnly) { this.positionX = new SimpleDoubleProperty(positionX); @@ -57,6 +63,10 @@ public GuiPreferences(double positionX, this.lastFocusedFile = new SimpleObjectProperty<>(lastFocusedFile); this.lastSelectedIdBasedFetcher = new SimpleStringProperty(lastSelectedIdBasedFetcher); this.mergeDiffMode = new SimpleObjectProperty<>(mergeDiffMode); + this.mergeShouldShowDiff = new SimpleBooleanProperty(mergeShouldShowDiff); + this.mergeShouldShowUnifiedDiff = new SimpleBooleanProperty(mergeShouldShowUnifiedDiff); + this.mergeHighlightWords = new SimpleBooleanProperty(mergeHighlightWords); + this.sidePaneWidth = new SimpleDoubleProperty(sidePaneWidth); this.fileHistory = fileHistory; this.mergeShowChangedFieldsOnly = new SimpleBooleanProperty(mergeShowChangedFieldsOnly); @@ -170,6 +180,42 @@ public void setMergeDiffMode(DiffMode mergeDiffMode) { this.mergeDiffMode.set(mergeDiffMode); } + public boolean getMergeShouldShowDiff() { + return mergeShouldShowDiff.get(); + } + + public BooleanProperty mergeShouldShowDiffProperty() { + return mergeShouldShowDiff; + } + + public void setMergeShouldShowDiff(boolean mergeShouldShowDiff) { + this.mergeShouldShowDiff.set(mergeShouldShowDiff); + } + + public boolean getMergeShouldShowUnifiedDiff() { + return mergeShouldShowUnifiedDiff.get(); + } + + public BooleanProperty mergeShouldShowUnifiedDiffProperty() { + return mergeShouldShowUnifiedDiff; + } + + public void setMergeShouldShowUnifiedDiff(boolean mergeShouldShowUnifiedDiff) { + this.mergeShouldShowUnifiedDiff.set(mergeShouldShowUnifiedDiff); + } + + public boolean getMergeHighlightWords() { + return mergeHighlightWords.get(); + } + + public BooleanProperty mergeHighlightWordsProperty() { + return mergeHighlightWords; + } + + public void setMergeHighlightWords(boolean mergeHighlightsWords) { + this.mergeHighlightWords.set(mergeHighlightsWords); + } + public double getSidePaneWidth() { return sidePaneWidth.get(); } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index f6322a7e529..8db213d76c4 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -238,6 +238,11 @@ public class JabRefPreferences implements PreferencesService { // merge related public static final String MERGE_ENTRIES_DIFF_MODE = "mergeEntriesDiffMode"; + public static final String MERGE_ENTRIES_SHOULD_SHOW_DIFF = "mergeEntriesShouldShowDiff"; + public static final String MERGE_ENTRIES_SHOULD_SHOW_UNIFIED_DIFF = "mergeEntriesShouldShowUnifiedDiff"; + public static final String MERGE_ENTRIES_HIGHLIGHT_WORDS = "mergeEntriesHighlightWords"; + + public static final String MERGE_SHOW_ONLY_CHANGED_FIELDS = "mergeShowOnlyChangedFields"; public static final String CUSTOM_EXPORT_FORMAT = "customExportFormat"; @@ -587,6 +592,9 @@ private JabRefPreferences() { defaults.put(DEFAULT_SHOW_SOURCE, Boolean.FALSE); defaults.put(MERGE_ENTRIES_DIFF_MODE, DiffMode.WORD.name()); + defaults.put(MERGE_ENTRIES_SHOULD_SHOW_DIFF, Boolean.TRUE); + defaults.put(MERGE_ENTRIES_SHOULD_SHOW_UNIFIED_DIFF, Boolean.TRUE); + defaults.put(MERGE_ENTRIES_HIGHLIGHT_WORDS, Boolean.TRUE); defaults.put(MERGE_SHOW_ONLY_CHANGED_FIELDS, Boolean.FALSE); defaults.put(SHOW_RECOMMENDATIONS, Boolean.TRUE); @@ -2510,6 +2518,9 @@ public GuiPreferences getGuiPreferences() { getFileHistory(), get(ID_ENTRY_GENERATOR), DiffMode.parse(get(MERGE_ENTRIES_DIFF_MODE)), + getBoolean(MERGE_ENTRIES_SHOULD_SHOW_DIFF), + getBoolean(MERGE_ENTRIES_SHOULD_SHOW_UNIFIED_DIFF), + getBoolean(MERGE_ENTRIES_HIGHLIGHT_WORDS), getDouble(SIDE_PANE_WIDTH), getBoolean(MERGE_SHOW_ONLY_CHANGED_FIELDS)); @@ -2535,6 +2546,9 @@ public GuiPreferences getGuiPreferences() { guiPreferences.getFileHistory().addListener((InvalidationListener) change -> storeFileHistory(guiPreferences.getFileHistory())); EasyBind.listen(guiPreferences.lastSelectedIdBasedFetcherProperty(), (obs, oldValue, newValue) -> put(ID_ENTRY_GENERATOR, newValue)); EasyBind.listen(guiPreferences.mergeDiffModeProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_DIFF_MODE, newValue.name())); + EasyBind.listen(guiPreferences.mergeShouldShowDiffProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_ENTRIES_SHOULD_SHOW_DIFF, newValue)); + EasyBind.listen(guiPreferences.mergeShouldShowUnifiedDiffProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_ENTRIES_SHOULD_SHOW_UNIFIED_DIFF, newValue)); + EasyBind.listen(guiPreferences.mergeHighlightWordsProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_ENTRIES_HIGHLIGHT_WORDS, newValue)); EasyBind.listen(guiPreferences.sidePaneWidthProperty(), (obs, oldValue, newValue) -> putDouble(SIDE_PANE_WIDTH, newValue.doubleValue())); EasyBind.listen(guiPreferences.mergeShowChangedFieldOnlyProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_SHOW_ONLY_CHANGED_FIELDS, newValue)); diff --git a/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java b/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java index b05aed909a5..6bdbac10b98 100644 --- a/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java +++ b/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java @@ -27,10 +27,11 @@ void testDefaultCitation() { String citation = CitationStyleGenerator.generateCitation(TestEntry.getTestEntry(), CitationStyle.getDefault().getSource(), CitationStyleOutputFormat.HTML, context, new BibEntryTypesManager()); // if the default citation style changes this has to be modified - String expected = "
\n" - + "
[1]
B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, 2016-07, doi: 10.1001/bla.blubb.
\n" - + "
\n" - + ""; + String expected = """ +
+
[1]
B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016, doi: 10.1001/bla.blubb.
+
+ """; assertEquals(expected, citation); }