Skip to content

Web Import: Add New Entries to 'Imported Entries' Group #12998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 @@ -21,6 +21,10 @@
<CheckBox fx:id="warnAboutDuplicatesOnImport" text="%Warn about duplicates on import"/>
<CheckBox fx:id="downloadLinkedOnlineFiles" text="%Download referenced files (PDFs, ...)"/>
<CheckBox fx:id="keepDownloadUrl" text="%Store url for downloaded file" />
<HBox alignment="CENTER_LEFT" spacing="10.0">
<CheckBox fx:id="addImportedEntries" text="%Add imported entries to group"/>
<TextField fx:id="addImportedEntriesGroupName" HBox.hgrow="ALWAYS"/>
</HBox>
<HBox alignment="BASELINE_LEFT" spacing="10">
<Label text="%Default plain citation parser"/>
<ComboBox fx:id="defaultPlainCitationParser" HBox.hgrow="ALWAYS"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class WebSearchTab extends AbstractPreferenceTabView<WebSearchTabViewMode
@FXML private CheckBox warnAboutDuplicatesOnImport;
@FXML private CheckBox downloadLinkedOnlineFiles;
@FXML private CheckBox keepDownloadUrl;
@FXML private CheckBox addImportedEntries;
@FXML private TextField addImportedEntriesGroupName;
Comment on lines +36 to +37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new UI elements 'addImportedEntries' and 'addImportedEntriesGroupName' should have their labels localized using Localization.lang to support multilingual functionality.

@FXML private ComboBox<PlainCitationParserChoice> defaultPlainCitationParser;

