Skip to content

Commit 2732800

Browse files
committed
Add field to configure imported entries group under web search preference
1 parent af362ea commit 2732800

File tree

6 files changed

+82
-2
lines changed

6 files changed

+82
-2
lines changed

src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<CheckBox fx:id="warnAboutDuplicatesOnImport" text="%Warn about duplicates on import"/>
2222
<CheckBox fx:id="downloadLinkedOnlineFiles" text="%Download referenced files (PDFs, ...)"/>
2323
<CheckBox fx:id="keepDownloadUrl" text="%Store url for downloaded file" />
24+
<HBox alignment="CENTER_LEFT" spacing="10.0">
25+
<CheckBox fx:id="addImportedEntries" text="%Add imported entries to group"/>
26+
<TextField fx:id="addImportedEntriesGroupName" HBox.hgrow="ALWAYS"/>
27+
</HBox>
2428
<HBox alignment="BASELINE_LEFT" spacing="10">
2529
<Label text="%Default plain citation parser"/>
2630
<ComboBox fx:id="defaultPlainCitationParser" HBox.hgrow="ALWAYS"/>

src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public class WebSearchTab extends AbstractPreferenceTabView<WebSearchTabViewMode
3333
@FXML private CheckBox warnAboutDuplicatesOnImport;
3434
@FXML private CheckBox downloadLinkedOnlineFiles;
3535
@FXML private CheckBox keepDownloadUrl;
36+
@FXML private CheckBox addImportedEntries;
37+
@FXML private TextField addImportedEntriesGroupName;
3638
@FXML private ComboBox<PlainCitationParserChoice> defaultPlainCitationParser;
3739

