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..9dff4dfed08
--- /dev/null
+++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.fxml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
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..fb3bd29aa03
--- /dev/null
+++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanel.java
@@ -0,0 +1,41 @@
+package org.jabref.gui.commonfxcontrols;
+
+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;
+ @FXML private RadioButton gorbidDisabled;
+ @FXML private RadioButton gorbidDemanded;
+ private RemoteServicesConfigPanelViewModel viewModel;
+
+ public RemoteServicesConfigPanel() {
+ ViewLoader.view(this)
+ .root(this)
+ .load();
+ }
+
+ @FXML
+ 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();
+ }
+
+ 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
new file mode 100644
index 00000000000..db7e3e51409
--- /dev/null
+++ b/src/main/java/org/jabref/gui/commonfxcontrols/RemoteServicesConfigPanelViewModel.java
@@ -0,0 +1,22 @@
+package org.jabref.gui.commonfxcontrols;
+
+import javafx.beans.property.BooleanProperty;
+import javafx.beans.property.SimpleBooleanProperty;
+
+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;
+ }
+
+ 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 cf21a38a30c..12045d720a6 100644
--- a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java
+++ b/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java
@@ -19,6 +19,10 @@ 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) {
+ if (preferences.isGrobidDemanded()) {
+ preferences.grobidEnabledProperty().setValue(false);
+ preferences.grobidOptOutProperty().setValue(false);
+ }
if (preferences.isGrobidEnabled()) {
return true;
}
@@ -29,8 +33,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/java/org/jabref/gui/preferences/importexport/ImportExportTab.fxml b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.fxml
index c698a797910..42b57d4851a 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 @@
+
+
@@ -29,7 +31,8 @@
-
+
+
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 3018a76daca..e6bb557ad0c 100644
--- a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java
+++ b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java
@@ -7,6 +7,7 @@
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
+import org.jabref.gui.commonfxcontrols.RemoteServicesConfigPanel;
import org.jabref.gui.commonfxcontrols.SaveOrderConfigPanel;
import org.jabref.gui.preferences.AbstractPreferenceTabView;
import org.jabref.gui.preferences.PreferencesTab;
@@ -23,13 +24,12 @@ public class ImportExportTab extends AbstractPreferenceTabView apiKeySelector;
@FXML private TextField customApiKey;
@FXML private CheckBox useCustomApiKey;
@FXML private Button testCustomApiKey;
- @FXML private CheckBox grobidEnabled;
@FXML private TextField grobidURL;
@FXML private CheckBox warnAboutDuplicatesOnImport;
@@ -62,9 +62,12 @@ public void initialize() {
exportOrderPanel.sortCriteriaProperty().bindBidirectional(viewModel.sortCriteriaProperty());
exportOrderPanel.setCriteriaLimit(3);
- grobidEnabled.selectedProperty().bindBidirectional(viewModel.grobidEnabledProperty());
+ RemoteServicesConfigPanel.gorbidDemandedProperty().bindBidirectional(viewModel.grobidDemandedProperty());
+ RemoteServicesConfigPanel.gorbidDisabledProperty().bindBidirectional(viewModel.grobidDisabledProperty());
+ RemoteServicesConfigPanel.gorbidEnabledProperty().bindBidirectional(viewModel.grobidEnabledProperty());
+
grobidURL.textProperty().bindBidirectional(viewModel.grobidURLProperty());
- grobidURL.disableProperty().bind(grobidEnabled.selectedProperty().not());
+ grobidURL.disableProperty().bind(viewModel.grobidEnabledProperty().not());
downloadLinkedOnlineFiles.selectedProperty().bindBidirectional(viewModel.shouldDownloadLinkedOnlineFiles());
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 96196df3284..dccd6f27315 100644
--- a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTabViewModel.java
@@ -55,8 +55,9 @@ public class ImportExportTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty exportInSpecifiedOrderProperty = new SimpleBooleanProperty();
private final ListProperty sortableFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
private final ListProperty sortCriteriaProperty = new SimpleListProperty<>(FXCollections.observableArrayList(new ArrayList<>()));
-
private final BooleanProperty grobidEnabledProperty = new SimpleBooleanProperty();
+ private final BooleanProperty grobidDisabledProperty = new SimpleBooleanProperty();
+ private final BooleanProperty grobidDemandedProperty = new SimpleBooleanProperty();
private final StringProperty grobidURLProperty = new SimpleStringProperty("");
private final BooleanProperty warnAboutDuplicatesOnImportProperty = new SimpleBooleanProperty();
private final BooleanProperty shouldDownloadLinkedOnlineFiles = new SimpleBooleanProperty();
@@ -105,6 +106,8 @@ public void setValues() {
.toList());
grobidEnabledProperty.setValue(grobidPreferences.isGrobidEnabled());
+ grobidDisabledProperty.setValue(grobidPreferences.isGrobidOptOut());
+ grobidDemandedProperty.setValue(grobidPreferences.isGrobidDemanded());
grobidURLProperty.setValue(grobidPreferences.getGrobidURL());
apiKeys.setValue(FXCollections.observableArrayList(preferencesService.getImporterPreferences().getApiKeys()));
@@ -114,7 +117,9 @@ public void setValues() {
public void storeSettings() {
importerPreferences.setGenerateNewKeyOnImport(generateKeyOnImportProperty.getValue());
grobidPreferences.setGrobidEnabled(grobidEnabledProperty.getValue());
- grobidPreferences.setGrobidOptOut(grobidPreferences.isGrobidOptOut());
+ grobidPreferences.setGrobidDemanded(grobidDemandedProperty.getValue());
+ grobidPreferences.setGrobidOptOut(grobidDisabledProperty.getValue());
+
grobidPreferences.setGrobidURL(grobidURLProperty.getValue());
filePreferences.setDownloadLinkedFiles(shouldDownloadLinkedOnlineFiles.getValue());
@@ -172,6 +177,14 @@ public BooleanProperty grobidEnabledProperty() {
return grobidEnabledProperty;
}
+ public BooleanProperty grobidDisabledProperty() {
+ return grobidDisabledProperty;
+ }
+
+ 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 e87b54f08fe..9fa7eb288a3 100644
--- a/src/main/java/org/jabref/logic/importer/fetcher/GrobidPreferences.java
+++ b/src/main/java/org/jabref/logic/importer/fetcher/GrobidPreferences.java
@@ -8,13 +8,16 @@
public class GrobidPreferences {
private final BooleanProperty grobidEnabled;
private final BooleanProperty grobidOptOut;
+ private final BooleanProperty grobidDemanded;
private final StringProperty grobidURL;
public GrobidPreferences(boolean grobidEnabled,
boolean grobidOptOut,
+ boolean grobidDemanded,
String grobidURL) {
this.grobidEnabled = new SimpleBooleanProperty(grobidEnabled);
this.grobidOptOut = new SimpleBooleanProperty(grobidOptOut);
+ this.grobidDemanded = new SimpleBooleanProperty(grobidDemanded);
this.grobidURL = new SimpleStringProperty(grobidURL);
}
@@ -42,6 +45,18 @@ public void setGrobidOptOut(boolean grobidOptOut) {
this.grobidOptOut.set(grobidOptOut);
}
+ public boolean isGrobidDemanded() {
+ return grobidDemanded.get();
+ }
+
+ public BooleanProperty grobidDemandedProperty() {
+ return grobidDemanded;
+ }
+
+ public void setGrobidDemanded(boolean grobidDemanded) {
+ this.grobidDemanded.set(grobidDemanded);
+ }
+
public String getGrobidURL() {
return grobidURL.get();
}
diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java
index bbc182f9497..ea2d14db5e4 100644
--- a/src/main/java/org/jabref/preferences/JabRefPreferences.java
+++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java
@@ -268,6 +268,8 @@ 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";
public static final String DEFAULT_CITATION_KEY_PATTERN = "defaultBibtexKeyPattern";
@@ -494,6 +496,7 @@ private JabRefPreferences() {
defaults.put(GENERATE_KEY_ON_IMPORT, Boolean.TRUE);
defaults.put(GROBID_ENABLED, Boolean.FALSE);
defaults.put(GROBID_OPT_OUT, Boolean.FALSE);
+ defaults.put(GROBID_DEMANDED, Boolean.TRUE);
defaults.put(GROBID_URL, "http://grobid.jabref.org:8070");
defaults.put(PUSH_TEXMAKER_PATH, JabRefDesktop.getNativeDesktop().detectProgramPath("texmaker", "Texmaker"));
@@ -2850,10 +2853,12 @@ public GrobidPreferences getGrobidPreferences() {
grobidPreferences = new GrobidPreferences(
getBoolean(GROBID_ENABLED),
getBoolean(GROBID_OPT_OUT),
+ getBoolean(GROBID_DEMANDED),
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.grobidDemandedProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_DEMANDED, newValue));
EasyBind.listen(grobidPreferences.grobidURLProperty(), (obs, oldValue, newValue) -> put(GROBID_URL, newValue));
return grobidPreferences;
diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties
index 188a114e8d4..12a4c2afd98 100644
--- a/src/main/resources/l10n/JabRef_en.properties
+++ b/src/main/resources/l10n/JabRef_en.properties
@@ -2432,7 +2432,9 @@ 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
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));
}