@FXML private CheckBox useCustomDOI;
Expand Down Expand Up @@ -76,6 +78,10 @@ public void initialize() {
downloadLinkedOnlineFiles.selectedProperty().bindBidirectional(viewModel.shouldDownloadLinkedOnlineFiles());
keepDownloadUrl.selectedProperty().bindBidirectional(viewModel.shouldKeepDownloadUrl());

addImportedEntries.selectedProperty().bindBidirectional(viewModel.getAddImportedEntries());
addImportedEntriesGroupName.textProperty().bindBidirectional(viewModel.getAddImportedEntriesGroupName());
addImportedEntriesGroupName.disableProperty().bind(addImportedEntries.selectedProperty().not());

new ViewModelListCellFactory<PlainCitationParserChoice>()
.withText(PlainCitationParserChoice::getLocalizedName)
.install(defaultPlainCitationParser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.jabref.gui.preferences.PreferenceTabViewModel;
import org.jabref.gui.slr.StudyCatalogItem;
import org.jabref.logic.FilePreferences;
import org.jabref.logic.LibraryPreferences;
import org.jabref.logic.importer.ImportFormatPreferences;
import org.jabref.logic.importer.ImporterPreferences;
import org.jabref.logic.importer.SearchBasedFetcher;
Expand Down Expand Up @@ -48,6 +49,9 @@ public class WebSearchTabViewModel implements PreferenceTabViewModel {
new SimpleListProperty<>(FXCollections.observableArrayList(PlainCitationParserChoice.values()));
private final ObjectProperty<PlainCitationParserChoice> defaultPlainCitationParser = new SimpleObjectProperty<>();

private final BooleanProperty addImportedEntries = new SimpleBooleanProperty();
private final StringProperty addImportedEntriesGroupName = new SimpleStringProperty("");

private final BooleanProperty useCustomDOIProperty = new SimpleBooleanProperty();
private final StringProperty useCustomDOINameProperty = new SimpleStringProperty("");

Expand All @@ -67,6 +71,7 @@ public class WebSearchTabViewModel implements PreferenceTabViewModel {
private final ImporterPreferences importerPreferences;
private final FilePreferences filePreferences;
private final ImportFormatPreferences importFormatPreferences;
private final LibraryPreferences libraryPreferences;

private final ReadOnlyBooleanProperty refAiEnabled;

Expand All @@ -78,6 +83,7 @@ public WebSearchTabViewModel(CliPreferences preferences, DialogService dialogSer
this.doiPreferences = preferences.getDOIPreferences();
this.filePreferences = preferences.getFilePreferences();
this.importFormatPreferences = preferences.getImportFormatPreferences();
this.libraryPreferences = preferences.getLibraryPreferences();

this.refAiEnabled = refAiEnabled;

Expand Down Expand Up @@ -128,6 +134,12 @@ public void setValues() {
warnAboutDuplicatesOnImportProperty.setValue(importerPreferences.shouldWarnAboutDuplicatesOnImport());
shouldDownloadLinkedOnlineFiles.setValue(filePreferences.shouldDownloadLinkedFiles());
shouldkeepDownloadUrl.setValue(filePreferences.shouldKeepDownloadUrl());
addImportedEntries.setValue(libraryPreferences.isAddImportedEntriesEnabled());
if (libraryPreferences.getAddImportedEntriesGroupName().isEmpty()) {
addImportedEntriesGroupName.setValue(Localization.lang("Imported entries"));
} else {
addImportedEntriesGroupName.setValue(libraryPreferences.getAddImportedEntriesGroupName());
}
defaultPlainCitationParser.setValue(importerPreferences.getDefaultPlainCitationParser());

useCustomDOIProperty.setValue(doiPreferences.isUseCustom());
Expand Down Expand Up @@ -159,7 +171,14 @@ public void storeSettings() {
importerPreferences.setWarnAboutDuplicatesOnImport(warnAboutDuplicatesOnImportProperty.getValue());
filePreferences.setDownloadLinkedFiles(shouldDownloadLinkedOnlineFiles.getValue());
filePreferences.setKeepDownloadUrl(shouldkeepDownloadUrl.getValue());
libraryPreferences.setAddImportedEntries(addImportedEntries.getValue());
if (addImportedEntriesGroupName.getValue().isEmpty() || addImportedEntriesGroupName.getValue().startsWith(" ")) {
libraryPreferences.setAddImportedEntriesGroupName("");
} else {
libraryPreferences.setAddImportedEntriesGroupName(addImportedEntriesGroupName.getValue());
}
importerPreferences.setDefaultPlainCitationParser(defaultPlainCitationParser.getValue());

grobidPreferences.setGrobidEnabled(grobidEnabledProperty.getValue());
grobidPreferences.setGrobidUseAsked(grobidPreferences.isGrobidUseAsked());
grobidPreferences.setGrobidURL(grobidURLProperty.getValue());
Expand Down Expand Up @@ -189,6 +208,14 @@ public ObjectProperty<PlainCitationParserChoice> defaultPlainCitationParserPrope
return defaultPlainCitationParser;
}

public BooleanProperty getAddImportedEntries() {
return addImportedEntries;
}

public StringProperty getAddImportedEntriesGroupName() {
return addImportedEntriesGroupName;
}

public BooleanProperty useCustomDOIProperty() {
return this.useCustomDOIProperty;
}
Expand Down
32 changes: 31 additions & 1 deletion src/main/java/org/jabref/logic/LibraryPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.jabref.model.database.BibDatabaseMode;

Expand All @@ -12,13 +14,17 @@ public class LibraryPreferences {
private final ObjectProperty<BibDatabaseMode> defaultBibDatabaseMode;
private final BooleanProperty alwaysReformatOnSave;
private final BooleanProperty autoSave;
private final BooleanProperty addImportedEntries;
private final StringProperty addImportedEntriesGroupName;

public LibraryPreferences(BibDatabaseMode defaultBibDatabaseMode,
boolean alwaysReformatOnSave,
boolean autoSave) {
boolean autoSave, boolean addImportedEntries, String addImportedEntriesGroupName) {
this.defaultBibDatabaseMode = new SimpleObjectProperty<>(defaultBibDatabaseMode);
this.alwaysReformatOnSave = new SimpleBooleanProperty(alwaysReformatOnSave);
this.autoSave = new SimpleBooleanProperty(autoSave);
this.addImportedEntries = new SimpleBooleanProperty(addImportedEntries);
this.addImportedEntriesGroupName = new SimpleStringProperty(addImportedEntriesGroupName);
}

public BibDatabaseMode getDefaultBibDatabaseMode() {
Expand Down Expand Up @@ -56,4 +62,28 @@ public BooleanProperty autoSaveProperty() {
public void setAutoSave(boolean shouldAutoSave) {
this.autoSave.set(shouldAutoSave);
}

public boolean isAddImportedEntriesEnabled() {
return addImportedEntries.get();
}

public BooleanProperty addImportedEntriesProperty() {
return addImportedEntries;
}

public void setAddImportedEntries(boolean addImportedEntries) {
this.addImportedEntries.set(addImportedEntries);
}

public String getAddImportedEntriesGroupName() {
return addImportedEntriesGroupName.get();
}

public StringProperty addImportedEntriesGroupNameProperty() {
return addImportedEntriesGroupName;
}

public void setAddImportedEntriesGroupName(String addImportedEntriesGroupName) {
this.addImportedEntriesGroupName.set(addImportedEntriesGroupName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ public class JabRefCliPreferences implements CliPreferences {
public static final String MEMORY_STICK_MODE = "memoryStickMode";
public static final String DEFAULT_ENCODING = "defaultEncoding";

private static final String ADD_IMPORTED_ENTRIES = "addImportedEntries";
private static final String ADD_IMPORTED_ENTRIES_GROUP_NAME = "addImportedEntriesGroupName";

public static final String BASE_DOI_URI = "baseDOIURI";
public static final String USE_CUSTOM_DOI_URI = "useCustomDOIURI";

Expand Down Expand Up @@ -470,6 +473,9 @@ protected JabRefCliPreferences() {
defaults.put(IMPORTERS_ENABLED, Boolean.TRUE);
defaults.put(GENERATE_KEY_ON_IMPORT, Boolean.TRUE);

defaults.put(ADD_IMPORTED_ENTRIES, Boolean.FALSE);
defaults.put(ADD_IMPORTED_ENTRIES_GROUP_NAME, Localization.lang("Imported entries"));

// region: Grobid
defaults.put(GROBID_ENABLED, Boolean.FALSE);
defaults.put(GROBID_PREFERENCE, Boolean.FALSE);
Expand Down Expand Up @@ -1175,12 +1181,17 @@ public LibraryPreferences getLibraryPreferences() {
libraryPreferences = new LibraryPreferences(
getBoolean(BIBLATEX_DEFAULT_MODE) ? BibDatabaseMode.BIBLATEX : BibDatabaseMode.BIBTEX,
getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT),
getBoolean(LOCAL_AUTO_SAVE));
getBoolean(LOCAL_AUTO_SAVE),
getBoolean(ADD_IMPORTED_ENTRIES),
get(ADD_IMPORTED_ENTRIES_GROUP_NAME));

EasyBind.listen(libraryPreferences.defaultBibDatabaseModeProperty(), (obs, oldValue, newValue) -> putBoolean(BIBLATEX_DEFAULT_MODE, (newValue == BibDatabaseMode.BIBLATEX)));
EasyBind.listen(libraryPreferences.alwaysReformatOnSaveProperty(), (obs, oldValue, newValue) -> putBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT, newValue));
EasyBind.listen(libraryPreferences.autoSaveProperty(), (obs, oldValue, newValue) -> putBoolean(LOCAL_AUTO_SAVE, newValue));

EasyBind.listen(libraryPreferences.addImportedEntriesProperty(), (obs, oldValue, newValue) -> putBoolean(ADD_IMPORTED_ENTRIES, newValue));
EasyBind.listen(libraryPreferences.addImportedEntriesGroupNameProperty(), (obs, oldValue, newValue) -> put(ADD_IMPORTED_ENTRIES_GROUP_NAME, newValue));

return libraryPreferences;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,8 @@ Unprotect\ terms=Unprotect terms
Generate\ a\ new\ key\ for\ imported\ entries\ (overwriting\ their\ default)=Generate a new key for imported entries (overwriting their default)
Warn\ about\ duplicates\ on\ import=Warn about duplicates on import

Add\ imported\ entries\ to\ group=Add imported entries to group

Custom\ DOI\ URI=Custom DOI URI
Use\ custom\ DOI\ base\ URI\ for\ article\ access=Use custom DOI base URI for article access

Expand Down
Loading