3840
@FXML private CheckBox useCustomDOI;
@@ -76,6 +78,10 @@ public void initialize() {
7678
downloadLinkedOnlineFiles.selectedProperty().bindBidirectional(viewModel.shouldDownloadLinkedOnlineFiles());
7779
keepDownloadUrl.selectedProperty().bindBidirectional(viewModel.shouldKeepDownloadUrl());
7880

81+
addImportedEntries.selectedProperty().bindBidirectional(viewModel.getAddImportedEntries());
82+
addImportedEntriesGroupName.textProperty().bindBidirectional(viewModel.getAddImportedEntriesGroupName());
83+
addImportedEntriesGroupName.disableProperty().bind(addImportedEntries.selectedProperty().not());
84+
7985
new ViewModelListCellFactory<PlainCitationParserChoice>()
8086
.withText(PlainCitationParserChoice::getLocalizedName)
8187
.install(defaultPlainCitationParser);

src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.jabref.gui.preferences.PreferenceTabViewModel;
2222
import org.jabref.gui.slr.StudyCatalogItem;
2323
import org.jabref.logic.FilePreferences;
24+
import org.jabref.logic.LibraryPreferences;
2425
import org.jabref.logic.importer.ImportFormatPreferences;
2526
import org.jabref.logic.importer.ImporterPreferences;
2627
import org.jabref.logic.importer.SearchBasedFetcher;
@@ -48,6 +49,9 @@ public class WebSearchTabViewModel implements PreferenceTabViewModel {
4849
new SimpleListProperty<>(FXCollections.observableArrayList(PlainCitationParserChoice.values()));
4950
private final ObjectProperty<PlainCitationParserChoice> defaultPlainCitationParser = new SimpleObjectProperty<>();
5051

52+
private final BooleanProperty addImportedEntries = new SimpleBooleanProperty();
53+
private final StringProperty addImportedEntriesGroupName = new SimpleStringProperty("");
54+
5155
private final BooleanProperty useCustomDOIProperty = new SimpleBooleanProperty();
5256
private final StringProperty useCustomDOINameProperty = new SimpleStringProperty("");
5357

@@ -67,6 +71,7 @@ public class WebSearchTabViewModel implements PreferenceTabViewModel {
6771
private final ImporterPreferences importerPreferences;
6872
private final FilePreferences filePreferences;
6973
private final ImportFormatPreferences importFormatPreferences;
74+
private final LibraryPreferences libraryPreferences;
7075

7176
private final ReadOnlyBooleanProperty refAiEnabled;
7277

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

8288
this.refAiEnabled = refAiEnabled;
8389

@@ -128,6 +134,12 @@ public void setValues() {
128134
warnAboutDuplicatesOnImportProperty.setValue(importerPreferences.shouldWarnAboutDuplicatesOnImport());
129135
shouldDownloadLinkedOnlineFiles.setValue(filePreferences.shouldDownloadLinkedFiles());
130136
shouldkeepDownloadUrl.setValue(filePreferences.shouldKeepDownloadUrl());
137+
addImportedEntries.setValue(libraryPreferences.isAddImportedEntriesEnabled());
138+
if (libraryPreferences.getAddImportedEntriesGroupName().isEmpty()) {
139+
addImportedEntriesGroupName.setValue(Localization.lang("Imported entries"));
140+
} else {
141+
addImportedEntriesGroupName.setValue(libraryPreferences.getAddImportedEntriesGroupName());
142+
}
131143
defaultPlainCitationParser.setValue(importerPreferences.getDefaultPlainCitationParser());
132144

133145
useCustomDOIProperty.setValue(doiPreferences.isUseCustom());
@@ -159,7 +171,14 @@ public void storeSettings() {
159171
importerPreferences.setWarnAboutDuplicatesOnImport(warnAboutDuplicatesOnImportProperty.getValue());
160172
filePreferences.setDownloadLinkedFiles(shouldDownloadLinkedOnlineFiles.getValue());
161173
filePreferences.setKeepDownloadUrl(shouldkeepDownloadUrl.getValue());
174+
libraryPreferences.setAddImportedEntries(addImportedEntries.getValue());
175+
if (addImportedEntriesGroupName.getValue().isEmpty() || addImportedEntriesGroupName.getValue().startsWith(" ")) {
176+
libraryPreferences.setAddImportedEntriesGroupName("");
177+
} else {
178+
libraryPreferences.setAddImportedEntriesGroupName(addImportedEntriesGroupName.getValue());
179+
}
162180
importerPreferences.setDefaultPlainCitationParser(defaultPlainCitationParser.getValue());
181+
163182
grobidPreferences.setGrobidEnabled(grobidEnabledProperty.getValue());
164183
grobidPreferences.setGrobidUseAsked(grobidPreferences.isGrobidUseAsked());
165184
grobidPreferences.setGrobidURL(grobidURLProperty.getValue());
@@ -189,6 +208,14 @@ public ObjectProperty<PlainCitationParserChoice> defaultPlainCitationParserPrope
189208
return defaultPlainCitationParser;
190209
}
191210

211+
public BooleanProperty getAddImportedEntries() {
212+
return addImportedEntries;
213+
}
214+
215+
public StringProperty getAddImportedEntriesGroupName() {
216+
return addImportedEntriesGroupName;
217+
}
218+
192219
public BooleanProperty useCustomDOIProperty() {
193220
return this.useCustomDOIProperty;
194221
}

src/main/java/org/jabref/logic/LibraryPreferences.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import javafx.beans.property.ObjectProperty;
55
import javafx.beans.property.SimpleBooleanProperty;
66
import javafx.beans.property.SimpleObjectProperty;
7+
import javafx.beans.property.SimpleStringProperty;
8+
import javafx.beans.property.StringProperty;
79

810
import org.jabref.model.database.BibDatabaseMode;
911

@@ -12,13 +14,17 @@ public class LibraryPreferences {
1214
private final ObjectProperty<BibDatabaseMode> defaultBibDatabaseMode;
1315
private final BooleanProperty alwaysReformatOnSave;
1416
private final BooleanProperty autoSave;
17+
private final BooleanProperty addImportedEntries;
18+
private final StringProperty addImportedEntriesGroupName;
1519

1620
public LibraryPreferences(BibDatabaseMode defaultBibDatabaseMode,
1721
boolean alwaysReformatOnSave,
18-
boolean autoSave) {
22+
boolean autoSave, boolean addImportedEntries, String addImportedEntriesGroupName) {
1923
this.defaultBibDatabaseMode = new SimpleObjectProperty<>(defaultBibDatabaseMode);
2024
this.alwaysReformatOnSave = new SimpleBooleanProperty(alwaysReformatOnSave);
2125
this.autoSave = new SimpleBooleanProperty(autoSave);
26+
this.addImportedEntries = new SimpleBooleanProperty(addImportedEntries);
27+
this.addImportedEntriesGroupName = new SimpleStringProperty(addImportedEntriesGroupName);
2228
}
2329

2430
public BibDatabaseMode getDefaultBibDatabaseMode() {
@@ -56,4 +62,28 @@ public BooleanProperty autoSaveProperty() {
5662
public void setAutoSave(boolean shouldAutoSave) {
5763
this.autoSave.set(shouldAutoSave);
5864
}
65+
66+
public boolean isAddImportedEntriesEnabled() {
67+
return addImportedEntries.get();
68+
}
69+
70+
public BooleanProperty addImportedEntriesProperty() {
71+
return addImportedEntries;
72+
}
73+
74+
public void setAddImportedEntries(boolean addImportedEntries) {
75+
this.addImportedEntries.set(addImportedEntries);
76+
}
77+
78+
public String getAddImportedEntriesGroupName() {
79+
return addImportedEntriesGroupName.get();
80+
}
81+
82+
public StringProperty addImportedEntriesGroupNameProperty() {
83+
return addImportedEntriesGroupName;
84+
}
85+
86+
public void setAddImportedEntriesGroupName(String addImportedEntriesGroupName) {
87+
this.addImportedEntriesGroupName.set(addImportedEntriesGroupName);
88+
}
5989
}

src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ public class JabRefCliPreferences implements CliPreferences {
171171
public static final String MEMORY_STICK_MODE = "memoryStickMode";
172172
public static final String DEFAULT_ENCODING = "defaultEncoding";
173173

174+
private static final String ADD_IMPORTED_ENTRIES = "addImportedEntries";
175+
private static final String ADD_IMPORTED_ENTRIES_GROUP_NAME = "addImportedEntriesGroupName";
176+
174177
public static final String BASE_DOI_URI = "baseDOIURI";
175178
public static final String USE_CUSTOM_DOI_URI = "useCustomDOIURI";
176179

@@ -470,6 +473,9 @@ protected JabRefCliPreferences() {
470473
defaults.put(IMPORTERS_ENABLED, Boolean.TRUE);
471474
defaults.put(GENERATE_KEY_ON_IMPORT, Boolean.TRUE);
472475

476+
defaults.put(ADD_IMPORTED_ENTRIES, Boolean.FALSE);
477+
defaults.put(ADD_IMPORTED_ENTRIES_GROUP_NAME, Localization.lang("Imported entries"));
478+
473479
// region: Grobid
474480
defaults.put(GROBID_ENABLED, Boolean.FALSE);
475481
defaults.put(GROBID_PREFERENCE, Boolean.FALSE);
@@ -1175,12 +1181,17 @@ public LibraryPreferences getLibraryPreferences() {
11751181
libraryPreferences = new LibraryPreferences(
11761182
getBoolean(BIBLATEX_DEFAULT_MODE) ? BibDatabaseMode.BIBLATEX : BibDatabaseMode.BIBTEX,
11771183
getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT),
1178-
getBoolean(LOCAL_AUTO_SAVE));
1184+
getBoolean(LOCAL_AUTO_SAVE),
1185+
getBoolean(ADD_IMPORTED_ENTRIES),
1186+
get(ADD_IMPORTED_ENTRIES_GROUP_NAME));
11791187

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

1192+
EasyBind.listen(libraryPreferences.addImportedEntriesProperty(), (obs, oldValue, newValue) -> putBoolean(ADD_IMPORTED_ENTRIES, newValue));
1193+
EasyBind.listen(libraryPreferences.addImportedEntriesGroupNameProperty(), (obs, oldValue, newValue) -> put(ADD_IMPORTED_ENTRIES_GROUP_NAME, newValue));
1194+
11841195
return libraryPreferences;
11851196
}
11861197

src/main/resources/l10n/JabRef_en.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,6 +2459,8 @@ Unprotect\ terms=Unprotect terms
24592459
Generate\ a\ new\ key\ for\ imported\ entries\ (overwriting\ their\ default)=Generate a new key for imported entries (overwriting their default)
24602460
Warn\ about\ duplicates\ on\ import=Warn about duplicates on import
24612461
2462+
Add\ imported\ entries\ to\ group=Add imported entries to group
2463+
24622464
Custom\ DOI\ URI=Custom DOI URI
24632465
Use\ custom\ DOI\ base\ URI\ for\ article\ access=Use custom DOI base URI for article access
24642466

0 commit comments

Comments
 (0)