From e9456664378d313234762718ba30cde60817ce3a Mon Sep 17 00:00:00 2001 From: Arsh Chawla Date: Wed, 16 Oct 2024 21:45:31 +1100 Subject: [PATCH 1/8] Modified GROBID dialog logic, allowing users to explicitly save GROBID usage preference. "Do not ask" checkbox replaced with "Save Preference", and GROBID_OPTOUT replaced with GROBID_PREFERENCE to reduce ambiguity. --- .../jabref/gui/entryeditor/EntryEditor.java | 4 ++-- .../gui/fieldeditors/LinkedFilesEditor.java | 4 ++-- ...java => GrobidPreferenceDialogHelper.java} | 18 ++++++++--------- .../jabref/gui/importer/ImportCommand.java | 4 ++-- .../websearch/WebSearchTabViewModel.java | 2 +- .../importer/util/GrobidPreferences.java | 20 +++++++++---------- .../preferences/JabRefCliPreferences.java | 8 ++++---- 7 files changed, 29 insertions(+), 31 deletions(-) rename src/main/java/org/jabref/gui/importer/{GrobidOptInDialogHelper.java => GrobidPreferenceDialogHelper.java} (75%) diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 6a382a7a59e..4f02c61dc6e 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -37,7 +37,7 @@ import org.jabref.gui.entryeditor.fileannotationtab.FulltextSearchResultsTab; import org.jabref.gui.externalfiles.ExternalFilesEntryLinker; import org.jabref.gui.help.HelpAction; -import org.jabref.gui.importer.GrobidOptInDialogHelper; +import org.jabref.gui.importer.GrobidPreferenceDialogHelper; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.gui.menus.ChangeEntryTypeMenu; @@ -432,7 +432,7 @@ private void setupToolBar() { if (fetcher instanceof PdfMergeMetadataImporter.EntryBasedFetcherWrapper) { // Handle Grobid Opt-In in case of the PdfMergeMetadataImporter fetcherMenuItem.setOnAction(event -> { - GrobidOptInDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences()); + GrobidPreferenceDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences()); PdfMergeMetadataImporter.EntryBasedFetcherWrapper pdfMergeMetadataImporter = new PdfMergeMetadataImporter.EntryBasedFetcherWrapper( preferences.getImportFormatPreferences(), diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java index 5a95b3e42f2..ca7d95bd2a6 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java @@ -41,7 +41,7 @@ import org.jabref.gui.copyfiles.CopySingleFileAction; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.icon.JabRefIconView; -import org.jabref.gui.importer.GrobidOptInDialogHelper; +import org.jabref.gui.importer.GrobidPreferenceDialogHelper; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.linkedfile.DeleteFileAction; import org.jabref.gui.linkedfile.LinkedFileEditDialog; @@ -236,7 +236,7 @@ private Node createFileDisplay(LinkedFileViewModel linkedFile) { parsePdfMetadata.setTooltip(new Tooltip(Localization.lang("Parse Metadata from PDF."))); parsePdfMetadata.visibleProperty().bind(linkedFile.isOfflinePdfProperty()); parsePdfMetadata.setOnAction(event -> { - GrobidOptInDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences()); + GrobidPreferenceDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences()); linkedFile.parsePdfMetadataAndShowMergeDialog(); }); parsePdfMetadata.getStyleClass().setAll("icon-button"); diff --git a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java b/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java similarity index 75% rename from src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java rename to src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java index 6ef67bc17a0..8d391f895f0 100644 --- a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java +++ b/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java @@ -9,27 +9,25 @@ * due to data privacy concerns. * To make users aware of the feature, we ask each time before querying Grobid, giving the option to opt-out. */ -public class GrobidOptInDialogHelper { +public class GrobidPreferenceDialogHelper { /** * If Grobid is not enabled but the user has not explicitly opted-out of Grobid, we ask for permission to send data - * to Grobid using a dialog and giving an opt-out option. + * to Grobid by using a dialog and giving an explicit 'save preference' option. * * @param dialogService the DialogService to use - * @return if the user enabled Grobid, either in the past or after being asked by the dialog. + * @return if the user enabled Grobid, either in the past or after being asked by the dialog, save preference + * if specified. */ public static boolean showAndWaitIfUserIsUndecided(DialogService dialogService, GrobidPreferences preferences) { - if (preferences.isGrobidEnabled()) { - return true; - } - if (preferences.isGrobidOptOut()) { - return false; + if (preferences.isGrobidPreference()) { + return preferences.isGrobidEnabled(); } boolean grobidEnabled = dialogService.showConfirmationDialogWithOptOutAndWait( Localization.lang("Remote services"), Localization.lang("Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results."), - Localization.lang("Do not ask again"), - optOut -> preferences.setGrobidOptOut(optOut)); + Localization.lang("Save Preference"), + preferences::setGrobidPreference); preferences.setGrobidEnabled(grobidEnabled); return grobidEnabled; } diff --git a/src/main/java/org/jabref/gui/importer/ImportCommand.java b/src/main/java/org/jabref/gui/importer/ImportCommand.java index 55469924eb9..d74ba47d775 100644 --- a/src/main/java/org/jabref/gui/importer/ImportCommand.java +++ b/src/main/java/org/jabref/gui/importer/ImportCommand.java @@ -144,7 +144,7 @@ private ParserResult doImport(List files, Importer importFormat) throws IO if (importer.isEmpty()) { // Unknown format UiTaskExecutor.runAndWaitInJavaFXThread(() -> { - if (FileUtil.isPDFFile(filename) && GrobidOptInDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences())) { + if (FileUtil.isPDFFile(filename) && GrobidPreferenceDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences())) { importFormatReader.reset(); } dialogService.notify(Localization.lang("Importing file %0 as unknown format", filename.getFileName().toString())); @@ -155,7 +155,7 @@ private ParserResult doImport(List files, Importer importFormat) throws IO UiTaskExecutor.runAndWaitInJavaFXThread(() -> { if (((importer.get() instanceof PdfGrobidImporter) || (importer.get() instanceof PdfMergeMetadataImporter)) - && GrobidOptInDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences())) { + && GrobidPreferenceDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences())) { importFormatReader.reset(); } dialogService.notify(Localization.lang("Importing in %0 format", importer.get().getName()) + "..."); diff --git a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java index 37f33badb6a..ad0d5b77009 100644 --- a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java @@ -161,7 +161,7 @@ public void storeSettings() { filePreferences.setKeepDownloadUrl(shouldkeepDownloadUrl.getValue()); importerPreferences.setDefaultPlainCitationParser(defaultPlainCitationParser.getValue()); grobidPreferences.setGrobidEnabled(grobidEnabledProperty.getValue()); - grobidPreferences.setGrobidOptOut(grobidPreferences.isGrobidOptOut()); + grobidPreferences.setGrobidPreference(grobidPreferences.isGrobidPreference()); grobidPreferences.setGrobidURL(grobidURLProperty.getValue()); doiPreferences.setUseCustom(useCustomDOIProperty.get()); doiPreferences.setDefaultBaseURI(useCustomDOINameProperty.getValue().trim()); diff --git a/src/main/java/org/jabref/logic/importer/util/GrobidPreferences.java b/src/main/java/org/jabref/logic/importer/util/GrobidPreferences.java index c58c84b4bcd..4470cbe821d 100644 --- a/src/main/java/org/jabref/logic/importer/util/GrobidPreferences.java +++ b/src/main/java/org/jabref/logic/importer/util/GrobidPreferences.java @@ -7,14 +7,14 @@ public class GrobidPreferences { private final BooleanProperty grobidEnabled; - private final BooleanProperty grobidOptOut; + private final BooleanProperty grobidPreference; private final StringProperty grobidURL; public GrobidPreferences(boolean grobidEnabled, - boolean grobidOptOut, + boolean grobidPreference, String grobidURL) { this.grobidEnabled = new SimpleBooleanProperty(grobidEnabled); - this.grobidOptOut = new SimpleBooleanProperty(grobidOptOut); + this.grobidPreference = new SimpleBooleanProperty(grobidPreference); this.grobidURL = new SimpleStringProperty(grobidURL); } @@ -30,17 +30,17 @@ public void setGrobidEnabled(boolean grobidEnabled) { this.grobidEnabled.set(grobidEnabled); } - // region: optout; models "Do not ask again" option - public boolean isGrobidOptOut() { - return grobidOptOut.get(); + // region: preference; models "Save Preference" option + public boolean isGrobidPreference() { + return grobidPreference.get(); } - public BooleanProperty grobidOptOutProperty() { - return grobidOptOut; + public BooleanProperty grobidPreferenceProperty() { + return grobidPreference; } - public void setGrobidOptOut(boolean grobidOptOut) { - this.grobidOptOut.set(grobidOptOut); + public void setGrobidPreference(boolean grobidPreference) { + this.grobidPreference.set(grobidPreference); } // endregion: optout diff --git a/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java b/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java index 79492a8f72c..2e175405c1b 100644 --- a/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java +++ b/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java @@ -220,7 +220,7 @@ public class JabRefCliPreferences implements CliPreferences { public static final String IMPORTERS_ENABLED = "importersEnabled"; public static final String GENERATE_KEY_ON_IMPORT = "generateKeyOnImport"; public static final String GROBID_ENABLED = "grobidEnabled"; - public static final String GROBID_OPT_OUT = "grobidOptOut"; + public static final String GROBID_PREFERENCE = "grobidPreference"; public static final String GROBID_URL = "grobidURL"; public static final String DEFAULT_CITATION_KEY_PATTERN = "defaultBibtexKeyPattern"; @@ -451,7 +451,7 @@ protected JabRefCliPreferences() { // region: Grobid defaults.put(GROBID_ENABLED, Boolean.FALSE); - defaults.put(GROBID_OPT_OUT, Boolean.FALSE); + defaults.put(GROBID_PREFERENCE, Boolean.FALSE); defaults.put(GROBID_URL, "http://grobid.jabref.org:8070"); // endregion @@ -2174,11 +2174,11 @@ public GrobidPreferences getGrobidPreferences() { grobidPreferences = new GrobidPreferences( getBoolean(GROBID_ENABLED), - getBoolean(GROBID_OPT_OUT), + getBoolean(GROBID_PREFERENCE), get(GROBID_URL)); EasyBind.listen(grobidPreferences.grobidEnabledProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_ENABLED, newValue)); - EasyBind.listen(grobidPreferences.grobidOptOutProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_OPT_OUT, newValue)); + EasyBind.listen(grobidPreferences.grobidPreferenceProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_PREFERENCE, newValue)); EasyBind.listen(grobidPreferences.grobidURLProperty(), (obs, oldValue, newValue) -> put(GROBID_URL, newValue)); return grobidPreferences; From 0e0ec95f31ddfc5ac37efdef65cb54bd1cbe0143 Mon Sep 17 00:00:00 2001 From: Arsh Chawla Date: Sun, 20 Oct 2024 10:45:19 +1100 Subject: [PATCH 2/8] Removed checkbox entirely, dialog logic updated such that users will only be asked about Grobid permissions once, with the preference being stored for the future. Updated CHANGELOG.md --- CHANGELOG.md | 1 + .../importer/GrobidPreferenceDialogHelper.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa487a1574a..178ffb528f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where recently opened files were not displayed in the main menu properly. [#9042](https://github.com/JabRef/jabref/issues/9042) - We fixed an issue where the DOI lookup would show an error when a DOI was found for an entry. [#11850](https://github.com/JabRef/jabref/issues/11850) - We fixed an issue where Tab cannot be used to jump to next field in some single-line fields. [#11785](https://github.com/JabRef/jabref/issues/11785) +- We fixed an issue where the "Do not ask again" checkbox was not working, when asking for permission to use Grobid. ### Removed diff --git a/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java b/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java index 8d391f895f0..298bbc0ea26 100644 --- a/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java +++ b/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java @@ -7,27 +7,27 @@ /** * Metadata extraction from PDFs and plaintext works very well using Grobid, but we do not want to enable it by default * due to data privacy concerns. - * To make users aware of the feature, we ask each time before querying Grobid, giving the option to opt-out. + * To make users aware of the feature, we ask before querying Grobid, saving the users' preference for the future. */ public class GrobidPreferenceDialogHelper { /** - * If Grobid is not enabled but the user has not explicitly opted-out of Grobid, we ask for permission to send data - * to Grobid by using a dialog and giving an explicit 'save preference' option. + * If the user has not explicitly opted-in/out of Grobid, we ask for permission to send data to Grobid by using + * a dialog. The users' preference is saved. * * @param dialogService the DialogService to use - * @return if the user enabled Grobid, either in the past or after being asked by the dialog, save preference - * if specified. + * @return if the user enabled Grobid, either in the past or after being asked by the dialog. */ public static boolean showAndWaitIfUserIsUndecided(DialogService dialogService, GrobidPreferences preferences) { if (preferences.isGrobidPreference()) { return preferences.isGrobidEnabled(); } - boolean grobidEnabled = dialogService.showConfirmationDialogWithOptOutAndWait( + boolean grobidEnabled = dialogService.showConfirmationDialogAndWait( Localization.lang("Remote services"), Localization.lang("Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results."), - Localization.lang("Save Preference"), - preferences::setGrobidPreference); + Localization.lang("Yes"), + Localization.lang("No")); + preferences.setGrobidPreference(true); preferences.setGrobidEnabled(grobidEnabled); return grobidEnabled; } From e254b756e14e8f8acef4d1f5204a75f49ce84749 Mon Sep 17 00:00:00 2001 From: Arsh Chawla Date: Sun, 27 Oct 2024 08:56:06 +1100 Subject: [PATCH 3/8] Updated dialog wording to be 'Send to Grobid' and 'Do not send' to improve clarity. --- .../org/jabref/gui/importer/GrobidPreferenceDialogHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java b/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java index 298bbc0ea26..838255ba656 100644 --- a/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java +++ b/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java @@ -25,8 +25,8 @@ public static boolean showAndWaitIfUserIsUndecided(DialogService dialogService, boolean grobidEnabled = dialogService.showConfirmationDialogAndWait( Localization.lang("Remote services"), Localization.lang("Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results."), - Localization.lang("Yes"), - Localization.lang("No")); + Localization.lang("Send to Grobid"), + Localization.lang("Do not send")); preferences.setGrobidPreference(true); preferences.setGrobidEnabled(grobidEnabled); return grobidEnabled; From 11603595a66b3b8dff1b5dd9bde15b976c8eaf97 Mon Sep 17 00:00:00 2001 From: Arsh Chawla Date: Sun, 27 Oct 2024 09:21:48 +1100 Subject: [PATCH 4/8] Refactored grobidPreference boolean to grobidUseAsked to improve clarity. Renamed GrobidPreferenceDialogHelper.java to GrobidUseDialogHelper.java. --- .../jabref/gui/entryeditor/EntryEditor.java | 4 ++-- .../gui/fieldeditors/LinkedFilesEditor.java | 4 ++-- ...Helper.java => GrobidUseDialogHelper.java} | 8 +++---- .../jabref/gui/importer/ImportCommand.java | 4 ++-- .../websearch/WebSearchTabViewModel.java | 2 +- .../importer/util/GrobidPreferences.java | 22 +++++++++---------- .../preferences/JabRefCliPreferences.java | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) rename src/main/java/org/jabref/gui/importer/{GrobidPreferenceDialogHelper.java => GrobidUseDialogHelper.java} (84%) diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 4f02c61dc6e..57f050e4274 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -37,7 +37,7 @@ import org.jabref.gui.entryeditor.fileannotationtab.FulltextSearchResultsTab; import org.jabref.gui.externalfiles.ExternalFilesEntryLinker; import org.jabref.gui.help.HelpAction; -import org.jabref.gui.importer.GrobidPreferenceDialogHelper; +import org.jabref.gui.importer.GrobidUseDialogHelper; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.gui.menus.ChangeEntryTypeMenu; @@ -432,7 +432,7 @@ private void setupToolBar() { if (fetcher instanceof PdfMergeMetadataImporter.EntryBasedFetcherWrapper) { // Handle Grobid Opt-In in case of the PdfMergeMetadataImporter fetcherMenuItem.setOnAction(event -> { - GrobidPreferenceDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences()); + GrobidUseDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences()); PdfMergeMetadataImporter.EntryBasedFetcherWrapper pdfMergeMetadataImporter = new PdfMergeMetadataImporter.EntryBasedFetcherWrapper( preferences.getImportFormatPreferences(), diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java index ca7d95bd2a6..ea30f18d3c9 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java @@ -41,7 +41,7 @@ import org.jabref.gui.copyfiles.CopySingleFileAction; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.icon.JabRefIconView; -import org.jabref.gui.importer.GrobidPreferenceDialogHelper; +import org.jabref.gui.importer.GrobidUseDialogHelper; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.linkedfile.DeleteFileAction; import org.jabref.gui.linkedfile.LinkedFileEditDialog; @@ -236,7 +236,7 @@ private Node createFileDisplay(LinkedFileViewModel linkedFile) { parsePdfMetadata.setTooltip(new Tooltip(Localization.lang("Parse Metadata from PDF."))); parsePdfMetadata.visibleProperty().bind(linkedFile.isOfflinePdfProperty()); parsePdfMetadata.setOnAction(event -> { - GrobidPreferenceDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences()); + GrobidUseDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences()); linkedFile.parsePdfMetadataAndShowMergeDialog(); }); parsePdfMetadata.getStyleClass().setAll("icon-button"); diff --git a/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java b/src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java similarity index 84% rename from src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java rename to src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java index 838255ba656..64c25200825 100644 --- a/src/main/java/org/jabref/gui/importer/GrobidPreferenceDialogHelper.java +++ b/src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java @@ -7,9 +7,9 @@ /** * Metadata extraction from PDFs and plaintext works very well using Grobid, but we do not want to enable it by default * due to data privacy concerns. - * To make users aware of the feature, we ask before querying Grobid, saving the users' preference for the future. + * To make users aware of the feature, we ask before querying for the first time Grobid, saving the users' preference */ -public class GrobidPreferenceDialogHelper { +public class GrobidUseDialogHelper { /** * If the user has not explicitly opted-in/out of Grobid, we ask for permission to send data to Grobid by using @@ -19,7 +19,7 @@ public class GrobidPreferenceDialogHelper { * @return if the user enabled Grobid, either in the past or after being asked by the dialog. */ public static boolean showAndWaitIfUserIsUndecided(DialogService dialogService, GrobidPreferences preferences) { - if (preferences.isGrobidPreference()) { + if (preferences.isGrobidUseAsked()) { return preferences.isGrobidEnabled(); } boolean grobidEnabled = dialogService.showConfirmationDialogAndWait( @@ -27,7 +27,7 @@ public static boolean showAndWaitIfUserIsUndecided(DialogService dialogService, Localization.lang("Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results."), Localization.lang("Send to Grobid"), Localization.lang("Do not send")); - preferences.setGrobidPreference(true); + preferences.setGrobidUseAsked(true); preferences.setGrobidEnabled(grobidEnabled); return grobidEnabled; } diff --git a/src/main/java/org/jabref/gui/importer/ImportCommand.java b/src/main/java/org/jabref/gui/importer/ImportCommand.java index d74ba47d775..896ef2a6145 100644 --- a/src/main/java/org/jabref/gui/importer/ImportCommand.java +++ b/src/main/java/org/jabref/gui/importer/ImportCommand.java @@ -144,7 +144,7 @@ private ParserResult doImport(List files, Importer importFormat) throws IO if (importer.isEmpty()) { // Unknown format UiTaskExecutor.runAndWaitInJavaFXThread(() -> { - if (FileUtil.isPDFFile(filename) && GrobidPreferenceDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences())) { + if (FileUtil.isPDFFile(filename) && GrobidUseDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences())) { importFormatReader.reset(); } dialogService.notify(Localization.lang("Importing file %0 as unknown format", filename.getFileName().toString())); @@ -155,7 +155,7 @@ private ParserResult doImport(List files, Importer importFormat) throws IO UiTaskExecutor.runAndWaitInJavaFXThread(() -> { if (((importer.get() instanceof PdfGrobidImporter) || (importer.get() instanceof PdfMergeMetadataImporter)) - && GrobidPreferenceDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences())) { + && GrobidUseDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences())) { importFormatReader.reset(); } dialogService.notify(Localization.lang("Importing in %0 format", importer.get().getName()) + "..."); diff --git a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java index bae8f6311cf..06907a2bcb8 100644 --- a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java @@ -164,7 +164,7 @@ public void storeSettings() { filePreferences.setKeepDownloadUrl(shouldkeepDownloadUrl.getValue()); importerPreferences.setDefaultPlainCitationParser(defaultPlainCitationParser.getValue()); grobidPreferences.setGrobidEnabled(grobidEnabledProperty.getValue()); - grobidPreferences.setGrobidPreference(grobidPreferences.isGrobidPreference()); + grobidPreferences.setGrobidUseAsked(grobidPreferences.isGrobidUseAsked()); grobidPreferences.setGrobidURL(grobidURLProperty.getValue()); doiPreferences.setUseCustom(useCustomDOIProperty.get()); doiPreferences.setDefaultBaseURI(useCustomDOINameProperty.getValue().trim()); diff --git a/src/main/java/org/jabref/logic/importer/util/GrobidPreferences.java b/src/main/java/org/jabref/logic/importer/util/GrobidPreferences.java index 4470cbe821d..04de98b71d9 100644 --- a/src/main/java/org/jabref/logic/importer/util/GrobidPreferences.java +++ b/src/main/java/org/jabref/logic/importer/util/GrobidPreferences.java @@ -7,14 +7,14 @@ public class GrobidPreferences { private final BooleanProperty grobidEnabled; - private final BooleanProperty grobidPreference; + private final BooleanProperty grobidUseAsked; private final StringProperty grobidURL; public GrobidPreferences(boolean grobidEnabled, - boolean grobidPreference, + boolean grobidUseAsked, String grobidURL) { this.grobidEnabled = new SimpleBooleanProperty(grobidEnabled); - this.grobidPreference = new SimpleBooleanProperty(grobidPreference); + this.grobidUseAsked = new SimpleBooleanProperty(grobidUseAsked); this.grobidURL = new SimpleStringProperty(grobidURL); } @@ -30,19 +30,19 @@ public void setGrobidEnabled(boolean grobidEnabled) { this.grobidEnabled.set(grobidEnabled); } - // region: preference; models "Save Preference" option - public boolean isGrobidPreference() { - return grobidPreference.get(); + // region: GrobidUseAsked; + public boolean isGrobidUseAsked() { + return grobidUseAsked.get(); } - public BooleanProperty grobidPreferenceProperty() { - return grobidPreference; + public BooleanProperty grobidUseAskedProperty() { + return grobidUseAsked; } - public void setGrobidPreference(boolean grobidPreference) { - this.grobidPreference.set(grobidPreference); + public void setGrobidUseAsked(boolean grobidUseAsked) { + this.grobidUseAsked.set(grobidUseAsked); } - // endregion: optout + // endregion: GrobidUseAsked public String getGrobidURL() { return grobidURL.get(); diff --git a/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java b/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java index 2e175405c1b..7383921d23b 100644 --- a/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java +++ b/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java @@ -2178,7 +2178,7 @@ public GrobidPreferences getGrobidPreferences() { get(GROBID_URL)); EasyBind.listen(grobidPreferences.grobidEnabledProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_ENABLED, newValue)); - EasyBind.listen(grobidPreferences.grobidPreferenceProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_PREFERENCE, newValue)); + EasyBind.listen(grobidPreferences.grobidUseAskedProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_PREFERENCE, newValue)); EasyBind.listen(grobidPreferences.grobidURLProperty(), (obs, oldValue, newValue) -> put(GROBID_URL, newValue)); return grobidPreferences; From 123449d2323663809d2d0834ca8647bb50beb19a Mon Sep 17 00:00:00 2001 From: Arsh Chawla <150571042+arshchawla21@users.noreply.github.com> Date: Sun, 27 Oct 2024 11:08:50 +1100 Subject: [PATCH 5/8] Update CHANGELOG.md Co-authored-by: Christoph --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 372c83c1c5d..203eb95a842 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,7 +100,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where recently opened files were not displayed in the main menu properly. [#9042](https://github.com/JabRef/jabref/issues/9042) - We fixed an issue where the DOI lookup would show an error when a DOI was found for an entry. [#11850](https://github.com/JabRef/jabref/issues/11850) - We fixed an issue where Tab cannot be used to jump to next field in some single-line fields. [#11785](https://github.com/JabRef/jabref/issues/11785) -- We fixed an issue where the "Do not ask again" checkbox was not working, when asking for permission to use Grobid. +- We fixed an issue where the "Do not ask again" checkbox was not working, when asking for permission to use Grobid [koppor#556](https://github.com/koppor/jabref/issues/566). - We fixed an issue where we display warning message for moving attached open files. [#10121](https://github.com/JabRef/jabref/issues/10121) - We fixed an issue where it was not possible to select selecting content of other user's comments.[#11106](https://github.com/JabRef/jabref/issues/11106) - We fixed an issue where web search preferences "Custom API key" table modifications not discarded. [#11925](https://github.com/JabRef/jabref/issues/11925) From 3edfb38edc90c26e36b7cb1b4b9f780e7b1b0163 Mon Sep 17 00:00:00 2001 From: Arsh Chawla Date: Sun, 27 Oct 2024 12:33:15 +1100 Subject: [PATCH 6/8] Updated JabRef_en.properties to reflect language keys: "Send to Grobid" and "Do not send". --- src/main/resources/l10n/JabRef_en.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 94119350460..20c0d3f015a 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2804,3 +2804,6 @@ Citation\ Entry=Citation Entry File\ Move\ Errors=File Move Errors Could\ not\ move\ file\ %0.\ Please\ close\ this\ file\ and\ retry.=Could not move file %0. Please close this file and retry. + +Send\ to\ Grobid=Send to Grobid +Do\ not\ send=Do not send From 420f940ece91d23f2861f828ea66f9545bdb29ad Mon Sep 17 00:00:00 2001 From: Arsh Chawla Date: Mon, 28 Oct 2024 07:14:33 +1100 Subject: [PATCH 7/8] Modified Grobid dialog logic such that users are not prompted to enable Grobid on first use, if Grobid has already been manually enabled. --- .../java/org/jabref/gui/importer/GrobidUseDialogHelper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java b/src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java index 64c25200825..e5c55dd51ba 100644 --- a/src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java +++ b/src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java @@ -22,6 +22,10 @@ public static boolean showAndWaitIfUserIsUndecided(DialogService dialogService, if (preferences.isGrobidUseAsked()) { return preferences.isGrobidEnabled(); } + if (preferences.isGrobidEnabled()) { + preferences.setGrobidUseAsked(true); + return preferences.isGrobidEnabled(); + } boolean grobidEnabled = dialogService.showConfirmationDialogAndWait( Localization.lang("Remote services"), Localization.lang("Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results."), From 76173e58761b059154324ada9a480cbb22bde4b9 Mon Sep 17 00:00:00 2001 From: Arsh Chawla <150571042+arshchawla21@users.noreply.github.com> Date: Mon, 28 Oct 2024 07:48:29 +1100 Subject: [PATCH 8/8] Update src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java Co-authored-by: Loay Ghreeb --- .../java/org/jabref/gui/importer/GrobidUseDialogHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java b/src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java index e5c55dd51ba..352f37b7a85 100644 --- a/src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java +++ b/src/main/java/org/jabref/gui/importer/GrobidUseDialogHelper.java @@ -24,7 +24,7 @@ public static boolean showAndWaitIfUserIsUndecided(DialogService dialogService, } if (preferences.isGrobidEnabled()) { preferences.setGrobidUseAsked(true); - return preferences.isGrobidEnabled(); + return true; } boolean grobidEnabled = dialogService.showConfirmationDialogAndWait( Localization.lang("Remote services"),