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/commonfxcontrols/RemoteServicesConfigPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java index 902f94ef8bd..2486dfd531c 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java @@ -11,7 +11,6 @@ RemoteServicesConfigPanel extends VBox { @FXML private RadioButton gorbidEnabled; @FXML private RadioButton gorbidDisabled; - @FXML private RadioButton gorbidDemanded; private RemoteServicesConfigPanelViewModel viewModel; public RemoteServicesConfigPanel() { @@ -25,7 +24,6 @@ private void initialize() { viewModel = new RemoteServicesConfigPanelViewModel(); gorbidEnabled.selectedProperty().bindBidirectional(viewModel.gorbidEnabledProperty()); gorbidDisabled.selectedProperty().bindBidirectional(viewModel.gorbidDisabledProperty()); - gorbidDemanded.selectedProperty().bindBidirectional(viewModel.gorbidDemandedProperty()); } public BooleanProperty gorbidEnabledProperty() { return viewModel.gorbidEnabledProperty(); @@ -33,9 +31,6 @@ public BooleanProperty 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..cc6b3502c27 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java @@ -6,7 +6,6 @@ public class RemoteServicesConfigPanelViewModel { private final BooleanProperty gorbidEnabledProperty = new SimpleBooleanProperty(); private final BooleanProperty gorbidDisabledProperty = new SimpleBooleanProperty(); - private final BooleanProperty gorbidDemandedProperty = new SimpleBooleanProperty(); public BooleanProperty gorbidEnabledProperty() { return gorbidEnabledProperty; @@ -14,9 +13,6 @@ public BooleanProperty 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 ca025064aaa..d93d524d410 100644 --- a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java +++ b/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java @@ -35,7 +35,9 @@ 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.") ); - preferences.grobidOptOutProperty().setValue(grobidEnabled); + preferences.grobidEnabledProperty().setValue(grobidEnabled); + preferences.grobidOptOutProperty().setValue(!grobidEnabled); + preferences.grobidDemandedProperty().setValue(false); return grobidEnabled; } } 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..0fccbdab2c7 100644 --- a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java +++ b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java @@ -62,7 +62,6 @@ public void initialize() { exportOrderPanel.sortCriteriaProperty().bindBidirectional(viewModel.sortCriteriaProperty()); exportOrderPanel.setCriteriaLimit(3); - RemoteServicesConfigPanel.gorbidDemandedProperty().bindBidirectional(viewModel.grobidDemandedProperty()); RemoteServicesConfigPanel.gorbidDisabledProperty().bindBidirectional(viewModel.grobidDisabledProperty()); RemoteServicesConfigPanel.gorbidEnabledProperty().bindBidirectional(viewModel.grobidEnabledProperty()); diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index ea2d14db5e4..dcd646fa994 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -268,7 +268,6 @@ public class JabRefPreferences implements PreferencesService { 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_DEMANDED = "grobidDemanded"; public static final String GROBID_URL = "grobidURL"; diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 2f2044ba46a..43bc7e43cd8 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2432,9 +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\ Grobid=Always enable Grobid -Always\ disable\ Grobid=Always disable Grobid -Always\ Ask=Always Ask +Disable\ GROBID=Disable GROBID +Enable\ GROBID=Enable GROBID Fetcher\ cannot\ be\ tested\!=Fetcher cannot be tested! Fetcher\ unknown\!=Fetcher unknown! From e22bec4a483ce13701dcfbe00258030a0fe31cda Mon Sep 17 00:00:00 2001 From: Hana Chaari Date: Fri, 28 Apr 2023 11:38:44 +0100 Subject: [PATCH 10/11] fix 1 checkstyle test --- .../RemoteServicesConfigPanel.java | 3 ++- .../RemoteServicesConfigPanelViewModel.java | 1 + .../gui/importer/GrobidOptInDialogHelper.java | 3 +-- .../importexport/ImportExportTabViewModel.java | 15 +++++---------- .../logic/importer/fetcher/GrobidPreferences.java | 2 -- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java index 2486dfd531c..eb4b9df32d6 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java @@ -6,7 +6,6 @@ import javafx.scene.control.RadioButton; import javafx.scene.layout.VBox; - public class RemoteServicesConfigPanel extends VBox { @FXML private RadioButton gorbidEnabled; @@ -25,9 +24,11 @@ private void initialize() { gorbidEnabled.selectedProperty().bindBidirectional(viewModel.gorbidEnabledProperty()); gorbidDisabled.selectedProperty().bindBidirectional(viewModel.gorbidDisabledProperty()); } + public BooleanProperty gorbidEnabledProperty() { return viewModel.gorbidEnabledProperty(); } + public BooleanProperty gorbidDisabledProperty() { return viewModel.gorbidDisabledProperty(); } diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java index cc6b3502c27..2d7bab06ca9 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java @@ -10,6 +10,7 @@ public class RemoteServicesConfigPanelViewModel { public BooleanProperty gorbidEnabledProperty() { return gorbidEnabledProperty; } + public BooleanProperty gorbidDisabledProperty() { return gorbidDisabledProperty; } diff --git a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java b/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java index d93d524d410..d77d68873c6 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..5875b1c7477 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,9 +105,6 @@ public void setValues() { .map(SortCriterionViewModel::new) .toList()); -//remove - - grobidEnabledProperty.setValue(grobidPreferences.isGrobidEnabled()); grobidDisabledProperty.setValue(grobidPreferences.isGrobidOptOut()); grobidDemandedProperty.setValue(grobidPreferences.isGrobidDemanded()); @@ -160,8 +153,6 @@ public StringProperty useCustomDOINameProperty() { return this.useCustomDOINameProperty; } - // SaveOrderConfigPanel - public BooleanProperty saveInOriginalProperty() { return exportInOriginalProperty; } @@ -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..9fa7eb288a3 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(); } @@ -58,7 +57,6 @@ public void setGrobidDemanded(boolean grobidDemanded) { this.grobidDemanded.set(grobidDemanded); } - public String getGrobidURL() { return grobidURL.get(); } From c2a3b2a3eb0a138375b84cbbadaaf89665bdcff0 Mon Sep 17 00:00:00 2001 From: Hana Chaari Date: Fri, 28 Apr 2023 11:51:58 +0100 Subject: [PATCH 11/11] fix 2 checkstyle test --- .../gui/commonfxcontrols/RemoteServicesConfigPanel.java | 3 --- .../commonfxcontrols/RemoteServicesConfigPanelViewModel.java | 4 +--- .../jabref/gui/preferences/importexport/ImportExportTab.java | 1 - .../preferences/importexport/ImportExportTabViewModel.java | 1 - 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java index eb4b9df32d6..f42ea03c0f4 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java @@ -33,7 +33,4 @@ public BooleanProperty gorbidDisabledProperty() { return viewModel.gorbidDisabledProperty(); } - - - } diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java index 2d7bab06ca9..6335d8fe1dc 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java @@ -1,7 +1,7 @@ package org.jabref.gui.commonfxcontrols; -import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.BooleanProperty; public class RemoteServicesConfigPanelViewModel { private final BooleanProperty gorbidEnabledProperty = new SimpleBooleanProperty(); @@ -14,6 +14,4 @@ public BooleanProperty gorbidEnabledProperty() { public BooleanProperty gorbidDisabledProperty() { return gorbidDisabledProperty; } - - } 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 0fccbdab2c7..9a316e80913 100644 --- a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java +++ b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java @@ -65,7 +65,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/gui/preferences/importexport/ImportExportTabViewModel.java b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTabViewModel.java index 5875b1c7477..e7f730b3226 100644 --- a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTabViewModel.java @@ -109,7 +109,6 @@ public void setValues() { grobidDisabledProperty.setValue(grobidPreferences.isGrobidOptOut()); grobidDemandedProperty.setValue(grobidPreferences.isGrobidDemanded()); - grobidURLProperty.setValue(grobidPreferences.getGrobidURL()); apiKeys.setValue(FXCollections.observableArrayList(preferencesService.getImporterPreferences().getApiKeys()));