Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class WebSearchTab extends AbstractPreferenceTabView<WebSearchTabViewMode
@FXML private CheckBox grobidEnabled;
@FXML private TextField grobidURL;

@FXML private CheckBox preferInspireTexkeys;

@FXML private VBox fetchersContainer;

private final ReadOnlyBooleanProperty refAiEnabled;
Expand Down Expand Up @@ -119,6 +121,8 @@ public void initialize() {
useCustomDOIName.textProperty().bindBidirectional(viewModel.useCustomDOINameProperty());
useCustomDOIName.disableProperty().bind(useCustomDOI.selectedProperty().not());

preferInspireTexkeys.selectedProperty().bindBidirectional(viewModel.preferInspireTexkeysProperty());

InvalidationListener listener = _ -> fetchersContainer
.getChildren()
.setAll(viewModel.getFetchers()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class WebSearchTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty grobidEnabledProperty = new SimpleBooleanProperty();
private final StringProperty grobidURLProperty = new SimpleStringProperty("");

private final BooleanProperty preferInspireTexkeysProperty = new SimpleBooleanProperty();

private final BooleanProperty apikeyPersistProperty = new SimpleBooleanProperty();
private final BooleanProperty apikeyPersistAvailableProperty = new SimpleBooleanProperty();

Expand Down Expand Up @@ -153,6 +155,8 @@ public void setValues() {
grobidEnabledProperty.setValue(grobidPreferences.isGrobidEnabled());
grobidURLProperty.setValue(grobidPreferences.getGrobidURL());

preferInspireTexkeysProperty.setValue(preferences.getImporterPreferences().isPreferInspireTexkeys());

Set<FetcherApiKey> savedApiKeys = preferences.getImporterPreferences().getApiKeys();
Set<String> enabledCatalogs = new HashSet<>(importerPreferences.getCatalogs());

Expand Down Expand Up @@ -207,6 +211,8 @@ public void storeSettings() {
doiPreferences.setUseCustom(useCustomDOIProperty.get());
doiPreferences.setDefaultBaseURI(useCustomDOINameProperty.getValue().trim());

importerPreferences.setPreferInspireTexkeys(preferInspireTexkeysProperty.getValue());

importerPreferences.setCatalogs(
fetchers.stream()
.filter(FetcherViewModel::isEnabled)
Expand Down Expand Up @@ -289,6 +295,10 @@ public IntegerProperty citationsRelationsStoreTTLProperty() {
return citationsRelationStoreTTL;
}

public BooleanProperty preferInspireTexkeysProperty() {
return preferInspireTexkeysProperty;
}

public void checkApiKey(FetcherViewModel fetcherViewModel, String apiKey, Consumer<Boolean> onFinished) {
Callable<Boolean> tester = () -> {
WebFetcher webFetcher = fetcherViewModel.getFetcher();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<TextField fx:id="grobidURL" HBox.hgrow="ALWAYS"/>
</HBox>

<Label styleClass="sectionHeader" text="%INSPIRE preferences"/>
<FlowPane styleClass="checkbox-flowpane">
<CheckBox fx:id="preferInspireTexkeys" text="%Prefer INSPIRE texkeys; clean URL-like citation keys"/>
</FlowPane>

<Label styleClass="sectionHeader" text="%Web search fetchers"/>
<VBox fx:id="fetchersContainer"/>
</fx:root>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ImporterPreferences {
private final ObservableList<String> catalogs;
private final ObjectProperty<PlainCitationParserChoice> defaultPlainCitationParser;
private final IntegerProperty citationsRelationsStoreTTL;
private final BooleanProperty preferInspireTexkeys;

public ImporterPreferences(boolean importerEnabled,
boolean generateNewKeyOnImport,
Expand All @@ -43,7 +44,8 @@ public ImporterPreferences(boolean importerEnabled,
boolean persistCustomKeys,
List<String> catalogs,
PlainCitationParserChoice defaultPlainCitationParser,
int citationsRelationsStoreTTL
int citationsRelationsStoreTTL,
boolean preferInspireTexkeys
) {
this.importerEnabled = new SimpleBooleanProperty(importerEnabled);
this.generateNewKeyOnImport = new SimpleBooleanProperty(generateNewKeyOnImport);
Expand All @@ -56,6 +58,7 @@ public ImporterPreferences(boolean importerEnabled,
this.catalogs = FXCollections.observableArrayList(catalogs);
this.defaultPlainCitationParser = new SimpleObjectProperty<>(defaultPlainCitationParser);
this.citationsRelationsStoreTTL = new SimpleIntegerProperty(citationsRelationsStoreTTL);
this.preferInspireTexkeys = new SimpleBooleanProperty(preferInspireTexkeys);
}

public boolean areImporterEnabled() {
Expand Down Expand Up @@ -176,4 +179,16 @@ public IntegerProperty citationsRelationsStoreTTLProperty() {
public void setCitationsRelationsStoreTTL(int citationsRelationsStoreTTL) {
this.citationsRelationsStoreTTL.set(citationsRelationsStoreTTL);
}

public boolean isPreferInspireTexkeys() {
return preferInspireTexkeys.get();
}

public BooleanProperty preferInspireTexkeysProperty() {
return preferInspireTexkeys;
}

public void setPreferInspireTexkeys(boolean preferInspireTexkeys) {
this.preferInspireTexkeys.set(preferInspireTexkeys);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ public class JabRefCliPreferences implements CliPreferences {
public static final String SEARCH_CATALOGS = "searchCatalogs";
public static final String DEFAULT_PLAIN_CITATION_PARSER = "defaultPlainCitationParser";
public static final String CITATIONS_RELATIONS_STORE_TTL = "citationsRelationsStoreTTL";
public static final String PREFER_INSPIRE_TEXKEYS = "preferInspireTexkeys";
public static final String IMPORTERS_ENABLED = "importersEnabled";
public static final String GENERATE_KEY_ON_IMPORT = "generateKeyOnImport";
public static final String GROBID_ENABLED = "grobidEnabled";
Expand Down Expand Up @@ -527,6 +528,7 @@ public JabRefCliPreferences() {
defaults.put(IMPORTERS_ENABLED, Boolean.TRUE);
defaults.put(GENERATE_KEY_ON_IMPORT, Boolean.TRUE);
defaults.put(CITATIONS_RELATIONS_STORE_TTL, 30);
defaults.put(PREFER_INSPIRE_TEXKEYS, Boolean.TRUE);

defaults.put(ADD_IMPORTED_ENTRIES, Boolean.FALSE);
defaults.put(ADD_IMPORTED_ENTRIES_GROUP_NAME, Localization.lang("Imported entries"));
Expand Down Expand Up @@ -2223,7 +2225,8 @@ public ImporterPreferences getImporterPreferences() {
getBoolean(FETCHER_CUSTOM_KEY_PERSIST),
getStringList(SEARCH_CATALOGS),
PlainCitationParserChoice.valueOf(get(DEFAULT_PLAIN_CITATION_PARSER)),
getInt(CITATIONS_RELATIONS_STORE_TTL)
getInt(CITATIONS_RELATIONS_STORE_TTL),
getBoolean(PREFER_INSPIRE_TEXKEYS)
);

EasyBind.listen(importerPreferences.importerEnabledProperty(), (_, _, newValue) -> putBoolean(IMPORTERS_ENABLED, newValue));
Expand All @@ -2236,6 +2239,7 @@ public ImporterPreferences getImporterPreferences() {
importerPreferences.getCatalogs().addListener((InvalidationListener) _ -> putStringList(SEARCH_CATALOGS, importerPreferences.getCatalogs()));
EasyBind.listen(importerPreferences.defaultPlainCitationParserProperty(), (_, _, newValue) -> put(DEFAULT_PLAIN_CITATION_PARSER, newValue.name()));
EasyBind.listen(importerPreferences.citationsRelationsStoreTTLProperty(), (_, _, newValue) -> put(CITATIONS_RELATIONS_STORE_TTL, newValue.toString()));
EasyBind.listen(importerPreferences.preferInspireTexkeysProperty(), (_, _, newValue) -> putBoolean(PREFER_INSPIRE_TEXKEYS, newValue));

return importerPreferences;
}
Expand Down