From e65a2030083327571f72aeffa6df82fba8e0db8c Mon Sep 17 00:00:00 2001 From: Jonathan Rech Date: Wed, 25 Oct 2023 14:39:26 +0200 Subject: [PATCH 1/2] Add button for a user to reset the cite command to the default value. Add button in ExternalTab.fxml and link it to a method in ExternalTabViewModel.java that sets the citeCommandProperty to the specified default value Update CHANGELOG.md --- CHANGELOG.md | 1 + .../jabref/gui/preferences/external/ExternalTab.fxml | 11 ++++++++++- .../jabref/gui/preferences/external/ExternalTab.java | 5 +++++ .../preferences/external/ExternalTabViewModel.java | 7 +++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c4869a0d16..24a4a1f83fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv ### Added - We added a dropdown menu to let users change the reference library during AUX file import. [#10472](https://github.com/JabRef/jabref/issues/10472) +- We added a button to let users reset the cite command to the default value. [#10569](https://github.com/JabRef/jabref/issues/10569) ### Changed diff --git a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml index 803d9bead9a..8db73e2b093 100644 --- a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml +++ b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml @@ -33,7 +33,7 @@ - + @@ -60,6 +60,15 @@ styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0" GridPane.columnIndex="2" GridPane.rowIndex="2"/> + diff --git a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java index 4a266a113c9..0ac80610051 100644 --- a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java +++ b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java @@ -101,4 +101,9 @@ void useTerminalCommandBrowse() { void useFileBrowserSpecialCommandBrowse() { viewModel.customFileBrowserBrowse(); } + + @FXML + void resetCiteCommandToDefault() { + viewModel.resetCiteCommandToDefault(); + } } diff --git a/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java b/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java index 59308f47c46..ac6b1977d9c 100644 --- a/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java @@ -24,6 +24,7 @@ import org.jabref.logic.l10n.Localization; import org.jabref.model.strings.StringUtil; import org.jabref.preferences.ExternalApplicationsPreferences; +import org.jabref.preferences.JabRefPreferences; import org.jabref.preferences.PreferencesService; import org.jabref.preferences.PushToApplicationPreferences; @@ -227,4 +228,10 @@ public BooleanProperty useCustomFileBrowserProperty() { public StringProperty customFileBrowserCommandProperty() { return this.customFileBrowserCommandProperty; } + + // Reset Cite Command + + public void resetCiteCommandToDefault() { + this.citeCommandProperty.setValue(preferences.getDefaults().get(JabRefPreferences.CITE_COMMAND).toString()); + } } From 656f566bd148ad711d519b8f9c9f07e3b299d463 Mon Sep 17 00:00:00 2001 From: Jonathan Rech Date: Wed, 25 Oct 2023 23:59:07 +0200 Subject: [PATCH 2/2] Fix the requested changes. Delete redundant comment. Encapsulate getDefaultCiteCommand in ExternalApplicationsPreferences and update JabRefPreferences accordingly --- .../gui/preferences/external/ExternalTabViewModel.java | 5 +---- .../preferences/ExternalApplicationsPreferences.java | 8 ++++++++ .../java/org/jabref/preferences/JabRefPreferences.java | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java b/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java index ac6b1977d9c..f8e7f96993c 100644 --- a/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java @@ -24,7 +24,6 @@ import org.jabref.logic.l10n.Localization; import org.jabref.model.strings.StringUtil; import org.jabref.preferences.ExternalApplicationsPreferences; -import org.jabref.preferences.JabRefPreferences; import org.jabref.preferences.PreferencesService; import org.jabref.preferences.PushToApplicationPreferences; @@ -229,9 +228,7 @@ public StringProperty customFileBrowserCommandProperty() { return this.customFileBrowserCommandProperty; } - // Reset Cite Command - public void resetCiteCommandToDefault() { - this.citeCommandProperty.setValue(preferences.getDefaults().get(JabRefPreferences.CITE_COMMAND).toString()); + this.citeCommandProperty.setValue(preferences.getExternalApplicationsPreferences().getDefaultCiteCommand()); } } diff --git a/src/main/java/org/jabref/preferences/ExternalApplicationsPreferences.java b/src/main/java/org/jabref/preferences/ExternalApplicationsPreferences.java index 2b64ebbe884..45670b68a28 100644 --- a/src/main/java/org/jabref/preferences/ExternalApplicationsPreferences.java +++ b/src/main/java/org/jabref/preferences/ExternalApplicationsPreferences.java @@ -11,6 +11,8 @@ public class ExternalApplicationsPreferences { private final BooleanProperty shouldAutoOpenEmailAttachmentsFolder; private final StringProperty citeCommand; + private final StringProperty defaultCiteCommand; + private final BooleanProperty useCustomTerminal; private final StringProperty customTerminalCommand; private final BooleanProperty useCustomFileBrowser; @@ -20,6 +22,7 @@ public class ExternalApplicationsPreferences { public ExternalApplicationsPreferences(String eMailSubject, boolean shouldAutoOpenEmailAttachmentsFolder, String citeCommand, + String defaultCiteCommand, boolean useCustomTerminal, String customTerminalCommand, boolean useCustomFileBrowser, @@ -29,6 +32,7 @@ public ExternalApplicationsPreferences(String eMailSubject, this.eMailSubject = new SimpleStringProperty(eMailSubject); this.shouldAutoOpenEmailAttachmentsFolder = new SimpleBooleanProperty(shouldAutoOpenEmailAttachmentsFolder); this.citeCommand = new SimpleStringProperty(citeCommand); + this.defaultCiteCommand = new SimpleStringProperty(defaultCiteCommand); this.useCustomTerminal = new SimpleBooleanProperty(useCustomTerminal); this.customTerminalCommand = new SimpleStringProperty(customTerminalCommand); this.useCustomFileBrowser = new SimpleBooleanProperty(useCustomFileBrowser); @@ -131,4 +135,8 @@ public StringProperty kindleEmailProperty() { public void setKindleEmail(String kindleEmail) { this.kindleEmail.set(kindleEmail); } + + public String getDefaultCiteCommand() { + return defaultCiteCommand.getValue(); + } } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 64eb1845322..d3ec6d79e99 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -1791,6 +1791,7 @@ public ExternalApplicationsPreferences getExternalApplicationsPreferences() { get(EMAIL_SUBJECT), getBoolean(OPEN_FOLDERS_OF_ATTACHED_FILES), get(CITE_COMMAND), + (String) defaults.get(CITE_COMMAND), !getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the ! get(CONSOLE_COMMAND), !getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the !