From b545ad89c0910171294ee970f880b1b63d8abc71 Mon Sep 17 00:00:00 2001
From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Date: Thu, 4 May 2023 00:43:32 +0200
Subject: [PATCH 01/11] Renamed ImportExportTab to WebSearchTab
---
.../gui/preferences/PreferencesDialogViewModel.java | 4 ++--
.../WebSearchTab.fxml} | 4 ++--
.../WebSearchTab.java} | 10 +++++-----
.../WebSearchTabViewModel.java} | 6 +++---
src/main/resources/l10n/JabRef_en.properties | 2 +-
5 files changed, 13 insertions(+), 13 deletions(-)
rename src/main/java/org/jabref/gui/preferences/{importexport/ImportExportTab.fxml => websearch/WebSearchTab.fxml} (94%)
rename src/main/java/org/jabref/gui/preferences/{importexport/ImportExportTab.java => websearch/WebSearchTab.java} (92%)
rename src/main/java/org/jabref/gui/preferences/{importexport/ImportExportTabViewModel.java => websearch/WebSearchTabViewModel.java} (97%)
diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
index 5b713d53172..5090544337e 100644
--- a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
@@ -25,7 +25,6 @@
import org.jabref.gui.preferences.file.FileTab;
import org.jabref.gui.preferences.general.GeneralTab;
import org.jabref.gui.preferences.groups.GroupsTab;
-import org.jabref.gui.preferences.importexport.ImportExportTab;
import org.jabref.gui.preferences.journals.JournalAbbreviationsTab;
import org.jabref.gui.preferences.keybindings.KeyBindingsTab;
import org.jabref.gui.preferences.linkedfiles.LinkedFilesTab;
@@ -34,6 +33,7 @@
import org.jabref.gui.preferences.preview.PreviewTab;
import org.jabref.gui.preferences.protectedterms.ProtectedTermsTab;
import org.jabref.gui.preferences.table.TableTab;
+import org.jabref.gui.preferences.websearch.WebSearchTab;
import org.jabref.gui.preferences.xmp.XmpPrivacyTab;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.JabRefException;
@@ -72,7 +72,7 @@ public PreferencesDialogViewModel(DialogService dialogService, PreferencesServic
new JournalAbbreviationsTab(),
new GroupsTab(),
new EntryEditorTab(),
- new ImportExportTab(),
+ new WebSearchTab(),
new CustomEditorFieldsTab(),
new CitationKeyPatternTab(),
new LinkedFilesTab(),
diff --git a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.fxml b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml
similarity index 94%
rename from src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.fxml
rename to src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml
index c698a797910..010d42c0350 100644
--- a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml
@@ -11,8 +11,8 @@
-
+ fx:controller="org.jabref.gui.preferences.websearch.WebSearchTab">
+
diff --git a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java
similarity index 92%
rename from src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java
rename to src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java
index 3018a76daca..da0fa882de1 100644
--- a/src/main/java/org/jabref/gui/preferences/importexport/ImportExportTab.java
+++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java
@@ -1,4 +1,4 @@
-package org.jabref.gui.preferences.importexport;
+package org.jabref.gui.preferences.websearch;
import javafx.beans.InvalidationListener;
import javafx.fxml.FXML;
@@ -16,7 +16,7 @@
import com.airhacks.afterburner.views.ViewLoader;
-public class ImportExportTab extends AbstractPreferenceTabView implements PreferencesTab {
+public class WebSearchTab extends AbstractPreferenceTabView implements PreferencesTab {
@FXML private CheckBox generateNewKeyOnImport;
@FXML private CheckBox useCustomDOI;
@@ -35,7 +35,7 @@ public class ImportExportTab extends AbstractPreferenceTabView apiKeys = new SimpleListProperty<>();
private final ObjectProperty selectedApiKeyProperty = new SimpleObjectProperty<>();
@@ -69,7 +69,7 @@ public class ImportExportTabViewModel implements PreferenceTabViewModel {
private final ImportExportPreferences importExportPreferences;
private final FilePreferences filePreferences;
- public ImportExportTabViewModel(PreferencesService preferencesService, DialogService dialogService) {
+ public WebSearchTabViewModel(PreferencesService preferencesService, DialogService dialogService) {
this.dialogService = dialogService;
this.preferencesService = preferencesService;
this.importerPreferences = preferencesService.getImporterPreferences();
diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties
index 504c0fba0b2..3deee196cdc 100644
--- a/src/main/resources/l10n/JabRef_en.properties
+++ b/src/main/resources/l10n/JabRef_en.properties
@@ -2340,7 +2340,7 @@ 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
-Import\ and\ Export=Import and Export
+
Custom\ DOI\ URI=Custom DOI URI
Use\ custom\ DOI\ base\ URI\ for\ article\ access=Use custom DOI base URI for article access
From 904b6a244ca11d9f6b837d4d078c6c5a95068289 Mon Sep 17 00:00:00 2001
From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Date: Thu, 4 May 2023 00:57:41 +0200
Subject: [PATCH 02/11] Separated WebSearchTab and ExportTab
---
.../PreferencesDialogViewModel.java | 2 +
.../gui/preferences/export/ExportTab.fxml | 13 +++
.../gui/preferences/export/ExportTab.java | 37 +++++++++
.../export/ExportTabViewModel.java | 82 +++++++++++++++++++
.../preferences/websearch/WebSearchTab.fxml | 4 -
.../preferences/websearch/WebSearchTab.java | 32 +++-----
.../websearch/WebSearchTabViewModel.java | 78 +++---------------
7 files changed, 154 insertions(+), 94 deletions(-)
create mode 100644 src/main/java/org/jabref/gui/preferences/export/ExportTab.fxml
create mode 100644 src/main/java/org/jabref/gui/preferences/export/ExportTab.java
create mode 100644 src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java
diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
index 5090544337e..10a1b6fd007 100644
--- a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
@@ -20,6 +20,7 @@
import org.jabref.gui.preferences.entry.EntryTab;
import org.jabref.gui.preferences.entryeditor.EntryEditorTab;
import org.jabref.gui.preferences.entryeditortabs.CustomEditorFieldsTab;
+import org.jabref.gui.preferences.export.ExportTab;
import org.jabref.gui.preferences.external.ExternalTab;
import org.jabref.gui.preferences.externalfiletypes.ExternalFileTypesTab;
import org.jabref.gui.preferences.file.FileTab;
@@ -73,6 +74,7 @@ public PreferencesDialogViewModel(DialogService dialogService, PreferencesServic
new GroupsTab(),
new EntryEditorTab(),
new WebSearchTab(),
+ new ExportTab(),
new CustomEditorFieldsTab(),
new CitationKeyPatternTab(),
new LinkedFilesTab(),
diff --git a/src/main/java/org/jabref/gui/preferences/export/ExportTab.fxml b/src/main/java/org/jabref/gui/preferences/export/ExportTab.fxml
new file mode 100644
index 00000000000..c5b107c39c9
--- /dev/null
+++ b/src/main/java/org/jabref/gui/preferences/export/ExportTab.fxml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/org/jabref/gui/preferences/export/ExportTab.java b/src/main/java/org/jabref/gui/preferences/export/ExportTab.java
new file mode 100644
index 00000000000..94f2b9d963b
--- /dev/null
+++ b/src/main/java/org/jabref/gui/preferences/export/ExportTab.java
@@ -0,0 +1,37 @@
+package org.jabref.gui.preferences.export;
+
+import javafx.fxml.FXML;
+
+import org.jabref.gui.commonfxcontrols.SaveOrderConfigPanel;
+import org.jabref.gui.preferences.AbstractPreferenceTabView;
+import org.jabref.gui.preferences.PreferencesTab;
+import org.jabref.logic.l10n.Localization;
+
+import com.airhacks.afterburner.views.ViewLoader;
+
+public class ExportTab extends AbstractPreferenceTabView implements PreferencesTab {
+
+ @FXML private SaveOrderConfigPanel exportOrderPanel;
+
+ public ExportTab() {
+ ViewLoader.view(this)
+ .root(this)
+ .load();
+ }
+
+ @Override
+ public String getTabName() {
+ return Localization.lang("Export");
+ }
+
+ public void initialize() {
+ this.viewModel = new ExportTabViewModel(preferencesService);
+
+ exportOrderPanel.saveInOriginalProperty().bindBidirectional(viewModel.saveInOriginalProperty());
+ exportOrderPanel.saveInTableOrderProperty().bindBidirectional(viewModel.saveInTableOrderProperty());
+ exportOrderPanel.saveInSpecifiedOrderProperty().bindBidirectional(viewModel.saveInSpecifiedOrderProperty());
+ exportOrderPanel.sortableFieldsProperty().bind(viewModel.sortableFieldsProperty());
+ exportOrderPanel.sortCriteriaProperty().bindBidirectional(viewModel.sortCriteriaProperty());
+ exportOrderPanel.setCriteriaLimit(3);
+ }
+}
diff --git a/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java b/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java
new file mode 100644
index 00000000000..1753c7bf3cb
--- /dev/null
+++ b/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java
@@ -0,0 +1,82 @@
+package org.jabref.gui.preferences.export;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+
+import javafx.beans.property.BooleanProperty;
+import javafx.beans.property.ListProperty;
+import javafx.beans.property.SimpleBooleanProperty;
+import javafx.beans.property.SimpleListProperty;
+import javafx.collections.FXCollections;
+
+import org.jabref.gui.commonfxcontrols.SortCriterionViewModel;
+import org.jabref.gui.preferences.PreferenceTabViewModel;
+import org.jabref.model.entry.field.Field;
+import org.jabref.model.entry.field.FieldFactory;
+import org.jabref.model.metadata.SaveOrder;
+import org.jabref.preferences.ImportExportPreferences;
+import org.jabref.preferences.PreferencesService;
+
+public class ExportTabViewModel implements PreferenceTabViewModel {
+
+ // SaveOrderConfigPanel
+ private final BooleanProperty exportInOriginalProperty = new SimpleBooleanProperty();
+ private final BooleanProperty exportInTableOrderProperty = new SimpleBooleanProperty();
+ 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 PreferencesService preferencesService;
+ private final ImportExportPreferences importExportPreferences;
+
+ public ExportTabViewModel(PreferencesService preferencesService) {
+ this.preferencesService = preferencesService;
+ this.importExportPreferences = preferencesService.getImportExportPreferences();
+ }
+
+ @Override
+ public void setValues() {
+ SaveOrder exportSaveOrder = importExportPreferences.getExportSaveOrder();
+ switch (exportSaveOrder.getOrderType()) {
+ case SPECIFIED -> exportInSpecifiedOrderProperty.setValue(true);
+ case ORIGINAL -> exportInOriginalProperty.setValue(true);
+ case TABLE -> exportInTableOrderProperty.setValue(true);
+ }
+ sortCriteriaProperty.addAll(exportSaveOrder.getSortCriteria().stream()
+ .map(SortCriterionViewModel::new)
+ .toList());
+
+ List fieldNames = new ArrayList<>(FieldFactory.getCommonFields());
+ fieldNames.sort(Comparator.comparing(Field::getDisplayName));
+ sortableFieldsProperty.addAll(fieldNames);
+ }
+
+ @Override
+ public void storeSettings() {
+ SaveOrder newSaveOrder = new SaveOrder(
+ SaveOrder.OrderType.fromBooleans(exportInSpecifiedOrderProperty.getValue(), exportInOriginalProperty.getValue()),
+ sortCriteriaProperty.stream().map(SortCriterionViewModel::getCriterion).toList());
+ preferencesService.getImportExportPreferences().setExportSaveOrder(newSaveOrder);
+ }
+
+ public BooleanProperty saveInOriginalProperty() {
+ return exportInOriginalProperty;
+ }
+
+ public BooleanProperty saveInTableOrderProperty() {
+ return exportInTableOrderProperty;
+ }
+
+ public BooleanProperty saveInSpecifiedOrderProperty() {
+ return exportInSpecifiedOrderProperty;
+ }
+
+ public ListProperty sortableFieldsProperty() {
+ return sortableFieldsProperty;
+ }
+
+ public ListProperty sortCriteriaProperty() {
+ return sortCriteriaProperty;
+ }
+}
diff --git a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml
index 010d42c0350..53a3d9c31f1 100644
--- a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml
@@ -8,7 +8,6 @@
-
@@ -25,9 +24,6 @@
-
-
-
diff --git a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java
index da0fa882de1..d2690a43d56 100644
--- a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java
+++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java
@@ -7,7 +7,6 @@
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
-import org.jabref.gui.commonfxcontrols.SaveOrderConfigPanel;
import org.jabref.gui.preferences.AbstractPreferenceTabView;
import org.jabref.gui.preferences.PreferencesTab;
import org.jabref.gui.util.ViewModelListCellFactory;
@@ -19,22 +18,20 @@
public class WebSearchTab extends AbstractPreferenceTabView implements PreferencesTab {
@FXML private CheckBox generateNewKeyOnImport;
+ @FXML private CheckBox warnAboutDuplicatesOnImport;
+ @FXML private CheckBox downloadLinkedOnlineFiles;
+
@FXML private CheckBox useCustomDOI;
@FXML private TextField useCustomDOIName;
- @FXML private SaveOrderConfigPanel exportOrderPanel;
+ @FXML private CheckBox grobidEnabled;
+ @FXML private TextField grobidURL;
@FXML private ComboBox 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;
- @FXML private CheckBox downloadLinkedOnlineFiles;
-
public WebSearchTab() {
ViewLoader.view(this)
.root(this)
@@ -49,24 +46,17 @@ public String getTabName() {
public void initialize() {
this.viewModel = new WebSearchTabViewModel(preferencesService, dialogService);
- useCustomDOI.selectedProperty().bindBidirectional(viewModel.useCustomDOIProperty());
- useCustomDOIName.textProperty().bindBidirectional(viewModel.useCustomDOINameProperty());
- useCustomDOIName.disableProperty().bind(useCustomDOI.selectedProperty().not());
-
generateNewKeyOnImport.selectedProperty().bindBidirectional(viewModel.generateKeyOnImportProperty());
-
- exportOrderPanel.saveInOriginalProperty().bindBidirectional(viewModel.saveInOriginalProperty());
- exportOrderPanel.saveInTableOrderProperty().bindBidirectional(viewModel.saveInTableOrderProperty());
- exportOrderPanel.saveInSpecifiedOrderProperty().bindBidirectional(viewModel.saveInSpecifiedOrderProperty());
- exportOrderPanel.sortableFieldsProperty().bind(viewModel.sortableFieldsProperty());
- exportOrderPanel.sortCriteriaProperty().bindBidirectional(viewModel.sortCriteriaProperty());
- exportOrderPanel.setCriteriaLimit(3);
+ warnAboutDuplicatesOnImport.selectedProperty().bindBidirectional(viewModel.warnAboutDuplicatesOnImportProperty());
+ downloadLinkedOnlineFiles.selectedProperty().bindBidirectional(viewModel.shouldDownloadLinkedOnlineFiles());
grobidEnabled.selectedProperty().bindBidirectional(viewModel.grobidEnabledProperty());
grobidURL.textProperty().bindBidirectional(viewModel.grobidURLProperty());
grobidURL.disableProperty().bind(grobidEnabled.selectedProperty().not());
- downloadLinkedOnlineFiles.selectedProperty().bindBidirectional(viewModel.shouldDownloadLinkedOnlineFiles());
+ useCustomDOI.selectedProperty().bindBidirectional(viewModel.useCustomDOIProperty());
+ useCustomDOIName.textProperty().bindBidirectional(viewModel.useCustomDOINameProperty());
+ useCustomDOIName.disableProperty().bind(useCustomDOI.selectedProperty().not());
new ViewModelListCellFactory()
.withText(FetcherApiKey::getName)
@@ -90,8 +80,6 @@ public void initialize() {
// Content is set later
viewModel.fetcherApiKeys().addListener((InvalidationListener) change -> apiKeySelector.getSelectionModel().selectFirst());
-
- warnAboutDuplicatesOnImport.selectedProperty().bindBidirectional(viewModel.warnAboutDuplicatesOnImportProperty());
}
private void updateFetcherApiKey(FetcherApiKey apiKey) {
diff --git a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java
index 563b79e867e..2c6678c4a11 100644
--- a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java
@@ -2,9 +2,6 @@
import java.io.IOException;
import java.net.HttpURLConnection;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
import java.util.Optional;
import javax.net.ssl.HostnameVerifier;
@@ -22,7 +19,6 @@
import javafx.collections.FXCollections;
import org.jabref.gui.DialogService;
-import org.jabref.gui.commonfxcontrols.SortCriterionViewModel;
import org.jabref.gui.preferences.PreferenceTabViewModel;
import org.jabref.logic.importer.ImporterPreferences;
import org.jabref.logic.importer.WebFetchers;
@@ -32,34 +28,23 @@
import org.jabref.logic.net.URLDownload;
import org.jabref.logic.preferences.DOIPreferences;
import org.jabref.logic.preferences.FetcherApiKey;
-import org.jabref.model.entry.field.Field;
-import org.jabref.model.entry.field.FieldFactory;
-import org.jabref.model.metadata.SaveOrder;
import org.jabref.preferences.FilePreferences;
import org.jabref.preferences.ImportExportPreferences;
import org.jabref.preferences.PreferencesService;
public class WebSearchTabViewModel implements PreferenceTabViewModel {
-
- private final ListProperty apiKeys = new SimpleListProperty<>();
- private final ObjectProperty selectedApiKeyProperty = new SimpleObjectProperty<>();
-
private final BooleanProperty generateKeyOnImportProperty = new SimpleBooleanProperty();
+ private final BooleanProperty warnAboutDuplicatesOnImportProperty = new SimpleBooleanProperty();
+ private final BooleanProperty shouldDownloadLinkedOnlineFiles = new SimpleBooleanProperty();
private final BooleanProperty useCustomDOIProperty = new SimpleBooleanProperty();
private final StringProperty useCustomDOINameProperty = new SimpleStringProperty("");
- // SaveOrderConfigPanel
- private final BooleanProperty exportInOriginalProperty = new SimpleBooleanProperty();
- private final BooleanProperty exportInTableOrderProperty = new SimpleBooleanProperty();
- 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 StringProperty grobidURLProperty = new SimpleStringProperty("");
- private final BooleanProperty warnAboutDuplicatesOnImportProperty = new SimpleBooleanProperty();
- private final BooleanProperty shouldDownloadLinkedOnlineFiles = new SimpleBooleanProperty();
+
+ private final ListProperty apiKeys = new SimpleListProperty<>();
+ private final ObjectProperty selectedApiKeyProperty = new SimpleObjectProperty<>();
private final DialogService dialogService;
private final PreferencesService preferencesService;
@@ -82,25 +67,11 @@ public WebSearchTabViewModel(PreferencesService preferencesService, DialogServic
@Override
public void setValues() {
generateKeyOnImportProperty.setValue(importerPreferences.isGenerateNewKeyOnImport());
- useCustomDOIProperty.setValue(doiPreferences.isUseCustom());
- useCustomDOINameProperty.setValue(doiPreferences.getDefaultBaseURI());
warnAboutDuplicatesOnImportProperty.setValue(importExportPreferences.shouldWarnAboutDuplicatesOnImport());
-
shouldDownloadLinkedOnlineFiles.setValue(filePreferences.shouldDownloadLinkedFiles());
- SaveOrder exportSaveOrder = importExportPreferences.getExportSaveOrder();
- switch (exportSaveOrder.getOrderType()) {
- case SPECIFIED -> exportInSpecifiedOrderProperty.setValue(true);
- case ORIGINAL -> exportInOriginalProperty.setValue(true);
- case TABLE -> exportInTableOrderProperty.setValue(true);
- }
- sortCriteriaProperty.addAll(exportSaveOrder.getSortCriteria().stream()
- .map(SortCriterionViewModel::new)
- .toList());
-
- List fieldNames = new ArrayList<>(FieldFactory.getCommonFields());
- fieldNames.sort(Comparator.comparing(Field::getDisplayName));
- sortableFieldsProperty.addAll(fieldNames);
+ useCustomDOIProperty.setValue(doiPreferences.isUseCustom());
+ useCustomDOINameProperty.setValue(doiPreferences.getDefaultBaseURI());
grobidEnabledProperty.setValue(grobidPreferences.isGrobidEnabled());
grobidURLProperty.setValue(grobidPreferences.getGrobidURL());
@@ -111,23 +82,16 @@ public void setValues() {
@Override
public void storeSettings() {
importerPreferences.setGenerateNewKeyOnImport(generateKeyOnImportProperty.getValue());
+ importExportPreferences.setWarnAboutDuplicatesOnImport(warnAboutDuplicatesOnImportProperty.getValue());
+ filePreferences.setDownloadLinkedFiles(shouldDownloadLinkedOnlineFiles.getValue());
+
grobidPreferences.setGrobidEnabled(grobidEnabledProperty.getValue());
grobidPreferences.setGrobidOptOut(grobidPreferences.isGrobidOptOut());
grobidPreferences.setGrobidURL(grobidURLProperty.getValue());
- filePreferences.setDownloadLinkedFiles(shouldDownloadLinkedOnlineFiles.getValue());
-
doiPreferences.setUseCustom(useCustomDOIProperty.get());
doiPreferences.setDefaultBaseURI(useCustomDOINameProperty.getValue().trim());
- SaveOrder newSaveOrder = new SaveOrder(
- SaveOrder.OrderType.fromBooleans(exportInSpecifiedOrderProperty.getValue(), exportInOriginalProperty.getValue()),
- sortCriteriaProperty.stream().map(SortCriterionViewModel::getCriterion).toList());
- preferencesService.getImportExportPreferences().setExportSaveOrder(newSaveOrder);
-
- importExportPreferences.setWarnAboutDuplicatesOnImport(warnAboutDuplicatesOnImportProperty.getValue());
-
- // API keys
preferencesService.getImporterPreferences().getApiKeys().clear();
preferencesService.getImporterPreferences().getApiKeys().addAll(apiKeys);
}
@@ -144,28 +108,6 @@ public StringProperty useCustomDOINameProperty() {
return this.useCustomDOINameProperty;
}
- // SaveOrderConfigPanel
-
- public BooleanProperty saveInOriginalProperty() {
- return exportInOriginalProperty;
- }
-
- public BooleanProperty saveInTableOrderProperty() {
- return exportInTableOrderProperty;
- }
-
- public BooleanProperty saveInSpecifiedOrderProperty() {
- return exportInSpecifiedOrderProperty;
- }
-
- public ListProperty sortableFieldsProperty() {
- return sortableFieldsProperty;
- }
-
- public ListProperty sortCriteriaProperty() {
- return sortCriteriaProperty;
- }
-
public BooleanProperty grobidEnabledProperty() {
return grobidEnabledProperty;
}
From a60530a1aa6c6eb3adf8becfcd54fdf509359e64 Mon Sep 17 00:00:00 2001
From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Date: Thu, 4 May 2023 01:09:31 +0200
Subject: [PATCH 03/11] Separated WebSearchPrefs and ExportPrefs
---
.../jabref/gui/importer/ImportCommand.java | 4 +-
.../gui/importer/ImportEntriesViewModel.java | 4 +-
.../export/ExportTabViewModel.java | 8 ++--
.../preferences/file/FileTabViewModel.java | 16 +++----
.../websearch/WebSearchTabViewModel.java | 7 +--
.../logic/importer/ImporterPreferences.java | 33 ++++++++++++++
...references.java => ExportPreferences.java} | 44 +++----------------
.../jabref/preferences/JabRefPreferences.java | 31 ++++++-------
.../preferences/PreferencesService.java | 2 +-
.../exporter/ExportToClipboardActionTest.java | 4 +-
.../gui/exporter/SaveDatabaseActionTest.java | 4 +-
11 files changed, 79 insertions(+), 78 deletions(-)
rename src/main/java/org/jabref/preferences/{ImportExportPreferences.java => ExportPreferences.java} (63%)
diff --git a/src/main/java/org/jabref/gui/importer/ImportCommand.java b/src/main/java/org/jabref/gui/importer/ImportCommand.java
index 8e40e6c0c49..ab0188c6f00 100644
--- a/src/main/java/org/jabref/gui/importer/ImportCommand.java
+++ b/src/main/java/org/jabref/gui/importer/ImportCommand.java
@@ -54,7 +54,7 @@ public void execute() {
.addExtensionFilter(FileFilterConverter.ANY_FILE)
.addExtensionFilter(FileFilterConverter.forAllImporters(importers))
.addExtensionFilter(FileFilterConverter.importerToExtensionFilter(importers))
- .withInitialDirectory(preferences.getImportExportPreferences().getImportWorkingDirectory())
+ .withInitialDirectory(preferences.getImporterPreferences().getImportWorkingDirectory())
.build();
dialogService.showFileOpenDialog(fileDialogConfiguration)
.ifPresent(path -> doImport(path, importers, fileDialogConfiguration.getSelectedExtensionFilter()));
@@ -71,6 +71,6 @@ private void doImport(Path file, SortedSet importers, FileChooser.Exte
ImportAction importMenu = new ImportAction(frame, openInNew, format.orElse(null), preferences);
importMenu.automatedImport(Collections.singletonList(file.toString()));
// Set last working dir for import
- preferences.getImportExportPreferences().setImportWorkingDirectory(file.getParent());
+ preferences.getImporterPreferences().setImportWorkingDirectory(file.getParent());
}
}
diff --git a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java
index dfd27079cff..dd2277b4e98 100644
--- a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java
+++ b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java
@@ -126,7 +126,7 @@ public boolean hasDuplicate(BibEntry entry) {
public void importEntries(List entriesToImport, boolean shouldDownloadFiles) {
// Check if we are supposed to warn about duplicates.
// If so, then see if there are duplicates, and warn if yes.
- if (preferences.getImportExportPreferences().shouldWarnAboutDuplicatesOnImport()) {
+ if (preferences.getImporterPreferences().shouldWarnAboutDuplicatesOnImport()) {
BackgroundTask.wrap(() -> entriesToImport.stream()
.anyMatch(this::hasDuplicate)).onSuccess(duplicateFound -> {
if (duplicateFound) {
@@ -135,7 +135,7 @@ public void importEntries(List entriesToImport, boolean shouldDownload
Localization.lang("Continue with import"),
Localization.lang("Cancel import"),
Localization.lang("Do not ask again"),
- optOut -> preferences.getImportExportPreferences().setWarnAboutDuplicatesOnImport(!optOut));
+ optOut -> preferences.getImporterPreferences().setWarnAboutDuplicatesOnImport(!optOut));
if (!continueImport) {
dialogService.notify(Localization.lang("Import canceled"));
diff --git a/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java b/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java
index 1753c7bf3cb..d8e90fa94d9 100644
--- a/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java
@@ -15,7 +15,7 @@
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.metadata.SaveOrder;
-import org.jabref.preferences.ImportExportPreferences;
+import org.jabref.preferences.ExportPreferences;
import org.jabref.preferences.PreferencesService;
public class ExportTabViewModel implements PreferenceTabViewModel {
@@ -28,16 +28,16 @@ public class ExportTabViewModel implements PreferenceTabViewModel {
private final ListProperty sortCriteriaProperty = new SimpleListProperty<>(FXCollections.observableArrayList(new ArrayList<>()));
private final PreferencesService preferencesService;
- private final ImportExportPreferences importExportPreferences;
+ private final ExportPreferences exportPreferences;
public ExportTabViewModel(PreferencesService preferencesService) {
this.preferencesService = preferencesService;
- this.importExportPreferences = preferencesService.getImportExportPreferences();
+ this.exportPreferences = preferencesService.getImportExportPreferences();
}
@Override
public void setValues() {
- SaveOrder exportSaveOrder = importExportPreferences.getExportSaveOrder();
+ SaveOrder exportSaveOrder = exportPreferences.getExportSaveOrder();
switch (exportSaveOrder.getOrderType()) {
case SPECIFIED -> exportInSpecifiedOrderProperty.setValue(true);
case ORIGINAL -> exportInOriginalProperty.setValue(true);
diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java b/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
index 2be81ba1a83..2764c5f63f9 100644
--- a/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
@@ -8,7 +8,7 @@
import org.jabref.gui.preferences.PreferenceTabViewModel;
import org.jabref.logic.bibtex.FieldPreferences;
import org.jabref.model.entry.field.FieldFactory;
-import org.jabref.preferences.ImportExportPreferences;
+import org.jabref.preferences.ExportPreferences;
public class FileTabViewModel implements PreferenceTabViewModel {
@@ -19,11 +19,11 @@ public class FileTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty alwaysReformatBibProperty = new SimpleBooleanProperty();
private final BooleanProperty autosaveLocalLibraries = new SimpleBooleanProperty();
- private final ImportExportPreferences importExportPreferences;
+ private final ExportPreferences exportPreferences;
private final FieldPreferences fieldPreferences;
- FileTabViewModel(ImportExportPreferences importExportPreferences, FieldPreferences fieldPreferences) {
- this.importExportPreferences = importExportPreferences;
+ FileTabViewModel(ExportPreferences exportPreferences, FieldPreferences fieldPreferences) {
+ this.exportPreferences = exportPreferences;
this.fieldPreferences = fieldPreferences;
}
@@ -34,8 +34,8 @@ public void setValues() {
doNotResolveStringsProperty.setValue(!fieldPreferences.shouldResolveStrings());
resolveStringsProperty.setValue(fieldPreferences.shouldResolveStrings());
resolveStringsForFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getResolvableFields()));
- alwaysReformatBibProperty.setValue(importExportPreferences.shouldAlwaysReformatOnSave());
- autosaveLocalLibraries.setValue(importExportPreferences.shouldAutoSave());
+ alwaysReformatBibProperty.setValue(exportPreferences.shouldAlwaysReformatOnSave());
+ autosaveLocalLibraries.setValue(exportPreferences.shouldAutoSave());
}
@Override
@@ -43,8 +43,8 @@ public void storeSettings() {
fieldPreferences.setResolveStrings(!doNotResolveStringsProperty.getValue());
fieldPreferences.setNonWrappableFields(FieldFactory.parseFieldList(noWrapFilesProperty.getValue().trim()));
fieldPreferences.setResolvableFields(FieldFactory.parseFieldList(resolveStringsForFieldsProperty.getValue().trim()));
- importExportPreferences.setAlwaysReformatOnSave(alwaysReformatBibProperty.getValue());
- importExportPreferences.setAutoSave(autosaveLocalLibraries.getValue());
+ exportPreferences.setAlwaysReformatOnSave(alwaysReformatBibProperty.getValue());
+ exportPreferences.setAutoSave(autosaveLocalLibraries.getValue());
}
// ImportExport
diff --git a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java
index 2c6678c4a11..b623728413d 100644
--- a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java
@@ -29,7 +29,6 @@
import org.jabref.logic.preferences.DOIPreferences;
import org.jabref.logic.preferences.FetcherApiKey;
import org.jabref.preferences.FilePreferences;
-import org.jabref.preferences.ImportExportPreferences;
import org.jabref.preferences.PreferencesService;
public class WebSearchTabViewModel implements PreferenceTabViewModel {
@@ -51,7 +50,6 @@ public class WebSearchTabViewModel implements PreferenceTabViewModel {
private final DOIPreferences doiPreferences;
private final GrobidPreferences grobidPreferences;
private final ImporterPreferences importerPreferences;
- private final ImportExportPreferences importExportPreferences;
private final FilePreferences filePreferences;
public WebSearchTabViewModel(PreferencesService preferencesService, DialogService dialogService) {
@@ -60,14 +58,13 @@ public WebSearchTabViewModel(PreferencesService preferencesService, DialogServic
this.importerPreferences = preferencesService.getImporterPreferences();
this.grobidPreferences = preferencesService.getGrobidPreferences();
this.doiPreferences = preferencesService.getDOIPreferences();
- this.importExportPreferences = preferencesService.getImportExportPreferences();
this.filePreferences = preferencesService.getFilePreferences();
}
@Override
public void setValues() {
generateKeyOnImportProperty.setValue(importerPreferences.isGenerateNewKeyOnImport());
- warnAboutDuplicatesOnImportProperty.setValue(importExportPreferences.shouldWarnAboutDuplicatesOnImport());
+ warnAboutDuplicatesOnImportProperty.setValue(importerPreferences.shouldWarnAboutDuplicatesOnImport());
shouldDownloadLinkedOnlineFiles.setValue(filePreferences.shouldDownloadLinkedFiles());
useCustomDOIProperty.setValue(doiPreferences.isUseCustom());
@@ -82,7 +79,7 @@ public void setValues() {
@Override
public void storeSettings() {
importerPreferences.setGenerateNewKeyOnImport(generateKeyOnImportProperty.getValue());
- importExportPreferences.setWarnAboutDuplicatesOnImport(warnAboutDuplicatesOnImportProperty.getValue());
+ importerPreferences.setWarnAboutDuplicatesOnImport(warnAboutDuplicatesOnImportProperty.getValue());
filePreferences.setDownloadLinkedFiles(shouldDownloadLinkedOnlineFiles.getValue());
grobidPreferences.setGrobidEnabled(grobidEnabledProperty.getValue());
diff --git a/src/main/java/org/jabref/logic/importer/ImporterPreferences.java b/src/main/java/org/jabref/logic/importer/ImporterPreferences.java
index 198eab8e51e..ce95bfd4354 100644
--- a/src/main/java/org/jabref/logic/importer/ImporterPreferences.java
+++ b/src/main/java/org/jabref/logic/importer/ImporterPreferences.java
@@ -1,9 +1,12 @@
package org.jabref.logic.importer;
+import java.nio.file.Path;
import java.util.Set;
import javafx.beans.property.BooleanProperty;
+import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
+import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableSet;
@@ -13,13 +16,19 @@
public class ImporterPreferences {
private final BooleanProperty generateNewKeyOnImport;
+ private final BooleanProperty warnAboutDuplicatesOnImport;
+ private final ObjectProperty importWorkingDirectory;
private final ObservableSet apiKeys;
private final ObservableSet customImportList;
public ImporterPreferences(boolean generateNewKeyOnImport,
+ Path importWorkingDirectory,
+ boolean warnAboutDuplicatesOnImport,
Set customImportList,
Set apiKeys) {
this.generateNewKeyOnImport = new SimpleBooleanProperty(generateNewKeyOnImport);
+ this.importWorkingDirectory = new SimpleObjectProperty<>(importWorkingDirectory);
+ this.warnAboutDuplicatesOnImport = new SimpleBooleanProperty(warnAboutDuplicatesOnImport);
this.customImportList = FXCollections.observableSet(customImportList);
this.apiKeys = FXCollections.observableSet(apiKeys);
}
@@ -36,6 +45,30 @@ public void setGenerateNewKeyOnImport(boolean generateNewKeyOnImport) {
this.generateNewKeyOnImport.set(generateNewKeyOnImport);
}
+ public Path getImportWorkingDirectory() {
+ return importWorkingDirectory.get();
+ }
+
+ public ObjectProperty importWorkingDirectoryProperty() {
+ return importWorkingDirectory;
+ }
+
+ public void setImportWorkingDirectory(Path importWorkingDirectory) {
+ this.importWorkingDirectory.set(importWorkingDirectory);
+ }
+
+ public boolean shouldWarnAboutDuplicatesOnImport() {
+ return warnAboutDuplicatesOnImport.get();
+ }
+
+ public BooleanProperty warnAboutDuplicatesOnImportProperty() {
+ return warnAboutDuplicatesOnImport;
+ }
+
+ public void setWarnAboutDuplicatesOnImport(boolean warnAboutDuplicatesOnImport) {
+ this.warnAboutDuplicatesOnImport.set(warnAboutDuplicatesOnImport);
+ }
+
public ObservableSet getApiKeys() {
return apiKeys;
}
diff --git a/src/main/java/org/jabref/preferences/ImportExportPreferences.java b/src/main/java/org/jabref/preferences/ExportPreferences.java
similarity index 63%
rename from src/main/java/org/jabref/preferences/ImportExportPreferences.java
rename to src/main/java/org/jabref/preferences/ExportPreferences.java
index 2ee110f4795..71548dbd49e 100644
--- a/src/main/java/org/jabref/preferences/ImportExportPreferences.java
+++ b/src/main/java/org/jabref/preferences/ExportPreferences.java
@@ -11,29 +11,23 @@
import org.jabref.model.metadata.SaveOrder;
-public class ImportExportPreferences {
+public class ExportPreferences {
private final BooleanProperty alwaysReformatOnSave;
- private final ObjectProperty importWorkingDirectory;
private final StringProperty lastExportExtension;
private final ObjectProperty exportWorkingDirectory;
private final ObjectProperty exportSaveOrder;
private final BooleanProperty autoSave;
- private final BooleanProperty warnAboutDuplicatesOnImport;
-
- public ImportExportPreferences(boolean alwaysReformatOnSave,
- Path importWorkingDirectory,
- String lastExportExtension,
- Path exportWorkingDirectory,
- SaveOrder exportSaveOrder,
- boolean autoSave,
- boolean warnAboutDuplicatesOnImport) {
+
+ public ExportPreferences(boolean alwaysReformatOnSave,
+ String lastExportExtension,
+ Path exportWorkingDirectory,
+ SaveOrder exportSaveOrder,
+ boolean autoSave) {
this.alwaysReformatOnSave = new SimpleBooleanProperty(alwaysReformatOnSave);
- this.importWorkingDirectory = new SimpleObjectProperty<>(importWorkingDirectory);
this.lastExportExtension = new SimpleStringProperty(lastExportExtension);
this.exportWorkingDirectory = new SimpleObjectProperty<>(exportWorkingDirectory);
this.exportSaveOrder = new SimpleObjectProperty<>(exportSaveOrder);
this.autoSave = new SimpleBooleanProperty(autoSave);
- this.warnAboutDuplicatesOnImport = new SimpleBooleanProperty(warnAboutDuplicatesOnImport);
}
public boolean shouldAlwaysReformatOnSave() {
@@ -48,18 +42,6 @@ public void setAlwaysReformatOnSave(boolean alwaysReformatOnSave) {
this.alwaysReformatOnSave.set(alwaysReformatOnSave);
}
- public Path getImportWorkingDirectory() {
- return importWorkingDirectory.get();
- }
-
- public ObjectProperty importWorkingDirectoryProperty() {
- return importWorkingDirectory;
- }
-
- public void setImportWorkingDirectory(Path importWorkingDirectory) {
- this.importWorkingDirectory.set(importWorkingDirectory);
- }
-
public String getLastExportExtension() {
return lastExportExtension.get();
}
@@ -107,16 +89,4 @@ public BooleanProperty autoSaveProperty() {
public void setAutoSave(boolean shouldAutoSave) {
this.autoSave.set(shouldAutoSave);
}
-
- public boolean shouldWarnAboutDuplicatesOnImport() {
- return warnAboutDuplicatesOnImport.get();
- }
-
- public BooleanProperty warnAboutDuplicatesOnImportProperty() {
- return warnAboutDuplicatesOnImport;
- }
-
- public void setWarnAboutDuplicatesOnImport(boolean warnAboutDuplicatesOnImport) {
- this.warnAboutDuplicatesOnImport.set(warnAboutDuplicatesOnImport);
- }
}
diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java
index 1763fe4a2ac..6739763d255 100644
--- a/src/main/java/org/jabref/preferences/JabRefPreferences.java
+++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java
@@ -444,7 +444,7 @@ public class JabRefPreferences implements PreferencesService {
private SSLPreferences sslPreferences;
private SearchPreferences searchPreferences;
private AutoLinkPreferences autoLinkPreferences;
- private ImportExportPreferences importExportPreferences;
+ private ExportPreferences exportPreferences;
private NameFormatterPreferences nameFormatterPreferences;
private BibEntryPreferences bibEntryPreferences;
private InternalPreferences internalPreferences;
@@ -2177,28 +2177,25 @@ public AutoLinkPreferences getAutoLinkPreferences() {
//*************************************************************************************************************
@Override
- public ImportExportPreferences getImportExportPreferences() {
- if (Objects.nonNull(importExportPreferences)) {
- return importExportPreferences;
+ public ExportPreferences getImportExportPreferences() {
+ if (Objects.nonNull(exportPreferences)) {
+ return exportPreferences;
}
- importExportPreferences = new ImportExportPreferences(
+ exportPreferences = new ExportPreferences(
getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT),
- Path.of(get(IMPORT_WORKING_DIRECTORY)),
get(LAST_USED_EXPORT),
Path.of(get(EXPORT_WORKING_DIRECTORY)),
getExportSaveOrder(),
- getBoolean(LOCAL_AUTO_SAVE), getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION));
+ getBoolean(LOCAL_AUTO_SAVE));
- EasyBind.listen(importExportPreferences.alwaysReformatOnSaveProperty(), (obs, oldValue, newValue) -> putBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT, newValue));
- EasyBind.listen(importExportPreferences.importWorkingDirectoryProperty(), (obs, oldValue, newValue) -> put(IMPORT_WORKING_DIRECTORY, newValue.toString()));
- EasyBind.listen(importExportPreferences.lastExportExtensionProperty(), (obs, oldValue, newValue) -> put(LAST_USED_EXPORT, newValue));
- EasyBind.listen(importExportPreferences.exportWorkingDirectoryProperty(), (obs, oldValue, newValue) -> put(EXPORT_WORKING_DIRECTORY, newValue.toString()));
- EasyBind.listen(importExportPreferences.exportSaveOrderProperty(), (obs, oldValue, newValue) -> storeExportSaveOrder(newValue));
- EasyBind.listen(importExportPreferences.autoSaveProperty(), (obs, oldValue, newValue) -> putBoolean(LOCAL_AUTO_SAVE, newValue));
- EasyBind.listen(importExportPreferences.warnAboutDuplicatesOnImportProperty(), (obs, oldValue, newValue) -> putBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION, newValue));
+ EasyBind.listen(exportPreferences.alwaysReformatOnSaveProperty(), (obs, oldValue, newValue) -> putBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT, newValue));
+ EasyBind.listen(exportPreferences.lastExportExtensionProperty(), (obs, oldValue, newValue) -> put(LAST_USED_EXPORT, newValue));
+ EasyBind.listen(exportPreferences.exportWorkingDirectoryProperty(), (obs, oldValue, newValue) -> put(EXPORT_WORKING_DIRECTORY, newValue.toString()));
+ EasyBind.listen(exportPreferences.exportSaveOrderProperty(), (obs, oldValue, newValue) -> storeExportSaveOrder(newValue));
+ EasyBind.listen(exportPreferences.autoSaveProperty(), (obs, oldValue, newValue) -> putBoolean(LOCAL_AUTO_SAVE, newValue));
- return importExportPreferences;
+ return exportPreferences;
}
public SaveOrder getExportSaveOrder() {
@@ -2757,11 +2754,15 @@ public ImporterPreferences getImporterPreferences() {
importerPreferences = new ImporterPreferences(
getBoolean(GENERATE_KEY_ON_IMPORT),
+ Path.of(get(IMPORT_WORKING_DIRECTORY)),
+ getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION),
getCustomImportFormats(),
getFetcherKeys()
);
EasyBind.listen(importerPreferences.generateNewKeyOnImportProperty(), (obs, oldValue, newValue) -> putBoolean(GENERATE_KEY_ON_IMPORT, newValue));
+ EasyBind.listen(importerPreferences.importWorkingDirectoryProperty(), (obs, oldValue, newValue) -> put(IMPORT_WORKING_DIRECTORY, newValue.toString()));
+ EasyBind.listen(importerPreferences.warnAboutDuplicatesOnImportProperty(), (obs, oldValue, newValue) -> putBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION, newValue));
importerPreferences.getApiKeys().addListener((InvalidationListener) c -> storeFetcherKeys(importerPreferences.getApiKeys()));
importerPreferences.getCustomImportList().addListener((InvalidationListener) c -> storeCustomImportFormats(importerPreferences.getCustomImportList()));
diff --git a/src/main/java/org/jabref/preferences/PreferencesService.java b/src/main/java/org/jabref/preferences/PreferencesService.java
index c28cd1746c1..03d75614fbb 100644
--- a/src/main/java/org/jabref/preferences/PreferencesService.java
+++ b/src/main/java/org/jabref/preferences/PreferencesService.java
@@ -171,7 +171,7 @@ public interface PreferencesService {
// Import/Export preferences
//*************************************************************************************************************
- ImportExportPreferences getImportExportPreferences();
+ ExportPreferences getImportExportPreferences();
List getCustomExportFormats(JournalAbbreviationRepository repository);
diff --git a/src/test/java/org/jabref/gui/exporter/ExportToClipboardActionTest.java b/src/test/java/org/jabref/gui/exporter/ExportToClipboardActionTest.java
index b2f82ad2a28..aeacfc8e219 100644
--- a/src/test/java/org/jabref/gui/exporter/ExportToClipboardActionTest.java
+++ b/src/test/java/org/jabref/gui/exporter/ExportToClipboardActionTest.java
@@ -24,9 +24,9 @@
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.model.metadata.MetaData;
+import org.jabref.preferences.ExportPreferences;
import org.jabref.preferences.FilePreferences;
import org.jabref.preferences.GeneralPreferences;
-import org.jabref.preferences.ImportExportPreferences;
import org.jabref.preferences.PreferencesService;
import org.junit.jupiter.api.BeforeEach;
@@ -49,7 +49,7 @@ public class ExportToClipboardActionTest {
private final ClipBoardManager clipBoardManager = mock(ClipBoardManager.class);
private final BibDatabaseContext databaseContext = mock(BibDatabaseContext.class);
private final PreferencesService preferences = mock(PreferencesService.class);
- private final ImportExportPreferences importExportPrefs = mock(ImportExportPreferences.class);
+ private final ExportPreferences importExportPrefs = mock(ExportPreferences.class);
private final StateManager stateManager = mock(StateManager.class);
private ExporterFactory exporterFactory;
diff --git a/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java b/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java
index 42f6f9fc72e..91035d7232e 100644
--- a/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java
+++ b/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java
@@ -28,8 +28,8 @@
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.metadata.MetaData;
import org.jabref.model.metadata.SaveOrder;
+import org.jabref.preferences.ExportPreferences;
import org.jabref.preferences.FilePreferences;
-import org.jabref.preferences.ImportExportPreferences;
import org.jabref.preferences.JabRefPreferences;
import org.junit.jupiter.api.BeforeEach;
@@ -63,7 +63,7 @@ public void setUp() {
when(libraryTab.getBibDatabaseContext()).thenReturn(dbContext);
when(filePreferences.getWorkingDirectory()).thenReturn(Path.of(TEST_BIBTEX_LIBRARY_LOCATION));
when(preferences.getFilePreferences()).thenReturn(filePreferences);
- when(preferences.getImportExportPreferences()).thenReturn(mock(ImportExportPreferences.class));
+ when(preferences.getImportExportPreferences()).thenReturn(mock(ExportPreferences.class));
when(jabRefFrame.getDialogService()).thenReturn(dialogService);
saveDatabaseAction = spy(new SaveDatabaseAction(libraryTab, preferences, mock(BibEntryTypesManager.class)));
}
From 455e3cb0bc0439ca6f33239d5d553b9205a1d578 Mon Sep 17 00:00:00 2001
From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Date: Thu, 4 May 2023 16:28:49 +0200
Subject: [PATCH 04/11] Renamed ImportExportPreferences to ExportPreferences
---
.../org/jabref/cli/ArgumentProcessor.java | 2 +-
src/main/java/org/jabref/gui/LibraryTab.java | 4 +--
.../jabref/gui/copyfiles/CopyFilesAction.java | 2 +-
.../CreateModifyExporterDialogViewModel.java | 4 +--
.../jabref/gui/exporter/ExportCommand.java | 8 ++---
.../gui/exporter/ExportToClipboardAction.java | 4 +--
.../gui/exporter/SaveDatabaseAction.java | 2 +-
.../saving/SavingPropertiesViewModel.java | 2 +-
.../gui/preferences/export/ExportTab.fxml | 10 ++++++
.../gui/preferences/export/ExportTab.java | 19 ++++++++--
.../export/ExportTabViewModel.java | 26 ++++++++++----
.../jabref/gui/preferences/file/FileTab.fxml | 14 +-------
.../jabref/gui/preferences/file/FileTab.java | 35 +++++--------------
.../preferences/file/FileTabViewModel.java | 34 ++++--------------
.../autosaveandbackup/BackupManager.java | 2 +-
.../jabref/logic/crawler/StudyRepository.java | 2 +-
.../jabref/preferences/JabRefPreferences.java | 4 +--
.../preferences/PreferencesService.java | 2 +-
.../exporter/ExportToClipboardActionTest.java | 2 +-
.../gui/exporter/SaveDatabaseActionTest.java | 2 +-
20 files changed, 83 insertions(+), 97 deletions(-)
diff --git a/src/main/java/org/jabref/cli/ArgumentProcessor.java b/src/main/java/org/jabref/cli/ArgumentProcessor.java
index b478c4a9a57..45ce8ba77d0 100644
--- a/src/main/java/org/jabref/cli/ArgumentProcessor.java
+++ b/src/main/java/org/jabref/cli/ArgumentProcessor.java
@@ -533,7 +533,7 @@ private void saveDatabase(BibDatabase newBase, String subName) {
try (AtomicFileWriter fileWriter = new AtomicFileWriter(Path.of(subName), StandardCharsets.UTF_8)) {
BibWriter bibWriter = new BibWriter(fileWriter, OS.NEWLINE);
SaveConfiguration saveConfiguration = new SaveConfiguration()
- .withReformatOnSave(preferencesService.getImportExportPreferences().shouldAlwaysReformatOnSave());
+ .withReformatOnSave(preferencesService.getExportPreferences().shouldAlwaysReformatOnSave());
BibDatabaseWriter databaseWriter = new BibtexDatabaseWriter(
bibWriter,
diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java
index 6edf841e0df..e9fa8dd6034 100644
--- a/src/main/java/org/jabref/gui/LibraryTab.java
+++ b/src/main/java/org/jabref/gui/LibraryTab.java
@@ -297,7 +297,7 @@ public void installAutosaveManagerAndBackupManager() {
private boolean isDatabaseReadyForAutoSave(BibDatabaseContext context) {
return ((context.getLocation() == DatabaseLocation.SHARED)
|| ((context.getLocation() == DatabaseLocation.LOCAL)
- && preferencesService.getImportExportPreferences().shouldAutoSave()))
+ && preferencesService.getExportPreferences().shouldAutoSave()))
&& context.getDatabasePath().isPresent();
}
@@ -313,7 +313,7 @@ private boolean isDatabaseReadyForBackup(BibDatabaseContext context) {
* Example: *jabref-authors.bib – testbib
*/
public void updateTabTitle(boolean isChanged) {
- boolean isAutosaveEnabled = preferencesService.getImportExportPreferences().shouldAutoSave();
+ boolean isAutosaveEnabled = preferencesService.getExportPreferences().shouldAutoSave();
DatabaseLocation databaseLocation = bibDatabaseContext.getLocation();
Optional file = bibDatabaseContext.getDatabasePath();
diff --git a/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java b/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java
index 4317dbeef8e..77d38da37a9 100644
--- a/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java
+++ b/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java
@@ -47,7 +47,7 @@ public void execute() {
List entries = stateManager.getSelectedEntries();
DirectoryDialogConfiguration dirDialogConfiguration = new DirectoryDialogConfiguration.Builder()
- .withInitialDirectory(preferencesService.getImportExportPreferences().getExportWorkingDirectory())
+ .withInitialDirectory(preferencesService.getExportPreferences().getExportWorkingDirectory())
.build();
Optional exportPath = dialogService.showDirectorySelectionDialog(dirDialogConfiguration);
exportPath.ifPresent(path -> {
diff --git a/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialogViewModel.java b/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialogViewModel.java
index cd08d6a56e8..2fae491983f 100644
--- a/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialogViewModel.java
@@ -58,7 +58,7 @@ public CreateModifyExporterDialogViewModel(ExporterViewModel exporter,
public ExporterViewModel saveExporter() {
Path layoutFileDir = Path.of(layoutFile.get()).getParent();
if (layoutFileDir != null) {
- preferences.getImportExportPreferences().setExportWorkingDirectory(layoutFileDir);
+ preferences.getExportPreferences().setExportWorkingDirectory(layoutFileDir);
}
// Check that there are no empty strings.
@@ -85,7 +85,7 @@ public void browse() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(Localization.lang("Custom layout file"), StandardFileType.LAYOUT)
.withDefaultExtension(Localization.lang("Custom layout file"), StandardFileType.LAYOUT)
- .withInitialDirectory(preferences.getImportExportPreferences().getExportWorkingDirectory()).build();
+ .withInitialDirectory(preferences.getExportPreferences().getExportWorkingDirectory()).build();
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(f -> layoutFile.set(f.toAbsolutePath().toString()));
}
diff --git a/src/main/java/org/jabref/gui/exporter/ExportCommand.java b/src/main/java/org/jabref/gui/exporter/ExportCommand.java
index c5479d8c2cd..672615b6c2a 100644
--- a/src/main/java/org/jabref/gui/exporter/ExportCommand.java
+++ b/src/main/java/org/jabref/gui/exporter/ExportCommand.java
@@ -78,8 +78,8 @@ public void execute() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(FileFilterConverter.exporterToExtensionFilter(exporters))
- .withDefaultExtension(preferences.getImportExportPreferences().getLastExportExtension())
- .withInitialDirectory(preferences.getImportExportPreferences().getExportWorkingDirectory())
+ .withDefaultExtension(preferences.getExportPreferences().getLastExportExtension())
+ .withInitialDirectory(preferences.getExportPreferences().getExportWorkingDirectory())
.build();
dialogService.showFileSaveDialog(fileDialogConfiguration)
.ifPresent(path -> export(path, fileDialogConfiguration.getSelectedExtensionFilter(), exporters));
@@ -110,8 +110,8 @@ private void export(Path file, FileChooser.ExtensionFilter selectedExtensionFilt
// Make sure we remember which filter was used, to set
// the default for next time:
- preferences.getImportExportPreferences().setLastExportExtension(format.getName());
- preferences.getImportExportPreferences().setExportWorkingDirectory(file.getParent());
+ preferences.getExportPreferences().setLastExportExtension(format.getName());
+ preferences.getExportPreferences().setExportWorkingDirectory(file.getParent());
final List finEntries = entries;
diff --git a/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java b/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java
index 79a044aef28..9ef046d4207 100644
--- a/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java
+++ b/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java
@@ -84,7 +84,7 @@ public void execute() {
// Find default choice, if any
Exporter defaultChoice = exporters.stream()
- .filter(exporter -> exporter.getName().equals(preferences.getImportExportPreferences().getLastExportExtension()))
+ .filter(exporter -> exporter.getName().equals(preferences.getExportPreferences().getLastExportExtension()))
.findAny()
.orElse(null);
@@ -107,7 +107,7 @@ private ExportResult exportToClipboard(Exporter exporter) throws Exception {
.orElse(List.of(preferences.getFilePreferences().getWorkingDirectory()));
// Add chosen export type to last used preference, to become default
- preferences.getImportExportPreferences().setLastExportExtension(exporter.getName());
+ preferences.getExportPreferences().setLastExportExtension(exporter.getName());
Path tmp = null;
try {
diff --git a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
index 78d79b3ff3e..95fa69f1777 100644
--- a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
+++ b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
@@ -233,7 +233,7 @@ private boolean saveDatabase(Path file, boolean selectedOnly, Charset encoding,
SaveConfiguration saveConfiguration = new SaveConfiguration()
.withSaveType(saveType)
- .withReformatOnSave(preferences.getImportExportPreferences().shouldAlwaysReformatOnSave());
+ .withReformatOnSave(preferences.getExportPreferences().shouldAlwaysReformatOnSave());
BibDatabaseContext bibDatabaseContext = libraryTab.getBibDatabaseContext();
synchronized (bibDatabaseContext) {
try (AtomicFileWriter fileWriter = new AtomicFileWriter(file, encoding, saveConfiguration.shouldMakeBackup())) {
diff --git a/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java b/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java
index 848645ae318..3216e60e2ed 100644
--- a/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java
+++ b/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java
@@ -50,7 +50,7 @@ public SavingPropertiesViewModel(BibDatabaseContext databaseContext, Preferences
this.preferencesService = preferencesService;
this.initialMetaData = databaseContext.getMetaData();
this.exportSaveOrder = initialMetaData.getSaveOrderConfig()
- .orElseGet(() -> preferencesService.getImportExportPreferences().getExportSaveOrder());
+ .orElseGet(() -> preferencesService.getExportPreferences().getExportSaveOrder());
}
@Override
diff --git a/src/main/java/org/jabref/gui/preferences/export/ExportTab.fxml b/src/main/java/org/jabref/gui/preferences/export/ExportTab.fxml
index c5b107c39c9..315ffa89114 100644
--- a/src/main/java/org/jabref/gui/preferences/export/ExportTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/export/ExportTab.fxml
@@ -1,6 +1,9 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/org/jabref/gui/preferences/export/ExportTab.java b/src/main/java/org/jabref/gui/preferences/export/ExportTab.java
index 94f2b9d963b..b6fde7f115d 100644
--- a/src/main/java/org/jabref/gui/preferences/export/ExportTab.java
+++ b/src/main/java/org/jabref/gui/preferences/export/ExportTab.java
@@ -1,18 +1,28 @@
package org.jabref.gui.preferences.export;
import javafx.fxml.FXML;
+import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
+import org.jabref.gui.Globals;
+import org.jabref.gui.actions.ActionFactory;
+import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.commonfxcontrols.SaveOrderConfigPanel;
+import org.jabref.gui.help.HelpAction;
import org.jabref.gui.preferences.AbstractPreferenceTabView;
import org.jabref.gui.preferences.PreferencesTab;
+import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
import com.airhacks.afterburner.views.ViewLoader;
public class ExportTab extends AbstractPreferenceTabView implements PreferencesTab {
-
@FXML private SaveOrderConfigPanel exportOrderPanel;
+ @FXML private CheckBox alwaysReformatBib;
+ @FXML private CheckBox autosaveLocalLibraries;
+ @FXML private Button autosaveLocalLibrariesHelp;
+
public ExportTab() {
ViewLoader.view(this)
.root(this)
@@ -25,7 +35,7 @@ public String getTabName() {
}
public void initialize() {
- this.viewModel = new ExportTabViewModel(preferencesService);
+ this.viewModel = new ExportTabViewModel(preferencesService.getExportPreferences());
exportOrderPanel.saveInOriginalProperty().bindBidirectional(viewModel.saveInOriginalProperty());
exportOrderPanel.saveInTableOrderProperty().bindBidirectional(viewModel.saveInTableOrderProperty());
@@ -33,5 +43,10 @@ public void initialize() {
exportOrderPanel.sortableFieldsProperty().bind(viewModel.sortableFieldsProperty());
exportOrderPanel.sortCriteriaProperty().bindBidirectional(viewModel.sortCriteriaProperty());
exportOrderPanel.setCriteriaLimit(3);
+
+ alwaysReformatBib.selectedProperty().bindBidirectional(viewModel.alwaysReformatBibProperty());
+ autosaveLocalLibraries.selectedProperty().bindBidirectional(viewModel.autosaveLocalLibrariesProperty());
+ ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs());
+ actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AUTOSAVE, dialogService), autosaveLocalLibrariesHelp);
}
}
diff --git a/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java b/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java
index d8e90fa94d9..ede1112a65e 100644
--- a/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java
@@ -16,7 +16,6 @@
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.metadata.SaveOrder;
import org.jabref.preferences.ExportPreferences;
-import org.jabref.preferences.PreferencesService;
public class ExportTabViewModel implements PreferenceTabViewModel {
@@ -27,12 +26,13 @@ public class ExportTabViewModel implements PreferenceTabViewModel {
private final ListProperty sortableFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
private final ListProperty sortCriteriaProperty = new SimpleListProperty<>(FXCollections.observableArrayList(new ArrayList<>()));
- private final PreferencesService preferencesService;
+ private final BooleanProperty alwaysReformatBibProperty = new SimpleBooleanProperty();
+ private final BooleanProperty autosaveLocalLibraries = new SimpleBooleanProperty();
+
private final ExportPreferences exportPreferences;
- public ExportTabViewModel(PreferencesService preferencesService) {
- this.preferencesService = preferencesService;
- this.exportPreferences = preferencesService.getImportExportPreferences();
+ public ExportTabViewModel(ExportPreferences exportPreferences) {
+ this.exportPreferences = exportPreferences;
}
@Override
@@ -50,6 +50,9 @@ public void setValues() {
List fieldNames = new ArrayList<>(FieldFactory.getCommonFields());
fieldNames.sort(Comparator.comparing(Field::getDisplayName));
sortableFieldsProperty.addAll(fieldNames);
+
+ alwaysReformatBibProperty.setValue(exportPreferences.shouldAlwaysReformatOnSave());
+ autosaveLocalLibraries.setValue(exportPreferences.shouldAutoSave());
}
@Override
@@ -57,7 +60,10 @@ public void storeSettings() {
SaveOrder newSaveOrder = new SaveOrder(
SaveOrder.OrderType.fromBooleans(exportInSpecifiedOrderProperty.getValue(), exportInOriginalProperty.getValue()),
sortCriteriaProperty.stream().map(SortCriterionViewModel::getCriterion).toList());
- preferencesService.getImportExportPreferences().setExportSaveOrder(newSaveOrder);
+ exportPreferences.setExportSaveOrder(newSaveOrder);
+
+ exportPreferences.setAlwaysReformatOnSave(alwaysReformatBibProperty.getValue());
+ exportPreferences.setAutoSave(autosaveLocalLibraries.getValue());
}
public BooleanProperty saveInOriginalProperty() {
@@ -79,4 +85,12 @@ public ListProperty sortableFieldsProperty() {
public ListProperty sortCriteriaProperty() {
return sortCriteriaProperty;
}
+
+ public BooleanProperty alwaysReformatBibProperty() {
+ return alwaysReformatBibProperty;
+ }
+
+ public BooleanProperty autosaveLocalLibrariesProperty() {
+ return autosaveLocalLibraries;
+ }
}
diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml b/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml
index 52863e25cab..98cb7e94aa4 100644
--- a/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml
@@ -1,7 +1,5 @@
-
-
@@ -24,18 +22,8 @@
-
-
-
-
-
-
-
-
-
+
-
-
diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTab.java b/src/main/java/org/jabref/gui/preferences/file/FileTab.java
index 63778cf91c8..b8542a9aedf 100644
--- a/src/main/java/org/jabref/gui/preferences/file/FileTab.java
+++ b/src/main/java/org/jabref/gui/preferences/file/FileTab.java
@@ -1,32 +1,20 @@
package org.jabref.gui.preferences.file;
import javafx.fxml.FXML;
-import javafx.scene.control.Button;
-import javafx.scene.control.CheckBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
-import org.jabref.gui.Globals;
-import org.jabref.gui.actions.ActionFactory;
-import org.jabref.gui.actions.StandardActions;
-import org.jabref.gui.help.HelpAction;
import org.jabref.gui.preferences.AbstractPreferenceTabView;
import org.jabref.gui.preferences.PreferencesTab;
-import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
import com.airhacks.afterburner.views.ViewLoader;
public class FileTab extends AbstractPreferenceTabView implements PreferencesTab {
-
- @FXML private TextField noWrapFiles;
@FXML private RadioButton doNotResolveStrings;
@FXML private RadioButton resolveStrings;
@FXML private TextField resolveStringsForFields;
- @FXML private CheckBox alwaysReformatBib;
-
- @FXML private CheckBox autosaveLocalLibraries;
- @FXML private Button autosaveLocalLibrariesHelp;
+ @FXML private TextField nonWrappableFields;
public FileTab() {
ViewLoader.view(this)
@@ -34,25 +22,18 @@ public FileTab() {
.load();
}
- public void initialize() {
- this.viewModel = new FileTabViewModel(preferencesService.getImportExportPreferences(), preferencesService.getFieldPreferences());
+ @Override
+ public String getTabName() {
+ return Localization.lang("File");
+ }
- noWrapFiles.textProperty().bindBidirectional(viewModel.noWrapFilesProperty());
+ public void initialize() {
+ this.viewModel = new FileTabViewModel(preferencesService.getFieldPreferences());
doNotResolveStrings.selectedProperty().bindBidirectional(viewModel.doNotResolveStringsProperty());
resolveStrings.selectedProperty().bindBidirectional(viewModel.resolveStringsProperty());
resolveStringsForFields.textProperty().bindBidirectional(viewModel.resolveStringsForFieldsProperty());
resolveStringsForFields.disableProperty().bind(doNotResolveStrings.selectedProperty());
-
- alwaysReformatBib.selectedProperty().bindBidirectional(viewModel.alwaysReformatBibProperty());
- autosaveLocalLibraries.selectedProperty().bindBidirectional(viewModel.autosaveLocalLibrariesProperty());
-
- ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs());
- actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AUTOSAVE, dialogService), autosaveLocalLibrariesHelp);
- }
-
- @Override
- public String getTabName() {
- return Localization.lang("File");
+ nonWrappableFields.textProperty().bindBidirectional(viewModel.nonWrappableFieldsProperty());
}
}
diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java b/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
index 2764c5f63f9..2b505d314c0 100644
--- a/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
@@ -8,49 +8,32 @@
import org.jabref.gui.preferences.PreferenceTabViewModel;
import org.jabref.logic.bibtex.FieldPreferences;
import org.jabref.model.entry.field.FieldFactory;
-import org.jabref.preferences.ExportPreferences;
public class FileTabViewModel implements PreferenceTabViewModel {
-
- private final StringProperty noWrapFilesProperty = new SimpleStringProperty("");
private final BooleanProperty doNotResolveStringsProperty = new SimpleBooleanProperty();
private final BooleanProperty resolveStringsProperty = new SimpleBooleanProperty();
private final StringProperty resolveStringsForFieldsProperty = new SimpleStringProperty("");
- private final BooleanProperty alwaysReformatBibProperty = new SimpleBooleanProperty();
- private final BooleanProperty autosaveLocalLibraries = new SimpleBooleanProperty();
+ private final StringProperty nonWrappableFieldsProperty = new SimpleStringProperty("");
- private final ExportPreferences exportPreferences;
private final FieldPreferences fieldPreferences;
- FileTabViewModel(ExportPreferences exportPreferences, FieldPreferences fieldPreferences) {
- this.exportPreferences = exportPreferences;
+ FileTabViewModel(FieldPreferences fieldPreferences) {
this.fieldPreferences = fieldPreferences;
}
@Override
public void setValues() {
- noWrapFilesProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getNonWrappableFields()));
-
doNotResolveStringsProperty.setValue(!fieldPreferences.shouldResolveStrings());
resolveStringsProperty.setValue(fieldPreferences.shouldResolveStrings());
resolveStringsForFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getResolvableFields()));
- alwaysReformatBibProperty.setValue(exportPreferences.shouldAlwaysReformatOnSave());
- autosaveLocalLibraries.setValue(exportPreferences.shouldAutoSave());
+ nonWrappableFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getNonWrappableFields()));
}
@Override
public void storeSettings() {
fieldPreferences.setResolveStrings(!doNotResolveStringsProperty.getValue());
- fieldPreferences.setNonWrappableFields(FieldFactory.parseFieldList(noWrapFilesProperty.getValue().trim()));
fieldPreferences.setResolvableFields(FieldFactory.parseFieldList(resolveStringsForFieldsProperty.getValue().trim()));
- exportPreferences.setAlwaysReformatOnSave(alwaysReformatBibProperty.getValue());
- exportPreferences.setAutoSave(autosaveLocalLibraries.getValue());
- }
-
- // ImportExport
-
- public StringProperty noWrapFilesProperty() {
- return noWrapFilesProperty;
+ fieldPreferences.setNonWrappableFields(FieldFactory.parseFieldList(nonWrappableFieldsProperty.getValue().trim()));
}
public BooleanProperty doNotResolveStringsProperty() {
@@ -65,12 +48,7 @@ public StringProperty resolveStringsForFieldsProperty() {
return resolveStringsForFieldsProperty;
}
- public BooleanProperty alwaysReformatBibProperty() {
- return alwaysReformatBibProperty;
- }
-
- // Autosave
- public BooleanProperty autosaveLocalLibrariesProperty() {
- return autosaveLocalLibraries;
+ public StringProperty nonWrappableFieldsProperty() {
+ return nonWrappableFieldsProperty;
}
}
diff --git a/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java b/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java
index f44cbd66f84..9a8aafacc38 100644
--- a/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java
+++ b/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java
@@ -227,7 +227,7 @@ void performBackup(Path backupPath) {
// code similar to org.jabref.gui.exporter.SaveDatabaseAction.saveDatabase
SaveConfiguration saveConfiguration = new SaveConfiguration()
.withMakeBackup(false)
- .withReformatOnSave(preferences.getImportExportPreferences().shouldAlwaysReformatOnSave());
+ .withReformatOnSave(preferences.getExportPreferences().shouldAlwaysReformatOnSave());
Charset encoding = bibDatabaseContext.getMetaData().getEncoding().orElse(StandardCharsets.UTF_8);
// We want to have successful backups only
diff --git a/src/main/java/org/jabref/logic/crawler/StudyRepository.java b/src/main/java/org/jabref/logic/crawler/StudyRepository.java
index 44d0412c98b..47c0045aec8 100644
--- a/src/main/java/org/jabref/logic/crawler/StudyRepository.java
+++ b/src/main/java/org/jabref/logic/crawler/StudyRepository.java
@@ -426,7 +426,7 @@ private void generateCiteKeys(BibDatabaseContext existingEntries, BibDatabase ta
private void writeResultToFile(Path pathToFile, BibDatabase entries) throws SaveException {
try (AtomicFileWriter fileWriter = new AtomicFileWriter(pathToFile, StandardCharsets.UTF_8)) {
SaveConfiguration saveConfiguration = new SaveConfiguration()
- .withReformatOnSave(preferencesService.getImportExportPreferences().shouldAlwaysReformatOnSave());
+ .withReformatOnSave(preferencesService.getExportPreferences().shouldAlwaysReformatOnSave());
BibWriter bibWriter = new BibWriter(fileWriter, OS.NEWLINE);
BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(
bibWriter,
diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java
index 6739763d255..7fbca883b00 100644
--- a/src/main/java/org/jabref/preferences/JabRefPreferences.java
+++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java
@@ -2177,7 +2177,7 @@ public AutoLinkPreferences getAutoLinkPreferences() {
//*************************************************************************************************************
@Override
- public ExportPreferences getImportExportPreferences() {
+ public ExportPreferences getExportPreferences() {
if (Objects.nonNull(exportPreferences)) {
return exportPreferences;
}
@@ -2251,7 +2251,7 @@ public SaveConfiguration getExportConfiguration() {
return new SaveConfiguration()
.withSaveOrder(saveOrder)
.withMetadataSaveOrder(false)
- .withReformatOnSave(getImportExportPreferences().shouldAlwaysReformatOnSave());
+ .withReformatOnSave(getExportPreferences().shouldAlwaysReformatOnSave());
}
@Override
diff --git a/src/main/java/org/jabref/preferences/PreferencesService.java b/src/main/java/org/jabref/preferences/PreferencesService.java
index 03d75614fbb..ac7b7f94312 100644
--- a/src/main/java/org/jabref/preferences/PreferencesService.java
+++ b/src/main/java/org/jabref/preferences/PreferencesService.java
@@ -171,7 +171,7 @@ public interface PreferencesService {
// Import/Export preferences
//*************************************************************************************************************
- ExportPreferences getImportExportPreferences();
+ ExportPreferences getExportPreferences();
List getCustomExportFormats(JournalAbbreviationRepository repository);
diff --git a/src/test/java/org/jabref/gui/exporter/ExportToClipboardActionTest.java b/src/test/java/org/jabref/gui/exporter/ExportToClipboardActionTest.java
index aeacfc8e219..0044eb7c877 100644
--- a/src/test/java/org/jabref/gui/exporter/ExportToClipboardActionTest.java
+++ b/src/test/java/org/jabref/gui/exporter/ExportToClipboardActionTest.java
@@ -92,7 +92,7 @@ public void export(BibDatabaseContext databaseContext, Path file, List
};
when(importExportPrefs.getLastExportExtension()).thenReturn("HTML");
- when(preferences.getImportExportPreferences()).thenReturn(importExportPrefs);
+ when(preferences.getExportPreferences()).thenReturn(importExportPrefs);
GeneralPreferences generalPreferences = mock(GeneralPreferences.class, Answers.RETURNS_DEEP_STUBS);
FilePreferences filePreferences = mock(FilePreferences.class, Answers.RETURNS_DEEP_STUBS);
when(preferences.getFilePreferences()).thenReturn(filePreferences);
diff --git a/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java b/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java
index 91035d7232e..ba398f743a8 100644
--- a/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java
+++ b/src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java
@@ -63,7 +63,7 @@ public void setUp() {
when(libraryTab.getBibDatabaseContext()).thenReturn(dbContext);
when(filePreferences.getWorkingDirectory()).thenReturn(Path.of(TEST_BIBTEX_LIBRARY_LOCATION));
when(preferences.getFilePreferences()).thenReturn(filePreferences);
- when(preferences.getImportExportPreferences()).thenReturn(mock(ExportPreferences.class));
+ when(preferences.getExportPreferences()).thenReturn(mock(ExportPreferences.class));
when(jabRefFrame.getDialogService()).thenReturn(dialogService);
saveDatabaseAction = spy(new SaveDatabaseAction(libraryTab, preferences, mock(BibEntryTypesManager.class)));
}
From f8f709927260f5797eb274924bb3bffbde04554b Mon Sep 17 00:00:00 2001
From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Date: Thu, 4 May 2023 17:53:32 +0200
Subject: [PATCH 05/11] Fixed antipattern, fixed radiobutton with checkbox
---
.../preferences/entryeditor/EntryEditorTab.fxml | 2 +-
.../org/jabref/gui/preferences/file/FileTab.fxml | 15 +++++----------
.../org/jabref/gui/preferences/file/FileTab.java | 7 ++-----
.../gui/preferences/file/FileTabViewModel.java | 8 +-------
.../org/jabref/preferences/JabRefPreferences.java | 2 +-
src/main/resources/l10n/JabRef_en.properties | 5 ++---
6 files changed, 12 insertions(+), 27 deletions(-)
diff --git a/src/main/java/org/jabref/gui/preferences/entryeditor/EntryEditorTab.fxml b/src/main/java/org/jabref/gui/preferences/entryeditor/EntryEditorTab.fxml
index 8d90f4b8c6d..e734b7cf2e8 100644
--- a/src/main/java/org/jabref/gui/preferences/entryeditor/EntryEditorTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/entryeditor/EntryEditorTab.fxml
@@ -34,7 +34,7 @@
-
+
diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml b/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml
index 98cb7e94aa4..77f3a5a001c 100644
--- a/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml
@@ -1,9 +1,8 @@
+
-
-
-
-
-
+
-
-
+
+
-
diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTab.java b/src/main/java/org/jabref/gui/preferences/file/FileTab.java
index b8542a9aedf..86cca4af0fe 100644
--- a/src/main/java/org/jabref/gui/preferences/file/FileTab.java
+++ b/src/main/java/org/jabref/gui/preferences/file/FileTab.java
@@ -1,7 +1,7 @@
package org.jabref.gui.preferences.file;
import javafx.fxml.FXML;
-import javafx.scene.control.RadioButton;
+import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
import org.jabref.gui.preferences.AbstractPreferenceTabView;
@@ -11,8 +11,7 @@
import com.airhacks.afterburner.views.ViewLoader;
public class FileTab extends AbstractPreferenceTabView implements PreferencesTab {
- @FXML private RadioButton doNotResolveStrings;
- @FXML private RadioButton resolveStrings;
+ @FXML private CheckBox resolveStrings;
@FXML private TextField resolveStringsForFields;
@FXML private TextField nonWrappableFields;
@@ -30,10 +29,8 @@ public String getTabName() {
public void initialize() {
this.viewModel = new FileTabViewModel(preferencesService.getFieldPreferences());
- doNotResolveStrings.selectedProperty().bindBidirectional(viewModel.doNotResolveStringsProperty());
resolveStrings.selectedProperty().bindBidirectional(viewModel.resolveStringsProperty());
resolveStringsForFields.textProperty().bindBidirectional(viewModel.resolveStringsForFieldsProperty());
- resolveStringsForFields.disableProperty().bind(doNotResolveStrings.selectedProperty());
nonWrappableFields.textProperty().bindBidirectional(viewModel.nonWrappableFieldsProperty());
}
}
diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java b/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
index 2b505d314c0..e784869f563 100644
--- a/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
@@ -10,7 +10,6 @@
import org.jabref.model.entry.field.FieldFactory;
public class FileTabViewModel implements PreferenceTabViewModel {
- private final BooleanProperty doNotResolveStringsProperty = new SimpleBooleanProperty();
private final BooleanProperty resolveStringsProperty = new SimpleBooleanProperty();
private final StringProperty resolveStringsForFieldsProperty = new SimpleStringProperty("");
private final StringProperty nonWrappableFieldsProperty = new SimpleStringProperty("");
@@ -23,7 +22,6 @@ public class FileTabViewModel implements PreferenceTabViewModel {
@Override
public void setValues() {
- doNotResolveStringsProperty.setValue(!fieldPreferences.shouldResolveStrings());
resolveStringsProperty.setValue(fieldPreferences.shouldResolveStrings());
resolveStringsForFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getResolvableFields()));
nonWrappableFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getNonWrappableFields()));
@@ -31,15 +29,11 @@ public void setValues() {
@Override
public void storeSettings() {
- fieldPreferences.setResolveStrings(!doNotResolveStringsProperty.getValue());
+ fieldPreferences.setResolveStrings(resolveStringsProperty.getValue());
fieldPreferences.setResolvableFields(FieldFactory.parseFieldList(resolveStringsForFieldsProperty.getValue().trim()));
fieldPreferences.setNonWrappableFields(FieldFactory.parseFieldList(nonWrappableFieldsProperty.getValue().trim()));
}
- public BooleanProperty doNotResolveStringsProperty() {
- return doNotResolveStringsProperty;
- }
-
public BooleanProperty resolveStringsProperty() {
return resolveStringsProperty;
}
diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java
index 7fbca883b00..e357aeb1ebd 100644
--- a/src/main/java/org/jabref/preferences/JabRefPreferences.java
+++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java
@@ -2081,7 +2081,7 @@ public FieldPreferences getFieldPreferences() {
}
fieldPreferences = new FieldPreferences(
- !getBoolean(DO_NOT_RESOLVE_STRINGS),
+ !getBoolean(DO_NOT_RESOLVE_STRINGS), // mind the !
getStringList(RESOLVE_STRINGS_FOR_FIELDS).stream()
.map(FieldFactory::parseField)
.collect(Collectors.toList()),
diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties
index 3deee196cdc..e1107d39815 100644
--- a/src/main/resources/l10n/JabRef_en.properties
+++ b/src/main/resources/l10n/JabRef_en.properties
@@ -742,8 +742,7 @@ Replaces\ Unicode\ ligatures\ with\ their\ expanded\ form=Replaces Unicode ligat
Required\ fields=Required fields
-Do\ not\ resolve\ BibTeX\ strings=Do not resolve BibTeX strings
-Resolve\ BibTeX\ strings\ for\ the\ following\ fields=Resolve BibTeX strings for the following fields
+Resolve\ BibTeX\ strings=Resolve BibTeX strings
resolved=resolved
@@ -2051,7 +2050,7 @@ Add\ formatter\ to\ list=Add formatter to list
Filter\ List=Filter List
Open\ files...=Open files...
-Affected\ fields\:=Affected fields:
+Affected\ fields=Affected fields
Show\ preview\ as\ a\ tab\ in\ entry\ editor=Show preview as a tab in entry editor
Font=Font
Visual\ theme=Visual theme
From cd6216881465033d479f53ceb5ad77f8c9b0c2a2 Mon Sep 17 00:00:00 2001
From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Date: Thu, 4 May 2023 18:18:11 +0200
Subject: [PATCH 06/11] Renamed CustomEditorFieldsTab to EntryEditorTabsTab
---
.../PreferencesDialogViewModel.java | 4 +-
.../gui/preferences/entry/EntryTab.fxml | 11 ++++++
.../gui/preferences/entry/EntryTab.java | 13 +++++--
.../preferences/entry/EntryTabViewModel.java | 39 ++++++++++++++++---
...FieldsTab.fxml => EntryEditorTabsTab.fxml} | 2 +-
...FieldsTab.java => EntryEditorTabsTab.java} | 6 +--
....java => EntryEditorTabsTabViewModel.java} | 4 +-
7 files changed, 62 insertions(+), 17 deletions(-)
rename src/main/java/org/jabref/gui/preferences/entryeditortabs/{CustomEditorFieldsTab.fxml => EntryEditorTabsTab.fxml} (97%)
rename src/main/java/org/jabref/gui/preferences/entryeditortabs/{CustomEditorFieldsTab.java => EntryEditorTabsTab.java} (83%)
rename src/main/java/org/jabref/gui/preferences/entryeditortabs/{CustomEditorFieldsTabViewModel.java => EntryEditorTabsTabViewModel.java} (94%)
diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
index 10a1b6fd007..713a80e13a1 100644
--- a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
@@ -19,7 +19,7 @@
import org.jabref.gui.preferences.customimporter.CustomImporterTab;
import org.jabref.gui.preferences.entry.EntryTab;
import org.jabref.gui.preferences.entryeditor.EntryEditorTab;
-import org.jabref.gui.preferences.entryeditortabs.CustomEditorFieldsTab;
+import org.jabref.gui.preferences.entryeditortabs.EntryEditorTabsTab;
import org.jabref.gui.preferences.export.ExportTab;
import org.jabref.gui.preferences.external.ExternalTab;
import org.jabref.gui.preferences.externalfiletypes.ExternalFileTypesTab;
@@ -75,7 +75,7 @@ public PreferencesDialogViewModel(DialogService dialogService, PreferencesServic
new EntryEditorTab(),
new WebSearchTab(),
new ExportTab(),
- new CustomEditorFieldsTab(),
+ new EntryEditorTabsTab(),
new CitationKeyPatternTab(),
new LinkedFilesTab(),
new NameFormatterTab(),
diff --git a/src/main/java/org/jabref/gui/preferences/entry/EntryTab.fxml b/src/main/java/org/jabref/gui/preferences/entry/EntryTab.fxml
index 81028a987d1..987053f6d34 100644
--- a/src/main/java/org/jabref/gui/preferences/entry/EntryTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/entry/EntryTab.fxml
@@ -12,10 +12,21 @@
fx:controller="org.jabref.gui.preferences.entry.EntryTab">
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/org/jabref/gui/preferences/entry/EntryTab.java b/src/main/java/org/jabref/gui/preferences/entry/EntryTab.java
index 31fc50f0521..57424ae3e34 100644
--- a/src/main/java/org/jabref/gui/preferences/entry/EntryTab.java
+++ b/src/main/java/org/jabref/gui/preferences/entry/EntryTab.java
@@ -21,6 +21,10 @@ public class EntryTab extends AbstractPreferenceTabView imple
@FXML private TextField keywordSeparator;
+ @FXML private CheckBox resolveStrings;
+ @FXML private TextField resolveStringsForFields;
+ @FXML private TextField nonWrappableFields;
+
@FXML private CheckBox markOwner;
@FXML private TextField markOwnerName;
@FXML private CheckBox markOwnerOverwrite;
@@ -38,13 +42,14 @@ public EntryTab() {
}
public void initialize() {
- this.viewModel = new EntryTabViewModel(
- preferencesService.getBibEntryPreferences(),
- preferencesService.getOwnerPreferences(),
- preferencesService.getTimestampPreferences());
+ this.viewModel = new EntryTabViewModel(preferencesService);
keywordSeparator.textProperty().bindBidirectional(viewModel.keywordSeparatorProperty());
+ resolveStrings.selectedProperty().bindBidirectional(viewModel.resolveStringsProperty());
+ resolveStringsForFields.textProperty().bindBidirectional(viewModel.resolveStringsForFieldsProperty());
+ nonWrappableFields.textProperty().bindBidirectional(viewModel.nonWrappableFieldsProperty());
+
markOwner.selectedProperty().bindBidirectional(viewModel.markOwnerProperty());
markOwnerName.textProperty().bindBidirectional(viewModel.markOwnerNameProperty());
markOwnerName.disableProperty().bind(markOwner.selectedProperty().not());
diff --git a/src/main/java/org/jabref/gui/preferences/entry/EntryTabViewModel.java b/src/main/java/org/jabref/gui/preferences/entry/EntryTabViewModel.java
index 2bf37676ac5..de204b52385 100644
--- a/src/main/java/org/jabref/gui/preferences/entry/EntryTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/entry/EntryTabViewModel.java
@@ -6,33 +6,46 @@
import javafx.beans.property.StringProperty;
import org.jabref.gui.preferences.PreferenceTabViewModel;
+import org.jabref.logic.bibtex.FieldPreferences;
import org.jabref.logic.preferences.OwnerPreferences;
import org.jabref.logic.preferences.TimestampPreferences;
+import org.jabref.model.entry.field.FieldFactory;
import org.jabref.preferences.BibEntryPreferences;
+import org.jabref.preferences.PreferencesService;
public class EntryTabViewModel implements PreferenceTabViewModel {
-
private final StringProperty keywordSeparatorProperty = new SimpleStringProperty("");
+
+ private final BooleanProperty resolveStringsProperty = new SimpleBooleanProperty();
+ private final StringProperty resolveStringsForFieldsProperty = new SimpleStringProperty("");
+ private final StringProperty nonWrappableFieldsProperty = new SimpleStringProperty("");
+
private final BooleanProperty markOwnerProperty = new SimpleBooleanProperty();
private final StringProperty markOwnerNameProperty = new SimpleStringProperty("");
private final BooleanProperty markOwnerOverwriteProperty = new SimpleBooleanProperty();
private final BooleanProperty addCreationDateProperty = new SimpleBooleanProperty();
private final BooleanProperty addModificationDateProperty = new SimpleBooleanProperty();
+ private final FieldPreferences fieldPreferences;
private final BibEntryPreferences bibEntryPreferences;
private final OwnerPreferences ownerPreferences;
private final TimestampPreferences timestampPreferences;
- public EntryTabViewModel(BibEntryPreferences bibEntryPreferences, OwnerPreferences ownerPreferences, TimestampPreferences timestampPreferences) {
- this.bibEntryPreferences = bibEntryPreferences;
- this.ownerPreferences = ownerPreferences;
- this.timestampPreferences = timestampPreferences;
+ public EntryTabViewModel(PreferencesService preferencesService) {
+ this.bibEntryPreferences = preferencesService.getBibEntryPreferences();
+ this.fieldPreferences = preferencesService.getFieldPreferences();
+ this.ownerPreferences = preferencesService.getOwnerPreferences();
+ this.timestampPreferences = preferencesService.getTimestampPreferences();
}
@Override
public void setValues() {
keywordSeparatorProperty.setValue(bibEntryPreferences.getKeywordSeparator().toString());
+ resolveStringsProperty.setValue(fieldPreferences.shouldResolveStrings());
+ resolveStringsForFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getResolvableFields()));
+ nonWrappableFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getNonWrappableFields()));
+
markOwnerProperty.setValue(ownerPreferences.isUseOwner());
markOwnerNameProperty.setValue(ownerPreferences.getDefaultOwner());
markOwnerOverwriteProperty.setValue(ownerPreferences.isOverwriteOwner());
@@ -45,6 +58,10 @@ public void setValues() {
public void storeSettings() {
bibEntryPreferences.keywordSeparatorProperty().setValue(keywordSeparatorProperty.getValue().charAt(0));
+ fieldPreferences.setResolveStrings(resolveStringsProperty.getValue());
+ fieldPreferences.setResolvableFields(FieldFactory.parseFieldList(resolveStringsForFieldsProperty.getValue().trim()));
+ fieldPreferences.setNonWrappableFields(FieldFactory.parseFieldList(nonWrappableFieldsProperty.getValue().trim()));
+
ownerPreferences.setUseOwner(markOwnerProperty.getValue());
ownerPreferences.setDefaultOwner(markOwnerNameProperty.getValue());
ownerPreferences.setOverwriteOwner(markOwnerOverwriteProperty.getValue());
@@ -57,6 +74,18 @@ public StringProperty keywordSeparatorProperty() {
return keywordSeparatorProperty;
}
+ public BooleanProperty resolveStringsProperty() {
+ return resolveStringsProperty;
+ }
+
+ public StringProperty resolveStringsForFieldsProperty() {
+ return resolveStringsForFieldsProperty;
+ }
+
+ public StringProperty nonWrappableFieldsProperty() {
+ return nonWrappableFieldsProperty;
+ }
+
// Entry owner
public BooleanProperty markOwnerProperty() {
diff --git a/src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTab.fxml b/src/main/java/org/jabref/gui/preferences/entryeditortabs/EntryEditorTabsTab.fxml
similarity index 97%
rename from src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTab.fxml
rename to src/main/java/org/jabref/gui/preferences/entryeditortabs/EntryEditorTabsTab.fxml
index ffbec77e841..e8715921876 100644
--- a/src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/entryeditortabs/EntryEditorTabsTab.fxml
@@ -9,7 +9,7 @@
+ fx:controller="org.jabref.gui.preferences.entryeditortabs.EntryEditorTabsTab">
diff --git a/src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTab.java b/src/main/java/org/jabref/gui/preferences/entryeditortabs/EntryEditorTabsTab.java
similarity index 83%
rename from src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTab.java
rename to src/main/java/org/jabref/gui/preferences/entryeditortabs/EntryEditorTabsTab.java
index 319f4e83f02..cb5c90ae880 100644
--- a/src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTab.java
+++ b/src/main/java/org/jabref/gui/preferences/entryeditortabs/EntryEditorTabsTab.java
@@ -15,12 +15,12 @@
import com.airhacks.afterburner.views.ViewLoader;
-public class CustomEditorFieldsTab extends AbstractPreferenceTabView implements PreferencesTab {
+public class EntryEditorTabsTab extends AbstractPreferenceTabView implements PreferencesTab {
@FXML private Button generalFieldsHelp;
@FXML private TextArea fieldsTextArea;
- public CustomEditorFieldsTab() {
+ public EntryEditorTabsTab() {
ViewLoader.view(this)
.root(this)
.load();
@@ -32,7 +32,7 @@ public String getTabName() {
}
public void initialize() {
- viewModel = new CustomEditorFieldsTabViewModel(dialogService, preferencesService);
+ viewModel = new EntryEditorTabsTabViewModel(dialogService, preferencesService);
fieldsTextArea.textProperty().bindBidirectional(viewModel.fieldsProperty());
diff --git a/src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTabViewModel.java b/src/main/java/org/jabref/gui/preferences/entryeditortabs/EntryEditorTabsTabViewModel.java
similarity index 94%
rename from src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTabViewModel.java
rename to src/main/java/org/jabref/gui/preferences/entryeditortabs/EntryEditorTabsTabViewModel.java
index ef51d2486e5..8fc6d90f526 100644
--- a/src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/entryeditortabs/EntryEditorTabsTabViewModel.java
@@ -16,7 +16,7 @@
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.preferences.PreferencesService;
-public class CustomEditorFieldsTabViewModel implements PreferenceTabViewModel {
+public class EntryEditorTabsTabViewModel implements PreferenceTabViewModel {
private final StringProperty fieldsProperty = new SimpleStringProperty();
@@ -24,7 +24,7 @@ public class CustomEditorFieldsTabViewModel implements PreferenceTabViewModel {
private final PreferencesService preferences;
private final EntryEditorPreferences entryEditorPreferences;
- public CustomEditorFieldsTabViewModel(DialogService dialogService, PreferencesService preferences) {
+ public EntryEditorTabsTabViewModel(DialogService dialogService, PreferencesService preferences) {
this.dialogService = dialogService;
this.preferences = preferences;
this.entryEditorPreferences = preferences.getEntryEditorPreferences();
From 44d9ec5dcbbcc9ae570c0deb4a2b415e4af40d40 Mon Sep 17 00:00:00 2001
From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Date: Thu, 4 May 2023 18:19:10 +0200
Subject: [PATCH 07/11] Dissolved FileTab and moved contents to EntryTab
---
.../PreferencesDialogViewModel.java | 2 -
.../jabref/gui/preferences/file/FileTab.fxml | 24 ----------
.../jabref/gui/preferences/file/FileTab.java | 36 --------------
.../preferences/file/FileTabViewModel.java | 48 -------------------
src/main/resources/l10n/JabRef_en.properties | 3 +-
5 files changed, 2 insertions(+), 111 deletions(-)
delete mode 100644 src/main/java/org/jabref/gui/preferences/file/FileTab.fxml
delete mode 100644 src/main/java/org/jabref/gui/preferences/file/FileTab.java
delete mode 100644 src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
index 713a80e13a1..0515e37561e 100644
--- a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
@@ -23,7 +23,6 @@
import org.jabref.gui.preferences.export.ExportTab;
import org.jabref.gui.preferences.external.ExternalTab;
import org.jabref.gui.preferences.externalfiletypes.ExternalFileTypesTab;
-import org.jabref.gui.preferences.file.FileTab;
import org.jabref.gui.preferences.general.GeneralTab;
import org.jabref.gui.preferences.groups.GroupsTab;
import org.jabref.gui.preferences.journals.JournalAbbreviationsTab;
@@ -63,7 +62,6 @@ public PreferencesDialogViewModel(DialogService dialogService, PreferencesServic
preferenceTabs = FXCollections.observableArrayList(
new GeneralTab(),
new KeyBindingsTab(),
- new FileTab(),
new EntryTab(),
new TableTab(),
new PreviewTab(),
diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml b/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml
deleted file mode 100644
index 77f3a5a001c..00000000000
--- a/src/main/java/org/jabref/gui/preferences/file/FileTab.fxml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTab.java b/src/main/java/org/jabref/gui/preferences/file/FileTab.java
deleted file mode 100644
index 86cca4af0fe..00000000000
--- a/src/main/java/org/jabref/gui/preferences/file/FileTab.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.jabref.gui.preferences.file;
-
-import javafx.fxml.FXML;
-import javafx.scene.control.CheckBox;
-import javafx.scene.control.TextField;
-
-import org.jabref.gui.preferences.AbstractPreferenceTabView;
-import org.jabref.gui.preferences.PreferencesTab;
-import org.jabref.logic.l10n.Localization;
-
-import com.airhacks.afterburner.views.ViewLoader;
-
-public class FileTab extends AbstractPreferenceTabView implements PreferencesTab {
- @FXML private CheckBox resolveStrings;
- @FXML private TextField resolveStringsForFields;
- @FXML private TextField nonWrappableFields;
-
- public FileTab() {
- ViewLoader.view(this)
- .root(this)
- .load();
- }
-
- @Override
- public String getTabName() {
- return Localization.lang("File");
- }
-
- public void initialize() {
- this.viewModel = new FileTabViewModel(preferencesService.getFieldPreferences());
-
- resolveStrings.selectedProperty().bindBidirectional(viewModel.resolveStringsProperty());
- resolveStringsForFields.textProperty().bindBidirectional(viewModel.resolveStringsForFieldsProperty());
- nonWrappableFields.textProperty().bindBidirectional(viewModel.nonWrappableFieldsProperty());
- }
-}
diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java b/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
deleted file mode 100644
index e784869f563..00000000000
--- a/src/main/java/org/jabref/gui/preferences/file/FileTabViewModel.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.jabref.gui.preferences.file;
-
-import javafx.beans.property.BooleanProperty;
-import javafx.beans.property.SimpleBooleanProperty;
-import javafx.beans.property.SimpleStringProperty;
-import javafx.beans.property.StringProperty;
-
-import org.jabref.gui.preferences.PreferenceTabViewModel;
-import org.jabref.logic.bibtex.FieldPreferences;
-import org.jabref.model.entry.field.FieldFactory;
-
-public class FileTabViewModel implements PreferenceTabViewModel {
- private final BooleanProperty resolveStringsProperty = new SimpleBooleanProperty();
- private final StringProperty resolveStringsForFieldsProperty = new SimpleStringProperty("");
- private final StringProperty nonWrappableFieldsProperty = new SimpleStringProperty("");
-
- private final FieldPreferences fieldPreferences;
-
- FileTabViewModel(FieldPreferences fieldPreferences) {
- this.fieldPreferences = fieldPreferences;
- }
-
- @Override
- public void setValues() {
- resolveStringsProperty.setValue(fieldPreferences.shouldResolveStrings());
- resolveStringsForFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getResolvableFields()));
- nonWrappableFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getNonWrappableFields()));
- }
-
- @Override
- public void storeSettings() {
- fieldPreferences.setResolveStrings(resolveStringsProperty.getValue());
- fieldPreferences.setResolvableFields(FieldFactory.parseFieldList(resolveStringsForFieldsProperty.getValue().trim()));
- fieldPreferences.setNonWrappableFields(FieldFactory.parseFieldList(nonWrappableFieldsProperty.getValue().trim()));
- }
-
- public BooleanProperty resolveStringsProperty() {
- return resolveStringsProperty;
- }
-
- public StringProperty resolveStringsForFieldsProperty() {
- return resolveStringsForFieldsProperty;
- }
-
- public StringProperty nonWrappableFieldsProperty() {
- return nonWrappableFieldsProperty;
- }
-}
diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties
index e1107d39815..8dfd61ac061 100644
--- a/src/main/resources/l10n/JabRef_en.properties
+++ b/src/main/resources/l10n/JabRef_en.properties
@@ -271,7 +271,8 @@ Do\ not\ abbreviate\ names=Do not abbreviate names
Do\ not\ open\ any\ files\ at\ startup=Do not open any files at startup
-Do\ not\ wrap\ the\ following\ fields\ when\ saving=Do not wrap the following fields when saving
+Do\ not\ wrap\ when\ saving=Do not wrap when saving
+
Do\ not\ write\ the\ following\ fields\ to\ XMP\ Metadata=Do not write the following fields to XMP Metadata
Donate\ to\ JabRef=Donate to JabRef
From d2239b8f9c4b6c057342d4d85f053027315462b4 Mon Sep 17 00:00:00 2001
From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Date: Thu, 4 May 2023 18:53:42 +0200
Subject: [PATCH 08/11] Refined ui
---
.../gui/preferences/entry/EntryTab.fxml | 24 +++++++++++++------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/jabref/gui/preferences/entry/EntryTab.fxml b/src/main/java/org/jabref/gui/preferences/entry/EntryTab.fxml
index 987053f6d34..2bece2af293 100644
--- a/src/main/java/org/jabref/gui/preferences/entry/EntryTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/entry/EntryTab.fxml
@@ -1,5 +1,6 @@
+
@@ -15,17 +16,26 @@
-
-
-
-
-
+
+
-
+
+ disable="${!resolveStrings.selected}">
+
+
+
+
+
+
+
+
+
+
+
+
From d4938c0c6fa5545ee02830d1071ecc72f5b39b18 Mon Sep 17 00:00:00 2001
From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Date: Thu, 4 May 2023 19:00:00 +0200
Subject: [PATCH 09/11] Removed unused code
---
.../component/DiffHighlightingTextPane.java | 24 ----
.../org/jabref/gui/util/component/Tag.fxml | 26 ----
.../org/jabref/gui/util/component/Tag.java | 64 ----------
.../org/jabref/gui/util/component/TagBar.css | 14 ---
.../org/jabref/gui/util/component/TagBar.fxml | 9 --
.../org/jabref/gui/util/component/TagBar.java | 112 ------------------
6 files changed, 249 deletions(-)
delete mode 100644 src/main/java/org/jabref/gui/util/component/DiffHighlightingTextPane.java
delete mode 100644 src/main/java/org/jabref/gui/util/component/Tag.fxml
delete mode 100644 src/main/java/org/jabref/gui/util/component/Tag.java
delete mode 100644 src/main/java/org/jabref/gui/util/component/TagBar.css
delete mode 100644 src/main/java/org/jabref/gui/util/component/TagBar.fxml
delete mode 100644 src/main/java/org/jabref/gui/util/component/TagBar.java
diff --git a/src/main/java/org/jabref/gui/util/component/DiffHighlightingTextPane.java b/src/main/java/org/jabref/gui/util/component/DiffHighlightingTextPane.java
deleted file mode 100644
index f055d0eff75..00000000000
--- a/src/main/java/org/jabref/gui/util/component/DiffHighlightingTextPane.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.jabref.gui.util.component;
-
-import javafx.scene.text.TextFlow;
-
-public class DiffHighlightingTextPane extends TextFlow {
-
- private static final String BODY_STYLE = "body{font:sans-serif}";
- private static final String ADDITION_STYLE = ".add{color:blue;text-decoration:underline}";
- private static final String REMOVAL_STYLE = ".del{color:red;text-decoration:line-through;}";
- private static final String CHANGE_STYLE = ".change{color:#006400;text-decoration:underline}";
-
- private static final String CONTENT_TYPE = "text/html";
-
- public DiffHighlightingTextPane() {
- super();
-// setContentType(CONTENT_TYPE);
-// StyleSheet sheet = ((HTMLEditorKit) getEditorKit()).getStyleSheet();
-// sheet.addRule(BODY_STYLE);
-// sheet.addRule(ADDITION_STYLE);
-// sheet.addRule(REMOVAL_STYLE);
-// sheet.addRule(CHANGE_STYLE);
-// setEditable(false);
- }
-}
diff --git a/src/main/java/org/jabref/gui/util/component/Tag.fxml b/src/main/java/org/jabref/gui/util/component/Tag.fxml
deleted file mode 100644
index 847c44e4060..00000000000
--- a/src/main/java/org/jabref/gui/util/component/Tag.fxml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main/java/org/jabref/gui/util/component/Tag.java b/src/main/java/org/jabref/gui/util/component/Tag.java
deleted file mode 100644
index 998f044eac5..00000000000
--- a/src/main/java/org/jabref/gui/util/component/Tag.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.jabref.gui.util.component;
-
-import java.util.Objects;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-import javafx.beans.property.ObjectProperty;
-import javafx.beans.property.SimpleObjectProperty;
-import javafx.event.ActionEvent;
-import javafx.fxml.FXML;
-import javafx.scene.control.Label;
-import javafx.scene.layout.HBox;
-
-import com.airhacks.afterburner.views.ViewLoader;
-import com.tobiasdiez.easybind.EasyBind;
-
-/**
- * A tag item in a {@link TagBar}.
- */
-public class Tag extends HBox {
-
- private final ObjectProperty value;
- private Consumer tagRemovedConsumer;
- @FXML private Label text;
-
- public Tag(Function toString) {
- Objects.requireNonNull(toString);
-
- ViewLoader.view(this)
- .root(this)
- .load();
-
- value = new SimpleObjectProperty<>();
- text.textProperty().bind(EasyBind.map(value, toString));
- }
-
- public Tag(Function toString, T value) {
- this(toString);
- setValue(value);
- }
-
- public T getValue() {
- return value.get();
- }
-
- public void setValue(T value) {
- this.value.set(value);
- }
-
- public ObjectProperty valueProperty() {
- return value;
- }
-
- @FXML
- private void removeButtonClicked(ActionEvent event) {
- if (tagRemovedConsumer != null) {
- tagRemovedConsumer.accept(value.get());
- }
- }
-
- public final void setOnTagRemoved(Consumer tagRemovedConsumer) {
- this.tagRemovedConsumer = tagRemovedConsumer;
- }
-}
diff --git a/src/main/java/org/jabref/gui/util/component/TagBar.css b/src/main/java/org/jabref/gui/util/component/TagBar.css
deleted file mode 100644
index d940858d283..00000000000
--- a/src/main/java/org/jabref/gui/util/component/TagBar.css
+++ /dev/null
@@ -1,14 +0,0 @@
-.tagBar > HBox {
- -fx-spacing: 3;
-}
-
-.tagBar .tag {
- -fx-background-color: transparent;
- -fx-alignment: center;
- -fx-border-width: 1;
- -fx-border-color: darkgrey;
-}
-
-.tagBar .tag .button {
- -fx-background-color: transparent;
-}
diff --git a/src/main/java/org/jabref/gui/util/component/TagBar.fxml b/src/main/java/org/jabref/gui/util/component/TagBar.fxml
deleted file mode 100644
index 12af8b3b8d9..00000000000
--- a/src/main/java/org/jabref/gui/util/component/TagBar.fxml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/src/main/java/org/jabref/gui/util/component/TagBar.java b/src/main/java/org/jabref/gui/util/component/TagBar.java
deleted file mode 100644
index da63e602893..00000000000
--- a/src/main/java/org/jabref/gui/util/component/TagBar.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.jabref.gui.util.component;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.function.BiConsumer;
-import java.util.stream.Collectors;
-
-import javafx.beans.property.ListProperty;
-import javafx.beans.property.SimpleListProperty;
-import javafx.collections.FXCollections;
-import javafx.collections.ListChangeListener;
-import javafx.collections.ObservableList;
-import javafx.event.ActionEvent;
-import javafx.fxml.FXML;
-import javafx.scene.control.TextField;
-import javafx.scene.input.MouseEvent;
-import javafx.scene.layout.HBox;
-import javafx.util.StringConverter;
-
-import org.jabref.model.entry.field.FieldProperty;
-import org.jabref.model.strings.StringUtil;
-
-import com.airhacks.afterburner.views.ViewLoader;
-
-/**
- * Field editor that provides various pre-defined options as a drop-down combobox.
- */
-public class TagBar extends HBox {
-
- private final ListProperty tags;
- private StringConverter stringConverter;
- @FXML
- private TextField inputTextField;
- @FXML
- private HBox tagList;
- private BiConsumer onTagClicked;
- private java.util.Set properties;
-
- public TagBar() {
- tags = new SimpleListProperty<>(FXCollections.observableArrayList());
- tags.addListener(this::onTagsChanged);
-
- // Load FXML
- ViewLoader.view(this)
- .root(this)
- .load();
- getStylesheets().add(0, TagBar.class.getResource("TagBar.css").toExternalForm());
- }
-
- public TextField getInputTextField() {
- return inputTextField;
- }
-
- public ObservableList getTags() {
- return tags.get();
- }
-
- public void setTags(Collection newTags) {
- this.tags.setAll(newTags);
- }
-
- public ListProperty tagsProperty() {
- return tags;
- }
-
- private void onTagsChanged(ListChangeListener.Change extends T> change) {
- while (change.next()) {
- if (change.wasRemoved()) {
- tagList.getChildren().subList(change.getFrom(), change.getFrom() + change.getRemovedSize()).clear();
- } else if (change.wasAdded()) {
- tagList.getChildren().addAll(change.getFrom(), change.getAddedSubList().stream().map(this::createTag).collect(Collectors.toList()));
- }
- }
- if (this.properties.contains(FieldProperty.SINGLE_ENTRY_LINK)) {
- inputTextField.setDisable(!tags.isEmpty());
- }
- }
-
- private Tag createTag(T item) {
- Tag tag = new Tag<>(stringConverter::toString);
- tag.setOnTagRemoved(tags::remove);
- tag.setValue(item);
- if (onTagClicked != null) {
- tag.setOnMouseClicked(event -> onTagClicked.accept(item, event));
- }
- return tag;
- }
-
- @FXML
- private void addTextAsNewTag(ActionEvent event) {
- String inputText = inputTextField.getText();
- if (StringUtil.isNotBlank(inputText)) {
- T newTag = stringConverter.fromString(inputText);
- if ((newTag != null) && !tags.contains(newTag) && (tags.isEmpty() || this.properties.contains(FieldProperty.MULTIPLE_ENTRY_LINK))) {
- tags.add(newTag);
- inputTextField.clear();
- }
- }
- }
-
- public void setStringConverter(StringConverter stringConverter) {
- this.stringConverter = stringConverter;
- }
-
- public void setOnTagClicked(BiConsumer onTagClicked) {
- this.onTagClicked = onTagClicked;
- }
-
- public void setFieldProperties(Set properties) {
- this.properties = properties;
- }
-}
From e586befd7049344b9e46a96051550d2d1239efb9 Mon Sep 17 00:00:00 2001
From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Date: Thu, 4 May 2023 19:16:27 +0200
Subject: [PATCH 10/11] CHANGELOG.md
---
CHANGELOG.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c3b69897e74..5b8e2a93056 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,7 +44,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We moved the preferences menu command from the options menu to the file menu. [#9768](https://github.com/JabRef/jabref/pull/9768)
- We changed the handling of an "overflow" of authors at `[authIniN]`: JabRef uses `+` to indicate an overflow. Example: `[authIni2]` produces `A+` (instead of `AB`) for `Aachen and Berlin and Chemnitz`. [#9703](https://github.com/JabRef/jabref/pull/9703)
- We moved the preferences option to open the last edited files on startup to the 'General' tab. [#9808](https://github.com/JabRef/jabref/pull/9808)
-
+- We split the 'Import and Export' tab into 'Web Search' and 'Export'. [9839](https://github.com/JabRef/jabref/pull/9839)
### Fixed
@@ -74,7 +74,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We removed the support of BibTeXML. [#9540](https://github.com/JabRef/jabref/issues/9540)
- We removed support for Markdown syntax for strikethrough and task lists in comment fields. [#9726](https://github.com/JabRef/jabref/pull/9726)
- We removed the options menu, because the two contents were moved to the File menu or the properties of the library. [#9768](https://github.com/JabRef/jabref/pull/9768)
-
+- We removed the 'File' tab in the preferences and moved its contents to the 'Export' tab. [9839](https://github.com/JabRef/jabref/pull/9839)
From 5a16fe45afd8ecb8fc8582278d57d9bd7da3ee34 Mon Sep 17 00:00:00 2001
From: Oliver Kopp
Date: Fri, 5 May 2023 09:26:04 +0200
Subject: [PATCH 11/11] Fix missing #
---
CHANGELOG.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 666e7a1f7a5..b021da6d6f1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,7 +44,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We moved the preferences menu command from the options menu to the file menu. [#9768](https://github.com/JabRef/jabref/pull/9768)
- We changed the handling of an "overflow" of authors at `[authIniN]`: JabRef uses `+` to indicate an overflow. Example: `[authIni2]` produces `A+` (instead of `AB`) for `Aachen and Berlin and Chemnitz`. [#9703](https://github.com/JabRef/jabref/pull/9703)
- We moved the preferences option to open the last edited files on startup to the 'General' tab. [#9808](https://github.com/JabRef/jabref/pull/9808)
-- We split the 'Import and Export' tab into 'Web Search' and 'Export'. [9839](https://github.com/JabRef/jabref/pull/9839)
+- We split the 'Import and Export' tab into 'Web Search' and 'Export'. [#9839](https://github.com/JabRef/jabref/pull/9839)
### Fixed
@@ -75,7 +75,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We removed the support of BibTeXML. [#9540](https://github.com/JabRef/jabref/issues/9540)
- We removed support for Markdown syntax for strikethrough and task lists in comment fields. [#9726](https://github.com/JabRef/jabref/pull/9726)
- We removed the options menu, because the two contents were moved to the File menu or the properties of the library. [#9768](https://github.com/JabRef/jabref/pull/9768)
-- We removed the 'File' tab in the preferences and moved its contents to the 'Export' tab. [9839](https://github.com/JabRef/jabref/pull/9839)
+- We removed the 'File' tab in the preferences and moved its contents to the 'Export' tab. [#9839](https://github.com/JabRef/jabref/pull/9839)