From 2af4fa40f74a379d62368b1e0e1a5d31dc9b1570 Mon Sep 17 00:00:00 2001 From: Hana Chaari Date: Tue, 21 Mar 2023 12:45:45 +0100 Subject: [PATCH 01/11] Remote services config panel UI --- .../RemoteServicesConfigPanel.fxml | 21 +++++++++++++++++++ .../RemoteServicesConfigPanel.java | 4 ++++ .../RemoteServicesConfigPanelViewModel.java | 4 ++++ .../importexport/ImportExportTab.fxml | 5 +++++ src/main/resources/l10n/JabRef_en.properties | 4 +++- 5 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.fxml create mode 100644 src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java create mode 100644 src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.fxml b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.fxml new file mode 100644 index 00000000000..3ce8887fa38 --- /dev/null +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.fxml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java new file mode 100644 index 00000000000..eec7fc84017 --- /dev/null +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java @@ -0,0 +1,4 @@ +package org.jabref.gui.commonfxcontrols; + +public class RemoteServicesConfigPanel { +} diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java new file mode 100644 index 00000000000..34541c84b17 --- /dev/null +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java @@ -0,0 +1,4 @@ +package org.jabref.gui.commonfxcontrols; + +public class RemoteServicesConfigPanelViewModel { +} diff --git a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.fxml b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.fxml index c698a797910..7785c01a42d 100644 --- a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.fxml +++ b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.fxml @@ -9,6 +9,8 @@ + + @@ -28,6 +30,9 @@ diff --git a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java b/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java index 967a58d1045..b9333f0bf22 100644 --- a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java +++ b/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java @@ -34,8 +34,10 @@ public static boolean showAndWaitIfUserIsUndecided(DialogService dialogService, 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.grobidOptOutProperty().setValue(optOut)); + (optOut) -> preferences.grobidDemandedProperty().setValue(!optOut)); + preferences.grobidEnabledProperty().setValue(grobidEnabled); + preferences.grobidOptOutProperty().setValue(!grobidEnabled); return grobidEnabled; } } diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 263d3e5c612..055d600a5a9 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2434,7 +2434,7 @@ Remote\ services=Remote services Allow\ sending\ PDF\ files\ and\ raw\ citation\ strings\ to\ a\ JabRef\ online\ service\ (Grobid)\ to\ determine\ Metadata.\ This\ produces\ better\ results.=Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results. Always\ enable\ Gorbid=Always enable Gorbid Always\ disable\ Gorbid=Always disable Gorbid -Always\ Ask=Always Ask +Always\ ask=Always ask Fetcher\ cannot\ be\ tested\!=Fetcher cannot be tested! Fetcher\ unknown\!=Fetcher unknown! diff --git a/src/test/java/org/jabref/logic/importer/fetcher/GrobidCitationFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/GrobidCitationFetcherTest.java index 2852909d212..d299c0cd389 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/GrobidCitationFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/GrobidCitationFetcherTest.java @@ -35,6 +35,7 @@ public class GrobidCitationFetcherTest { static GrobidPreferences grobidPreferences = new GrobidPreferences( true, false, + false, "http://grobid.jabref.org:8070"); static GrobidCitationFetcher grobidCitationFetcher = new GrobidCitationFetcher(grobidPreferences, importFormatPreferences); diff --git a/src/test/java/org/jabref/logic/importer/util/GrobidServiceTest.java b/src/test/java/org/jabref/logic/importer/util/GrobidServiceTest.java index 69c3693f2d1..826eb3eebcf 100644 --- a/src/test/java/org/jabref/logic/importer/util/GrobidServiceTest.java +++ b/src/test/java/org/jabref/logic/importer/util/GrobidServiceTest.java @@ -40,6 +40,7 @@ public static void setup() { GrobidPreferences grobidPreferences = new GrobidPreferences( true, false, + false, "http://grobid.jabref.org:8070"); grobidService = new GrobidService(grobidPreferences); } @@ -85,6 +86,7 @@ public void failsWhenGrobidDisabled() { GrobidPreferences importSettingsWithGrobidDisabled = new GrobidPreferences( false, false, + true, "http://grobid.jabref.org:8070"); assertThrows(UnsupportedOperationException.class, () -> new GrobidService(importSettingsWithGrobidDisabled)); } From fff80df61b1b2f6e24062734a9ecd947644debb5 Mon Sep 17 00:00:00 2001 From: Hana Chaari Date: Tue, 25 Apr 2023 20:13:55 +0100 Subject: [PATCH 08/11] fixed a spelling mistake --- .../gui/commonfxcontrols/RemoteServicesConfigPanel.fxml | 4 ++-- src/main/resources/l10n/JabRef_en.properties | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.fxml b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.fxml index f3b707d58bf..9dff4dfed08 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.fxml +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.fxml @@ -9,9 +9,9 @@ - - diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 055d600a5a9..12a4c2afd98 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2432,8 +2432,8 @@ Found\ matches\ in\ Annotations\:=Found matches in Annotations: Grobid\ URL=Grobid URL Remote\ services=Remote services Allow\ sending\ PDF\ files\ and\ raw\ citation\ strings\ to\ a\ JabRef\ online\ service\ (Grobid)\ to\ determine\ Metadata.\ This\ produces\ better\ results.=Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results. -Always\ enable\ Gorbid=Always enable Gorbid -Always\ disable\ Gorbid=Always disable Gorbid +Always\ enable\ Grobid=Always enable Grobid +Always\ disable\ Grobid=Always disable Grobid Always\ ask=Always ask Fetcher\ cannot\ be\ tested\!=Fetcher cannot be tested! Fetcher\ unknown\!=Fetcher unknown! From 22e872b3cf3b1b891bb4bedf058e7279f128ce54 Mon Sep 17 00:00:00 2001 From: Hana Chaari Date: Tue, 25 Apr 2023 21:01:09 +0100 Subject: [PATCH 09/11] fixing checkstyle errors reported by reviewdog --- .../RemoteServicesConfigPanel.java | 10 ++++------ .../RemoteServicesConfigPanelViewModel.java | 4 ++-- .../gui/importer/GrobidOptInDialogHelper.java | 3 +-- .../importexport/ImportExportTabViewModel.java | 15 +++++---------- .../logic/importer/fetcher/GrobidPreferences.java | 1 - 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java index 902f94ef8bd..96556506329 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java @@ -7,8 +7,7 @@ import javafx.scene.layout.VBox; -public class -RemoteServicesConfigPanel extends VBox { +public class RemoteServicesConfigPanel extends VBox { @FXML private RadioButton gorbidEnabled; @FXML private RadioButton gorbidDisabled; @FXML private RadioButton gorbidDemanded; @@ -27,17 +26,16 @@ private void initialize() { gorbidDisabled.selectedProperty().bindBidirectional(viewModel.gorbidDisabledProperty()); gorbidDemanded.selectedProperty().bindBidirectional(viewModel.gorbidDemandedProperty()); } + public BooleanProperty gorbidEnabledProperty() { return viewModel.gorbidEnabledProperty(); } + public BooleanProperty gorbidDisabledProperty() { return viewModel.gorbidDisabledProperty(); } + public BooleanProperty gorbidDemandedProperty() { return viewModel.gorbidDemandedProperty(); } - - - - } diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java index d0d6ef4f523..db7e3e51409 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java @@ -11,12 +11,12 @@ public class RemoteServicesConfigPanelViewModel { public BooleanProperty gorbidEnabledProperty() { return gorbidEnabledProperty; } + public BooleanProperty gorbidDisabledProperty() { return gorbidDisabledProperty; } + public BooleanProperty gorbidDemandedProperty() { return gorbidDemandedProperty; } - - } diff --git a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java b/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java index b9333f0bf22..12045d720a6 100644 --- a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java +++ b/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java @@ -19,8 +19,7 @@ public class GrobidOptInDialogHelper { * @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) { - //new code// - if (preferences.isGrobidDemanded()){ + if (preferences.isGrobidDemanded()) { preferences.grobidEnabledProperty().setValue(false); preferences.grobidOptOutProperty().setValue(false); } diff --git a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTabViewModel.java b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTabViewModel.java index 76c39fd9f15..dccd6f27315 100644 --- a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTabViewModel.java @@ -53,16 +53,12 @@ public class ImportExportTabViewModel implements PreferenceTabViewModel { private final BooleanProperty exportInOriginalProperty = new SimpleBooleanProperty(); private final BooleanProperty exportInTableOrderProperty = new SimpleBooleanProperty(); private final BooleanProperty exportInSpecifiedOrderProperty = new SimpleBooleanProperty(); - //private final BooleanProperty gorbidEnabledProperty = new SimpleBooleanProperty(); - private final ListProperty sortableFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList()); private final ListProperty sortCriteriaProperty = new SimpleListProperty<>(FXCollections.observableArrayList(new ArrayList<>())); -//remove private final BooleanProperty grobidEnabledProperty = new SimpleBooleanProperty(); private final BooleanProperty grobidDisabledProperty = new SimpleBooleanProperty(); private final BooleanProperty grobidDemandedProperty = new SimpleBooleanProperty(); private final StringProperty grobidURLProperty = new SimpleStringProperty(""); - //remove private final BooleanProperty warnAboutDuplicatesOnImportProperty = new SimpleBooleanProperty(); private final BooleanProperty shouldDownloadLinkedOnlineFiles = new SimpleBooleanProperty(); @@ -109,14 +105,9 @@ public void setValues() { .map(SortCriterionViewModel::new) .toList()); -//remove - - grobidEnabledProperty.setValue(grobidPreferences.isGrobidEnabled()); grobidDisabledProperty.setValue(grobidPreferences.isGrobidOptOut()); grobidDemandedProperty.setValue(grobidPreferences.isGrobidDemanded()); - - grobidURLProperty.setValue(grobidPreferences.getGrobidURL()); apiKeys.setValue(FXCollections.observableArrayList(preferencesService.getImporterPreferences().getApiKeys())); @@ -185,10 +176,14 @@ public ListProperty sortCriteriaProperty() { public BooleanProperty grobidEnabledProperty() { return grobidEnabledProperty; } + public BooleanProperty grobidDisabledProperty() { return grobidDisabledProperty; } - public BooleanProperty grobidDemandedProperty() { return grobidDemandedProperty; } + + public BooleanProperty grobidDemandedProperty() { + return grobidDemandedProperty; + } public StringProperty grobidURLProperty() { return grobidURLProperty; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/GrobidPreferences.java b/src/main/java/org/jabref/logic/importer/fetcher/GrobidPreferences.java index 9a97740ad79..e6f05586aa7 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/GrobidPreferences.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/GrobidPreferences.java @@ -45,7 +45,6 @@ public void setGrobidOptOut(boolean grobidOptOut) { this.grobidOptOut.set(grobidOptOut); } - public boolean isGrobidDemanded() { return grobidDemanded.get(); } From 5cdcf83673bdfe353eb90806987b34d43a3295a1 Mon Sep 17 00:00:00 2001 From: Hana Chaari Date: Tue, 25 Apr 2023 21:17:47 +0100 Subject: [PATCH 10/11] fixing checkstyle errors reported by reviewdog part2 --- .../jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java | 3 +-- .../jabref/gui/preferences/importexport/ImportExportTab.java | 1 - .../org/jabref/logic/importer/fetcher/GrobidPreferences.java | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java index 96556506329..6e3f11e7dd6 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java @@ -1,11 +1,10 @@ package org.jabref.gui.commonfxcontrols; -import com.airhacks.afterburner.views.ViewLoader; import javafx.beans.property.BooleanProperty; import javafx.fxml.FXML; import javafx.scene.control.RadioButton; import javafx.scene.layout.VBox; - +import com.airhacks.afterburner.views.ViewLoader; public class RemoteServicesConfigPanel extends VBox { @FXML private RadioButton gorbidEnabled; diff --git a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java index 427d0ac304c..e6bb557ad0c 100644 --- a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java +++ b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java @@ -66,7 +66,6 @@ public void initialize() { RemoteServicesConfigPanel.gorbidDisabledProperty().bindBidirectional(viewModel.grobidDisabledProperty()); RemoteServicesConfigPanel.gorbidEnabledProperty().bindBidirectional(viewModel.grobidEnabledProperty()); - grobidURL.textProperty().bindBidirectional(viewModel.grobidURLProperty()); grobidURL.disableProperty().bind(viewModel.grobidEnabledProperty().not()); diff --git a/src/main/java/org/jabref/logic/importer/fetcher/GrobidPreferences.java b/src/main/java/org/jabref/logic/importer/fetcher/GrobidPreferences.java index e6f05586aa7..9fa7eb288a3 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/GrobidPreferences.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/GrobidPreferences.java @@ -57,7 +57,6 @@ public void setGrobidDemanded(boolean grobidDemanded) { this.grobidDemanded.set(grobidDemanded); } - public String getGrobidURL() { return grobidURL.get(); } From e880eb4d6aa69631a37215c463d3fe518d050053 Mon Sep 17 00:00:00 2001 From: Hana Chaari Date: Tue, 25 Apr 2023 21:25:01 +0100 Subject: [PATCH 11/11] fixing checkstyle errors reported by reviewdog part3 --- .../jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java index 6e3f11e7dd6..fb3bd29aa03 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java @@ -4,6 +4,7 @@ import javafx.fxml.FXML; import javafx.scene.control.RadioButton; import javafx.scene.layout.VBox; + import com.airhacks.afterburner.views.ViewLoader; public class RemoteServicesConfigPanel extends VBox {