diff --git a/src/main/java/org/jabref/gui/Base.css b/src/main/java/org/jabref/gui/Base.css
index 8c6b1dbe2d8..8b2cd80f7b1 100644
--- a/src/main/java/org/jabref/gui/Base.css
+++ b/src/main/java/org/jabref/gui/Base.css
@@ -1027,3 +1027,8 @@ We want to have a look that matches our icons in the tool-bar */
.tooltip-error {
-fx-background-color: -jr-error;
}
+
+.sectionHeader {
+ -fx-font-size: 1.5em;
+ -fx-padding: 1em 0em 1em 0em;
+}
diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java
index 74144a9ab42..ffdeb573738 100644
--- a/src/main/java/org/jabref/gui/JabRefFrame.java
+++ b/src/main/java/org/jabref/gui/JabRefFrame.java
@@ -61,9 +61,9 @@
import org.jabref.gui.actions.ConnectToSharedDatabaseCommand;
import org.jabref.gui.actions.CopyFilesAction;
import org.jabref.gui.actions.CustomizeKeyBindingAction;
-import org.jabref.gui.actions.DatabasePropertiesAction;
import org.jabref.gui.actions.EditExternalFileTypesAction;
import org.jabref.gui.actions.ErrorConsoleAction;
+import org.jabref.gui.actions.LibraryPropertiesAction;
import org.jabref.gui.actions.LookupIdentifierAction;
import org.jabref.gui.actions.ManageContentSelectorAction;
import org.jabref.gui.actions.ManageCustomExportsAction;
@@ -818,7 +818,7 @@ private MenuBar createMenu() {
edit.getItems().add(new SeparatorMenuItem());
}
}
-
+ //@formatter:off
library.getItems().addAll(
factory.createMenuItem(StandardActions.NEW_ENTRY, new NewEntryAction(this, dialogService, Globals.prefs)),
factory.createMenuItem(StandardActions.NEW_ENTRY_FROM_PLAINTEX, new NewEntryFromPlainTextAction(this, Globals.prefs.getUpdateFieldPreferences(), dialogService, Globals.prefs)),
@@ -826,7 +826,7 @@ private MenuBar createMenu() {
new SeparatorMenuItem(),
- factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new DatabasePropertiesAction(this)),
+ factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(this, dialogService)),
factory.createMenuItem(StandardActions.EDIT_PREAMBLE, new PreambleEditor(this)),
factory.createMenuItem(StandardActions.EDIT_STRINGS, new BibtexStringEditorAction(this)),
factory.createMenuItem(StandardActions.MASS_SET_FIELDS, new MassSetFieldsAction(this))
@@ -838,7 +838,6 @@ private MenuBar createMenu() {
lookupIdentifiers.getItems().add(factory.createMenuItem(identifierAction.getAction(), identifierAction));
}
- //@formatter:off
quality.getItems().addAll(
factory.createMenuItem(StandardActions.FIND_DUPLICATES, new DuplicateSearch(this, dialogService)),
factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(this)),
diff --git a/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.fxml b/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.fxml
new file mode 100644
index 00000000000..4bee6851ab0
--- /dev/null
+++ b/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.fxml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.java b/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.java
deleted file mode 100644
index 5103fba8d29..00000000000
--- a/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.jabref.gui;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.Objects;
-
-import javafx.collections.FXCollections;
-import javafx.scene.Node;
-import javafx.scene.control.CheckBox;
-import javafx.scene.control.ComboBox;
-import javafx.scene.control.Label;
-import javafx.scene.layout.GridPane;
-import javafx.scene.text.Font;
-
-import org.jabref.logic.l10n.Localization;
-import org.jabref.model.entry.BibEntry;
-import org.jabref.model.entry.InternalBibtexFields;
-import org.jabref.model.metadata.SaveOrderConfig;
-import org.jabref.model.metadata.SaveOrderConfig.SortCriterion;
-
-public class SaveOrderConfigDisplay {
-
- private GridPane panel;
- private ComboBox savePriSort;
- private ComboBox saveSecSort;
- private ComboBox saveTerSort;
- private CheckBox savePriDesc;
- private CheckBox saveSecDesc;
- private CheckBox saveTerDesc;
-
-
- public SaveOrderConfigDisplay() {
- init();
- }
-
- private void init() {
- List fieldNames = InternalBibtexFields.getAllPublicFieldNames();
- fieldNames.add(BibEntry.KEY_FIELD);
- Collections.sort(fieldNames);
- savePriSort = new ComboBox<>(FXCollections.observableArrayList(fieldNames));
- savePriSort.setEditable(true);
- saveSecSort = new ComboBox<>(FXCollections.observableArrayList(fieldNames));
- saveSecSort.setEditable(true);
- saveTerSort = new ComboBox<>(FXCollections.observableArrayList(fieldNames));
- saveTerSort.setEditable(true);
-
- savePriDesc = new CheckBox(Localization.lang("Descending"));
- saveSecDesc = new CheckBox(Localization.lang("Descending"));
- saveTerDesc = new CheckBox(Localization.lang("Descending"));
-
- Font font = new Font(10);
- GridPane builder = new GridPane();
- Label primarySortCriterion = new Label(Localization.lang("Primary sort criterion"));
- primarySortCriterion.setFont(font);
- builder.add(primarySortCriterion, 1, 1);
- builder.add(savePriSort, 2, 1);
- builder.add(savePriDesc, 3, 1);
-
- Label secondarySortCriterion = new Label(Localization.lang("Secondary sort criterion"));
- secondarySortCriterion.setFont(font);
- builder.add(secondarySortCriterion, 1, 2);
- builder.add(saveSecSort, 2, 2);
- builder.add(saveSecDesc, 3, 2);
-
- Label tertiarySortCriterion = new Label(Localization.lang("Tertiary sort criterion"));
- tertiarySortCriterion.setFont(font);
- builder.add(tertiarySortCriterion, 1, 3);
- builder.add(saveTerSort, 2, 3);
- builder.add(saveTerDesc, 3, 3);
- panel = builder;
- }
-
- public Node getJFXPanel() {
- return panel;
- }
-
- public void setEnabled(boolean enabled) {
- savePriSort.setDisable(!enabled);
- savePriDesc.setDisable(!enabled);
- saveSecSort.setDisable(!enabled);
- saveSecDesc.setDisable(!enabled);
- saveTerSort.setDisable(!enabled);
- saveTerDesc.setDisable(!enabled);
- }
-
- public SaveOrderConfig getSaveOrderConfig() {
- SaveOrderConfig saveOrderConfig = new SaveOrderConfig();
- SortCriterion primary = new SortCriterion(getSelectedItemAsLowerCaseTrim(savePriSort), savePriDesc.isSelected());
- saveOrderConfig.getSortCriteria().add(primary);
- SortCriterion secondary = new SortCriterion(getSelectedItemAsLowerCaseTrim(saveSecSort), saveSecDesc.isSelected());
- saveOrderConfig.getSortCriteria().add(secondary);
- SortCriterion tertiary = new SortCriterion(getSelectedItemAsLowerCaseTrim(saveTerSort), saveTerDesc.isSelected());
- saveOrderConfig.getSortCriteria().add(tertiary);
-
- return saveOrderConfig;
- }
-
- public void setSaveOrderConfig(SaveOrderConfig saveOrderConfig) {
- Objects.requireNonNull(saveOrderConfig);
-
- savePriSort.setValue(saveOrderConfig.getSortCriteria().get(0).field);
- savePriDesc.setSelected(saveOrderConfig.getSortCriteria().get(0).descending);
- saveSecSort.setValue(saveOrderConfig.getSortCriteria().get(1).field);
- saveSecDesc.setSelected(saveOrderConfig.getSortCriteria().get(1).descending);
- saveTerSort.setValue(saveOrderConfig.getSortCriteria().get(2).field);
- saveTerDesc.setSelected(saveOrderConfig.getSortCriteria().get(2).descending);
- }
-
- private String getSelectedItemAsLowerCaseTrim(ComboBox sortBox) {
- return sortBox.getValue().toLowerCase(Locale.ROOT).trim();
- }
-}
diff --git a/src/main/java/org/jabref/gui/SaveOrderConfigDisplayView.java b/src/main/java/org/jabref/gui/SaveOrderConfigDisplayView.java
new file mode 100644
index 00000000000..aeca6f4ddad
--- /dev/null
+++ b/src/main/java/org/jabref/gui/SaveOrderConfigDisplayView.java
@@ -0,0 +1,81 @@
+package org.jabref.gui;
+
+import javax.inject.Inject;
+
+import javafx.fxml.FXML;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.RadioButton;
+import javafx.scene.control.ToggleGroup;
+import javafx.scene.layout.GridPane;
+
+import org.jabref.logic.l10n.Localization;
+import org.jabref.model.metadata.SaveOrderConfig;
+import org.jabref.preferences.PreferencesService;
+
+import com.airhacks.afterburner.views.ViewLoader;
+
+public class SaveOrderConfigDisplayView extends GridPane {
+
+ private final SaveOrderConfig config;
+
+ @FXML private ToggleGroup saveOrderToggleGroup;
+ @FXML private ComboBox savePriSort;
+ @FXML private ComboBox saveSecSort;
+ @FXML private ComboBox saveTerSort;
+ @FXML private RadioButton exportInSpecifiedOrder;
+ @FXML private RadioButton exportInTableOrder;
+ @FXML private RadioButton exportInOriginalOrder;
+ @FXML private CheckBox savePriDesc;
+ @FXML private CheckBox saveSecDesc;
+ @FXML private CheckBox saveTerDesc;
+ @Inject private PreferencesService preferencesService;
+
+ private SaveOrderConfigDisplayViewModel viewModel;
+
+ public SaveOrderConfigDisplayView(SaveOrderConfig config) {
+ this.config = config;
+
+ ViewLoader.view(this)
+ .root(this)
+ .load();
+ }
+
+ @FXML
+ private void initialize() {
+
+ viewModel = new SaveOrderConfigDisplayViewModel(config, preferencesService);
+
+ exportInSpecifiedOrder.selectedProperty().bindBidirectional(viewModel.saveInSpecifiedOrderProperty());
+ exportInTableOrder.selectedProperty().bindBidirectional(viewModel.saveInTableOrderProperty());
+ exportInOriginalOrder.selectedProperty().bindBidirectional(viewModel.saveInOriginalProperty());
+
+ savePriSort.itemsProperty().bindBidirectional(viewModel.priSortFieldsProperty());
+ saveSecSort.itemsProperty().bindBidirectional(viewModel.secSortFieldsProperty());
+ saveTerSort.itemsProperty().bindBidirectional(viewModel.terSortFieldsProperty());
+
+ savePriSort.valueProperty().bindBidirectional(viewModel.savePriSortSelectedValueProperty());
+ saveSecSort.valueProperty().bindBidirectional(viewModel.saveSecSortSelectedValueProperty());
+ saveTerSort.valueProperty().bindBidirectional(viewModel.saveTerSortSelectedValueProperty());
+
+ savePriDesc.selectedProperty().bindBidirectional(viewModel.savePriDescPropertySelected());
+ saveSecDesc.selectedProperty().bindBidirectional(viewModel.saveSecDescPropertySelected());
+ saveTerDesc.selectedProperty().bindBidirectional(viewModel.saveTerDescPropertySelected());
+
+ }
+
+ public void changeExportDescriptionToSave() {
+ exportInOriginalOrder.setText(Localization.lang("Save entries in their original order"));
+ exportInSpecifiedOrder.setText(Localization.lang("Save entries ordered as specified"));
+ exportInTableOrder.setText(Localization.lang("Save in current table sort order"));
+ }
+
+ public void storeConfig() {
+ viewModel.storeConfigInPrefs();
+ }
+
+ public SaveOrderConfig getSaveOrderConfig() {
+ return viewModel.getSaveOrderConfig();
+ }
+
+}
diff --git a/src/main/java/org/jabref/gui/SaveOrderConfigDisplayViewModel.java b/src/main/java/org/jabref/gui/SaveOrderConfigDisplayViewModel.java
new file mode 100644
index 00000000000..0846ee4866c
--- /dev/null
+++ b/src/main/java/org/jabref/gui/SaveOrderConfigDisplayViewModel.java
@@ -0,0 +1,141 @@
+package org.jabref.gui;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
+
+import javafx.beans.property.BooleanProperty;
+import javafx.beans.property.ListProperty;
+import javafx.beans.property.SimpleBooleanProperty;
+import javafx.beans.property.SimpleListProperty;
+import javafx.beans.property.SimpleStringProperty;
+import javafx.beans.property.StringProperty;
+import javafx.collections.FXCollections;
+
+import org.jabref.model.entry.BibEntry;
+import org.jabref.model.entry.InternalBibtexFields;
+import org.jabref.model.metadata.SaveOrderConfig;
+import org.jabref.model.metadata.SaveOrderConfig.SortCriterion;
+import org.jabref.preferences.PreferencesService;
+
+public class SaveOrderConfigDisplayViewModel {
+
+ private final ListProperty priSortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
+ private final ListProperty secSortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
+ private final ListProperty terSortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
+
+ private final BooleanProperty savePriDescPropertySelected = new SimpleBooleanProperty();
+ private final BooleanProperty saveSecDescPropertySelected = new SimpleBooleanProperty();
+ private final BooleanProperty saveTerDescPropertySelected = new SimpleBooleanProperty();
+
+ private final StringProperty savePriSortSelectedValueProperty = new SimpleStringProperty("");
+ private final StringProperty saveSecSortSelectedValueProperty = new SimpleStringProperty("");
+ private final StringProperty saveTerSortSelectedValueProperty = new SimpleStringProperty("");
+
+ private final BooleanProperty saveInOriginalProperty = new SimpleBooleanProperty();
+ private final BooleanProperty saveInTableOrderProperty = new SimpleBooleanProperty();
+ private final BooleanProperty saveInSpecifiedOrderProperty = new SimpleBooleanProperty();
+
+ private final PreferencesService prefs;
+
+ public SaveOrderConfigDisplayViewModel(SaveOrderConfig config, PreferencesService prefs) {
+ this.prefs = prefs;
+
+ List fieldNames = InternalBibtexFields.getAllPublicFieldNames();
+ fieldNames.add(BibEntry.KEY_FIELD);
+ Collections.sort(fieldNames);
+
+ priSortFieldsProperty.addAll(fieldNames);
+ secSortFieldsProperty.addAll(fieldNames);
+ terSortFieldsProperty.addAll(fieldNames);
+
+ setSaveOrderConfig(config);
+ }
+
+ public ListProperty priSortFieldsProperty() {
+ return priSortFieldsProperty;
+ }
+
+ public ListProperty secSortFieldsProperty() {
+ return secSortFieldsProperty;
+ }
+
+ public ListProperty terSortFieldsProperty() {
+ return terSortFieldsProperty;
+ }
+
+ public SaveOrderConfig getSaveOrderConfig() {
+ SortCriterion primary = new SortCriterion(getSelectedItemAsLowerCaseTrim(savePriSortSelectedValueProperty), savePriDescPropertySelected.getValue());
+ SortCriterion secondary = new SortCriterion(getSelectedItemAsLowerCaseTrim(saveSecSortSelectedValueProperty), saveSecDescPropertySelected.getValue());
+ SortCriterion tertiary = new SortCriterion(getSelectedItemAsLowerCaseTrim(saveTerSortSelectedValueProperty), saveTerDescPropertySelected.getValue());
+
+ SaveOrderConfig saveOrderConfig = new SaveOrderConfig(saveInOriginalProperty.getValue(), saveInSpecifiedOrderProperty.getValue(), primary, secondary, tertiary);
+
+ return saveOrderConfig;
+ }
+
+ public void setSaveOrderConfig(SaveOrderConfig saveOrderConfig) {
+ Objects.requireNonNull(saveOrderConfig);
+
+ savePriSortSelectedValueProperty.setValue(saveOrderConfig.getSortCriteria().get(0).field);
+ savePriDescPropertySelected.setValue(saveOrderConfig.getSortCriteria().get(0).descending);
+ saveSecSortSelectedValueProperty.setValue(saveOrderConfig.getSortCriteria().get(1).field);
+ saveSecDescPropertySelected.setValue(saveOrderConfig.getSortCriteria().get(1).descending);
+ saveTerSortSelectedValueProperty.setValue(saveOrderConfig.getSortCriteria().get(2).field);
+ saveTerDescPropertySelected.setValue(saveOrderConfig.getSortCriteria().get(2).descending);
+
+ if (saveOrderConfig.saveInOriginalOrder()) {
+ saveInOriginalProperty.setValue(true);
+ } else if (saveOrderConfig.saveInSpecifiedOrder()) {
+ saveInSpecifiedOrderProperty.setValue(true);
+ } else {
+ saveInTableOrderProperty.setValue(true);
+ }
+
+ }
+
+ private String getSelectedItemAsLowerCaseTrim(StringProperty string) {
+ return string.getValue().toLowerCase(Locale.ROOT).trim();
+ }
+
+ public BooleanProperty savePriDescPropertySelected() {
+ return savePriDescPropertySelected;
+ }
+
+ public BooleanProperty saveSecDescPropertySelected() {
+ return saveSecDescPropertySelected;
+ }
+
+ public BooleanProperty saveTerDescPropertySelected() {
+ return saveTerDescPropertySelected;
+ }
+
+ public StringProperty savePriSortSelectedValueProperty() {
+ return savePriSortSelectedValueProperty;
+ }
+
+ public StringProperty saveSecSortSelectedValueProperty() {
+ return saveSecSortSelectedValueProperty;
+ }
+
+ public StringProperty saveTerSortSelectedValueProperty() {
+ return saveTerSortSelectedValueProperty;
+ }
+
+ public void storeConfigInPrefs() {
+ prefs.storeExportSaveOrder(this.getSaveOrderConfig());
+ }
+
+ public BooleanProperty saveInOriginalProperty() {
+ return saveInOriginalProperty;
+ }
+
+ public BooleanProperty saveInTableOrderProperty() {
+ return saveInTableOrderProperty;
+ }
+
+ public BooleanProperty saveInSpecifiedOrderProperty() {
+ return this.saveInSpecifiedOrderProperty;
+ }
+}
diff --git a/src/main/java/org/jabref/gui/actions/DatabasePropertiesAction.java b/src/main/java/org/jabref/gui/actions/DatabasePropertiesAction.java
deleted file mode 100644
index 564b6c5cc2f..00000000000
--- a/src/main/java/org/jabref/gui/actions/DatabasePropertiesAction.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.jabref.gui.actions;
-
-import org.jabref.gui.JabRefFrame;
-import org.jabref.gui.dbproperties.DatabasePropertiesDialog;
-
-public class DatabasePropertiesAction extends SimpleCommand {
-
- private final JabRefFrame frame;
-
- public DatabasePropertiesAction(JabRefFrame frame) {
- this.frame = frame;
- }
-
- @Override
- public void execute() {
- DatabasePropertiesDialog propertiesDialog = new DatabasePropertiesDialog(frame.getCurrentBasePanel());
- propertiesDialog.updateEnableStatus();
- propertiesDialog.setVisible(true);
- }
-
-}
diff --git a/src/main/java/org/jabref/gui/actions/LibraryPropertiesAction.java b/src/main/java/org/jabref/gui/actions/LibraryPropertiesAction.java
new file mode 100644
index 00000000000..1b2299e3f06
--- /dev/null
+++ b/src/main/java/org/jabref/gui/actions/LibraryPropertiesAction.java
@@ -0,0 +1,24 @@
+package org.jabref.gui.actions;
+
+import org.jabref.gui.DialogService;
+import org.jabref.gui.JabRefFrame;
+import org.jabref.gui.libraryproperties.LibraryPropertiesDialogView;
+
+public class LibraryPropertiesAction extends SimpleCommand {
+
+ private final JabRefFrame frame;
+ private final DialogService dialogService;
+
+ public LibraryPropertiesAction(JabRefFrame frame, DialogService dialogService) {
+ this.frame = frame;
+ this.dialogService = dialogService;
+ }
+
+ @Override
+ public void execute() {
+ LibraryPropertiesDialogView propertiesDialog = new LibraryPropertiesDialogView(frame.getCurrentBasePanel(), dialogService);
+ propertiesDialog.showAndWait();
+
+ }
+
+}
diff --git a/src/main/java/org/jabref/gui/dbproperties/DatabasePropertiesDialog.java b/src/main/java/org/jabref/gui/dbproperties/DatabasePropertiesDialog.java
deleted file mode 100644
index f1a58b0be7c..00000000000
--- a/src/main/java/org/jabref/gui/dbproperties/DatabasePropertiesDialog.java
+++ /dev/null
@@ -1,330 +0,0 @@
-package org.jabref.gui.dbproperties;
-
-import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.nio.charset.Charset;
-import java.util.Optional;
-
-import javax.swing.AbstractAction;
-import javax.swing.ActionMap;
-import javax.swing.BorderFactory;
-import javax.swing.ButtonGroup;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.InputMap;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JRadioButton;
-import javax.swing.JTextField;
-
-import javafx.embed.swing.JFXPanel;
-import javafx.scene.Parent;
-import javafx.scene.Scene;
-
-import org.jabref.Globals;
-import org.jabref.gui.BasePanel;
-import org.jabref.gui.DialogService;
-import org.jabref.gui.FXDialogService;
-import org.jabref.gui.JabRefDialog;
-import org.jabref.gui.SaveOrderConfigDisplay;
-import org.jabref.gui.cleanup.FieldFormatterCleanupsPanel;
-import org.jabref.gui.customjfx.CustomJFXPanel;
-import org.jabref.gui.help.HelpAction;
-import org.jabref.gui.keyboard.KeyBinding;
-import org.jabref.gui.util.DefaultTaskExecutor;
-import org.jabref.gui.util.DirectoryDialogConfiguration;
-import org.jabref.logic.cleanup.Cleanups;
-import org.jabref.logic.help.HelpFile;
-import org.jabref.logic.l10n.Encodings;
-import org.jabref.logic.l10n.Localization;
-import org.jabref.model.database.shared.DatabaseLocation;
-import org.jabref.model.metadata.MetaData;
-import org.jabref.model.metadata.SaveOrderConfig;
-import org.jabref.preferences.JabRefPreferences;
-
-import com.jgoodies.forms.builder.ButtonBarBuilder;
-import com.jgoodies.forms.builder.FormBuilder;
-import com.jgoodies.forms.layout.FormLayout;
-
-public class DatabasePropertiesDialog extends JabRefDialog {
-
- private final MetaData metaData;
- private final BasePanel panel;
- private final JComboBox encoding;
- private final JButton ok;
- private final JButton cancel;
- private final JTextField fileDir = new JTextField(40);
- private final JTextField fileDirIndv = new JTextField(40);
- private String oldFileVal = "";
- private String oldFileIndvVal = "";
- private SaveOrderConfig oldSaveOrderConfig;
-
- /* The code for "Save sort order" is copied from ExportSortingPrefsTab and slightly updated to fit storing at metadata */
- private JRadioButton saveInOriginalOrder;
-
- private JRadioButton saveInSpecifiedOrder;
-
- private final JCheckBox protect = new JCheckBox(
- Localization.lang("Refuse to save the library before external changes have been reviewed."));
- private boolean oldProtectVal;
- private SaveOrderConfigDisplay saveOrderPanel;
-
- private FieldFormatterCleanupsPanel fieldFormatterCleanupsPanel;
-
- public DatabasePropertiesDialog(BasePanel panel) {
- super(Localization.lang("Library properties"), true, DatabasePropertiesDialog.class);
- encoding = new JComboBox<>();
- encoding.setModel(new DefaultComboBoxModel<>(Encodings.ENCODINGS));
- ok = new JButton(Localization.lang("OK"));
- cancel = new JButton(Localization.lang("Cancel"));
- this.panel = panel;
- this.metaData = panel.getBibDatabaseContext().getMetaData();
- init();
- }
-
- public void updateEnableStatus() {
- DatabaseLocation location = panel.getBibDatabaseContext().getLocation();
- boolean isShared = (location == DatabaseLocation.SHARED);
- encoding.setEnabled(!isShared); // the encoding of shared database is always UTF-8
- saveInOriginalOrder.setEnabled(!isShared);
- saveInSpecifiedOrder.setEnabled(!isShared);
- saveOrderPanel.setEnabled(!isShared);
- protect.setEnabled(!isShared);
- }
-
- private void init() {
-
- DirectoryDialogConfiguration directoryDialogConfiguration = new DirectoryDialogConfiguration.Builder()
- .withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
- DialogService ds = new FXDialogService();
-
- JButton browseFile = new JButton(Localization.lang("Browse"));
- JButton browseFileIndv = new JButton(Localization.lang("Browse"));
-
- browseFile.addActionListener(e -> DefaultTaskExecutor
- .runInJavaFXThread(() -> ds.showDirectorySelectionDialog(directoryDialogConfiguration))
- .ifPresent(f -> fileDir.setText(f.toAbsolutePath().toString())));
- browseFileIndv.addActionListener(e -> DefaultTaskExecutor
- .runInJavaFXThread(() -> ds.showDirectorySelectionDialog(directoryDialogConfiguration))
- .ifPresent(f -> fileDirIndv.setText(f.toAbsolutePath().toString())));
-
- setupSortOrderConfiguration();
- FormLayout form = new FormLayout("left:pref, 4dlu, pref:grow, 4dlu, pref:grow, 4dlu, pref",
- "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, fill:pref:grow, 180dlu, fill:pref:grow,");
- FormBuilder builder = FormBuilder.create().layout(form);
- builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
- builder.add(Localization.lang("Library encoding")).xy(1, 1);
- builder.add(encoding).xy(3, 1);
-
- builder.addSeparator(Localization.lang("Override default file directories")).xyw(1, 3, 5);
- builder.add(Localization.lang("General file directory")).xy(1, 5);
- builder.add(fileDir).xy(3, 5);
- builder.add(browseFile).xy(5, 5);
- builder.add(Localization.lang("User-specific file directory")).xy(1, 7);
- builder.add(fileDirIndv).xy(3, 7);
- builder.add(browseFileIndv).xy(5, 7);
-
- builder.addSeparator(Localization.lang("Save sort order")).xyw(1, 13, 5);
- builder.add(saveInOriginalOrder).xyw(1, 15, 5);
- builder.add(saveInSpecifiedOrder).xyw(1, 17, 5);
-
- saveOrderPanel = new SaveOrderConfigDisplay();
- JFXPanel panel = CustomJFXPanel.wrap(new Scene((Parent) saveOrderPanel.getJFXPanel()));
- builder.add(panel).xyw(1, 21, 5);
-
- builder.addSeparator(Localization.lang("Library protection")).xyw(1, 23, 5);
- builder.add(protect).xyw(1, 25, 5);
-
- fieldFormatterCleanupsPanel = new FieldFormatterCleanupsPanel(Localization.lang("Enable save actions"),
- Cleanups.DEFAULT_SAVE_ACTIONS);
- builder.addSeparator(Localization.lang("Save actions")).xyw(1, 27, 5);
- builder.add(CustomJFXPanel.wrap(new Scene(fieldFormatterCleanupsPanel))).xyw(1, 29, 5);
-
- ButtonBarBuilder bb = new ButtonBarBuilder();
- bb.addGlue();
- bb.addButton(ok);
- bb.addButton(cancel);
- bb.addRelatedGap();
- bb.addButton(new HelpAction(HelpFile.DATABASE_PROPERTIES).getHelpButton());
- bb.addGlue();
- bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
- getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
- getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
- pack();
-
- AbstractAction closeAction = new AbstractAction() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- dispose();
- }
- };
- ActionMap am = builder.getPanel().getActionMap();
- InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
- im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE), "close");
- am.put("close", closeAction);
-
- ok.addActionListener(e -> {
- if (propertiesChanged()) {
- storeSettings();
- }
- dispose();
- });
-
- cancel.addActionListener(e -> dispose());
- }
-
- private boolean propertiesChanged() {
- Charset oldEncoding = panel.getBibDatabaseContext().getMetaData().getEncoding()
- .orElse(Globals.prefs.getDefaultEncoding());
- Charset newEncoding = (Charset) encoding.getSelectedItem();
- boolean saveActionsChanged = fieldFormatterCleanupsPanel.hasChanged();
- boolean saveOrderConfigChanged = !getNewSaveOrderConfig().equals(oldSaveOrderConfig);
- boolean changed = saveOrderConfigChanged || !newEncoding.equals(oldEncoding)
- || !oldFileVal.equals(fileDir.getText()) || !oldFileIndvVal.equals(fileDirIndv.getText())
- || (oldProtectVal != protect.isSelected()) || saveActionsChanged;
- return changed;
- }
-
- private SaveOrderConfig getNewSaveOrderConfig() {
- SaveOrderConfig saveOrderConfig = null;
- if (saveInOriginalOrder.isSelected()) {
- saveOrderConfig = SaveOrderConfig.getDefaultSaveOrder();
- } else {
- saveOrderConfig = saveOrderPanel.getSaveOrderConfig();
- saveOrderConfig.setSaveInSpecifiedOrder();
- }
- return saveOrderConfig;
- }
-
- private void setupSortOrderConfiguration() {
- saveInOriginalOrder = new JRadioButton(Localization.lang("Save entries in their original order"));
- saveInSpecifiedOrder = new JRadioButton(Localization.lang("Save entries ordered as specified"));
-
- ButtonGroup bg = new ButtonGroup();
- bg.add(saveInOriginalOrder);
- bg.add(saveInSpecifiedOrder);
- ActionListener listener = e -> {
- boolean selected = e.getSource() == saveInSpecifiedOrder;
- saveOrderPanel.setEnabled(selected);
- };
-
- saveInOriginalOrder.addActionListener(listener);
- saveInSpecifiedOrder.addActionListener(listener);
- }
-
- @Override
- public void setVisible(boolean visible) {
- if (visible) {
- setValues();
- }
- super.setVisible(visible);
- }
-
- private void setValues() {
- Optional charset = panel.getBibDatabaseContext().getMetaData().getEncoding();
- encoding.setSelectedItem(charset.orElse(Globals.prefs.getDefaultEncoding()));
-
- Optional storedSaveOrderConfig = metaData.getSaveOrderConfig();
- boolean selected;
- if (!storedSaveOrderConfig.isPresent()) {
- saveInOriginalOrder.setSelected(true);
- oldSaveOrderConfig = SaveOrderConfig.getDefaultSaveOrder();
- selected = false;
- } else {
- SaveOrderConfig saveOrderConfig = storedSaveOrderConfig.get();
- oldSaveOrderConfig = saveOrderConfig;
- if (saveOrderConfig.saveInOriginalOrder()) {
- saveInOriginalOrder.setSelected(true);
- selected = false;
- } else {
- saveInSpecifiedOrder.setSelected(true);
- selected = true;
- }
- saveOrderPanel.setSaveOrderConfig(saveOrderConfig);
- }
- saveOrderPanel.setEnabled(selected);
-
- Optional fileD = metaData.getDefaultFileDirectory();
- if (fileD.isPresent()) {
- fileDir.setText(fileD.get().trim());
- } else {
- fileDir.setText("");
- }
-
- String fileDI = metaData.getUserFileDirectory(Globals.prefs.getUser()).orElse(""); // File dir setting
- fileDirIndv.setText(fileDI);
- oldFileIndvVal = fileDirIndv.getText();
-
- protect.setSelected(metaData.isProtected());
-
- // Store original values to see if they get changed:
- oldFileVal = fileDir.getText();
- oldProtectVal = protect.isSelected();
-
- //set save actions
- fieldFormatterCleanupsPanel.setValues(metaData);
- }
-
- private void storeSettings() {
- Charset oldEncoding = panel.getBibDatabaseContext().getMetaData().getEncoding()
- .orElse(Globals.prefs.getDefaultEncoding());
- Charset newEncoding = (Charset) encoding.getSelectedItem();
- panel.getBibDatabaseContext().getMetaData().setEncoding(newEncoding);
-
- String text = fileDir.getText().trim();
- if (text.isEmpty()) {
- metaData.clearDefaultFileDirectory();
- } else {
- metaData.setDefaultFileDirectory(text);
- }
- // Repeat for individual file dir - reuse 'text' and 'dir' vars
- text = fileDirIndv.getText();
- if (text.isEmpty()) {
- metaData.clearUserFileDirectory(Globals.prefs.getUser());
- } else {
- metaData.setUserFileDirectory(Globals.prefs.getUser(), text);
- }
-
- if (protect.isSelected()) {
- metaData.markAsProtected();
- } else {
- metaData.markAsNotProtected();
- }
-
- SaveOrderConfig newSaveOrderConfig = getNewSaveOrderConfig();
-
- boolean saveOrderConfigChanged = !getNewSaveOrderConfig().equals(oldSaveOrderConfig);
-
- // See if any of the values have been modified:
- if (saveOrderConfigChanged) {
- if (newSaveOrderConfig.equals(SaveOrderConfig.getDefaultSaveOrder())) {
- metaData.clearSaveOrderConfig();
- } else {
- metaData.setSaveOrderConfig(newSaveOrderConfig);
- }
- }
-
- boolean saveActionsChanged = fieldFormatterCleanupsPanel.hasChanged();
- if (saveActionsChanged) {
- if (fieldFormatterCleanupsPanel.isDefaultSaveActions()) {
- metaData.clearSaveActions();
- } else {
- fieldFormatterCleanupsPanel.storeSettings(metaData);
- }
- }
-
- boolean changed = saveOrderConfigChanged || !newEncoding.equals(oldEncoding)
- || !oldFileVal.equals(fileDir.getText()) || !oldFileIndvVal.equals(fileDirIndv.getText())
- || (oldProtectVal != protect.isSelected()) || saveActionsChanged;
- // ... if so, mark base changed. Prevent the Undo button from removing
- // change marking:
- if (changed) {
- panel.markNonUndoableBaseChanged();
- }
- }
-}
diff --git a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialog.fxml b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialog.fxml
new file mode 100644
index 00000000000..126d9e959b6
--- /dev/null
+++ b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialog.fxml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogView.java b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogView.java
new file mode 100644
index 00000000000..8ed238faf8a
--- /dev/null
+++ b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogView.java
@@ -0,0 +1,175 @@
+package org.jabref.gui.libraryproperties;
+
+import java.nio.charset.Charset;
+import java.util.Optional;
+
+import javax.inject.Inject;
+
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.scene.control.Button;
+import javafx.scene.control.ButtonType;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.Label;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.VBox;
+
+import org.jabref.gui.BasePanel;
+import org.jabref.gui.DialogService;
+import org.jabref.gui.SaveOrderConfigDisplayView;
+import org.jabref.gui.cleanup.FieldFormatterCleanupsPanel;
+import org.jabref.gui.util.BaseDialog;
+import org.jabref.logic.cleanup.Cleanups;
+import org.jabref.logic.l10n.Localization;
+import org.jabref.model.metadata.MetaData;
+import org.jabref.model.metadata.SaveOrderConfig;
+import org.jabref.preferences.PreferencesService;
+
+import com.airhacks.afterburner.views.ViewLoader;
+
+public class LibraryPropertiesDialogView extends BaseDialog {
+
+ @FXML private VBox contentVbox;
+ @FXML private ComboBox encoding;
+ @FXML private TextField generalFileDirectory;
+ @FXML private Button browseGeneralFileDir;
+ @FXML private TextField userSpecificFileDirectory;
+ @FXML private Button browseUserSpefiicFileDir;
+ @FXML private CheckBox protect;
+ @Inject private PreferencesService preferencesService;
+
+ private BasePanel panel;
+ private LibraryPropertiesDialogViewModel viewModel;
+ private final DialogService dialogService;
+ private FieldFormatterCleanupsPanel fieldFormatterCleanupsPanel;
+ private SaveOrderConfigDisplayView saveOrderConfigDisplayView;
+ private SaveOrderConfig oldSaveOrderConfig;
+
+ public LibraryPropertiesDialogView(BasePanel panel, DialogService dialogService) {
+ this.dialogService = dialogService;
+ this.panel = panel;
+ ViewLoader.view(this)
+ .load()
+ .setAsDialogPane(this);
+
+ setResultConverter(btn -> {
+ if (btn == ButtonType.OK) {
+ storeSettings();
+ }
+ return null;
+ });
+
+ setTitle(Localization.lang("Library properties"));
+
+ }
+
+ @FXML
+ private void initialize() {
+ viewModel = new LibraryPropertiesDialogViewModel(panel, dialogService, preferencesService);
+
+ generalFileDirectory.textProperty().bindBidirectional(viewModel.generalFileDirectoryPropertyProperty());
+ userSpecificFileDirectory.textProperty().bindBidirectional(viewModel.userSpecificFileDirectoryProperty());
+
+ encoding.itemsProperty().bind(viewModel.encodingsProperty());
+ encoding.valueProperty().bindBidirectional(viewModel.selectedEncodingProperty());
+ encoding.disableProperty().bind(viewModel.encodingDisableProperty());
+ protect.disableProperty().bind(viewModel.protectDisableProperty());
+
+ Optional storedSaveOrderConfig = panel.getBibDatabaseContext().getMetaData().getSaveOrderConfig();
+ if (storedSaveOrderConfig.isPresent()) {
+ saveOrderConfigDisplayView = new SaveOrderConfigDisplayView(storedSaveOrderConfig.get());
+ oldSaveOrderConfig = storedSaveOrderConfig.get();
+ } else {
+ oldSaveOrderConfig = preferencesService.loadExportSaveOrder();
+ saveOrderConfigDisplayView = new SaveOrderConfigDisplayView(preferencesService.loadExportSaveOrder());
+ }
+
+ saveOrderConfigDisplayView.changeExportDescriptionToSave();
+ fieldFormatterCleanupsPanel = new FieldFormatterCleanupsPanel(Localization.lang("Enable save actions"),
+ Cleanups.DEFAULT_SAVE_ACTIONS);
+ Label saveActions = new Label(Localization.lang("Save actions"));
+ saveActions.getStyleClass().add("sectionHeader");
+
+ contentVbox.getChildren().addAll(saveOrderConfigDisplayView, saveActions, fieldFormatterCleanupsPanel);
+
+ protect.selectedProperty().bindBidirectional(viewModel.libraryProtectedProperty());
+
+ setValues();
+ }
+
+ private void setValues() {
+ fieldFormatterCleanupsPanel.setValues(panel.getBibDatabaseContext().getMetaData());
+ }
+
+ @FXML
+ public void browseGeneralFileDirectory(ActionEvent event) {
+ viewModel.browseGeneralDir();
+ }
+
+ @FXML
+ public void browseUserSpecificFileDirectory(ActionEvent event) {
+ viewModel.browseUserDir();
+ }
+
+ private void storeSettings() {
+ //FIXME: Move to viewModel until fieldFormatterCleanupsPanel is property implemented
+ MetaData metaData = panel.getBibDatabaseContext().getMetaData();
+ Charset oldEncoding = metaData.getEncoding()
+ .orElse(preferencesService.getDefaultEncoding());
+ Charset newEncoding = viewModel.selectedEncodingProperty().getValue();
+ metaData.setEncoding(newEncoding);
+
+ String text = viewModel.generalFileDirectoryPropertyProperty().getValue().trim();
+ if (text.isEmpty()) {
+ metaData.clearDefaultFileDirectory();
+ } else {
+ metaData.setDefaultFileDirectory(text);
+ }
+ // Repeat for individual file dir - reuse 'text' and 'dir' vars
+ text = viewModel.userSpecificFileDirectoryProperty().getValue();
+ if (text.isEmpty()) {
+ metaData.clearUserFileDirectory(preferencesService.getUser());
+ } else {
+ metaData.setUserFileDirectory(preferencesService.getUser(), text);
+ }
+
+ if (viewModel.libraryProtectedProperty().getValue()) {
+ metaData.markAsProtected();
+ } else {
+ metaData.markAsNotProtected();
+ }
+
+ SaveOrderConfig newSaveOrderConfig = saveOrderConfigDisplayView.getSaveOrderConfig();
+
+ boolean saveOrderConfigChanged = !newSaveOrderConfig.equals(oldSaveOrderConfig);
+
+ // See if any of the values have been modified:
+ if (saveOrderConfigChanged) {
+ if (newSaveOrderConfig.equals(SaveOrderConfig.getDefaultSaveOrder())) {
+ metaData.clearSaveOrderConfig();
+ } else {
+ metaData.setSaveOrderConfig(newSaveOrderConfig);
+ }
+ }
+
+ boolean saveActionsChanged = fieldFormatterCleanupsPanel.hasChanged();
+ if (saveActionsChanged) {
+ if (fieldFormatterCleanupsPanel.isDefaultSaveActions()) {
+ metaData.clearSaveActions();
+ } else {
+ fieldFormatterCleanupsPanel.storeSettings(metaData);
+ }
+ }
+ boolean encodingChanged = !newEncoding.equals(oldEncoding);
+
+ boolean changed = saveOrderConfigChanged || encodingChanged
+ || viewModel.generalFileDirChanged() || viewModel.userFileDirChanged()
+ || viewModel.protectedValueChanged() || saveActionsChanged;
+ // ... if so, mark base changed. Prevent the Undo button from removing
+ // change marking:
+ if (changed) {
+ panel.markNonUndoableBaseChanged();
+ }
+ }
+}
diff --git a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java
new file mode 100644
index 00000000000..05f3982d7e0
--- /dev/null
+++ b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java
@@ -0,0 +1,116 @@
+package org.jabref.gui.libraryproperties;
+
+import java.nio.charset.Charset;
+import java.util.Optional;
+
+import javafx.beans.property.BooleanProperty;
+import javafx.beans.property.ListProperty;
+import javafx.beans.property.ObjectProperty;
+import javafx.beans.property.SimpleBooleanProperty;
+import javafx.beans.property.SimpleListProperty;
+import javafx.beans.property.SimpleObjectProperty;
+import javafx.beans.property.SimpleStringProperty;
+import javafx.beans.property.StringProperty;
+import javafx.collections.FXCollections;
+
+import org.jabref.gui.BasePanel;
+import org.jabref.gui.DialogService;
+import org.jabref.gui.util.DirectoryDialogConfiguration;
+import org.jabref.logic.l10n.Encodings;
+import org.jabref.model.database.shared.DatabaseLocation;
+import org.jabref.model.metadata.MetaData;
+import org.jabref.preferences.PreferencesService;
+
+public class LibraryPropertiesDialogViewModel {
+
+ private final StringProperty generalFileDirectoryProperty = new SimpleStringProperty("");
+ private final StringProperty userSpecificFileDirectoryProperty = new SimpleStringProperty("");
+ private final ListProperty encodingsProperty = new SimpleListProperty<>(FXCollections.observableArrayList(Encodings.getCharsets()));
+ private final ObjectProperty selectedEncodingPropety = new SimpleObjectProperty<>(Encodings.getCharsets().get(0));
+ private final BooleanProperty libraryProtectedProperty = new SimpleBooleanProperty();
+ private final BooleanProperty encodingDisableProperty = new SimpleBooleanProperty();
+ private final BooleanProperty protectDisableProperty = new SimpleBooleanProperty();
+
+ private final DialogService dialogService;
+ private final DirectoryDialogConfiguration directoryDialogConfiguration;
+
+ private final String oldUserSpecificFileDir;
+ private final String oldGeneralFileDir;
+ private final boolean oldLibraryProtected;
+
+ public LibraryPropertiesDialogViewModel(BasePanel panel, DialogService dialogService, PreferencesService preferencesService) {
+ this.dialogService = dialogService;
+ MetaData metaData = panel.getBibDatabaseContext().getMetaData();
+
+ DatabaseLocation location = panel.getBibDatabaseContext().getLocation();
+ boolean isShared = (location == DatabaseLocation.SHARED);
+ encodingDisableProperty.setValue(isShared); // the encoding of shared database is always UTF-8
+ protectDisableProperty.setValue(isShared);
+
+ directoryDialogConfiguration = new DirectoryDialogConfiguration.Builder()
+ .withInitialDirectory(preferencesService.getWorkingDir()).build();
+
+ Optional charset = metaData.getEncoding();
+ selectedEncodingPropety.setValue(charset.orElse(preferencesService.getDefaultEncoding()));
+
+ Optional fileD = metaData.getDefaultFileDirectory();
+ fileD.ifPresent(path -> generalFileDirectoryProperty.setValue(path.trim()));
+
+ Optional fileDI = metaData.getUserFileDirectory(preferencesService.getUser());
+ fileDI.ifPresent(userSpecificFileDirectoryProperty::setValue);
+
+ oldUserSpecificFileDir = generalFileDirectoryProperty.getValue();
+ oldGeneralFileDir = userSpecificFileDirectoryProperty.getValue();
+
+ libraryProtectedProperty.setValue(metaData.isProtected());
+ oldLibraryProtected = libraryProtectedProperty.getValue();
+ }
+
+ public StringProperty generalFileDirectoryPropertyProperty() {
+ return this.generalFileDirectoryProperty;
+ }
+
+ public StringProperty userSpecificFileDirectoryProperty() {
+ return this.userSpecificFileDirectoryProperty;
+ }
+
+ public ListProperty encodingsProperty() {
+ return this.encodingsProperty;
+ }
+
+ public ObjectProperty selectedEncodingProperty() {
+ return this.selectedEncodingPropety;
+ }
+
+ public void browseGeneralDir() {
+ dialogService.showDirectorySelectionDialog(directoryDialogConfiguration).ifPresent(dir -> generalFileDirectoryProperty.setValue(dir.toAbsolutePath().toString()));
+ }
+
+ public void browseUserDir() {
+ dialogService.showDirectorySelectionDialog(directoryDialogConfiguration).ifPresent(dir -> userSpecificFileDirectoryProperty.setValue(dir.toAbsolutePath().toString()));
+ }
+
+ public BooleanProperty libraryProtectedProperty() {
+ return this.libraryProtectedProperty;
+ }
+
+ public boolean generalFileDirChanged() {
+ return !oldGeneralFileDir.equals(generalFileDirectoryProperty.getValue());
+ }
+
+ public boolean userFileDirChanged() {
+ return !oldUserSpecificFileDir.equals(userSpecificFileDirectoryProperty.getValue());
+ }
+
+ public boolean protectedValueChanged() {
+ return !oldLibraryProtected == libraryProtectedProperty.getValue();
+ }
+
+ public BooleanProperty encodingDisableProperty() {
+ return encodingDisableProperty;
+ }
+
+ public BooleanProperty protectDisableProperty() {
+ return protectDisableProperty;
+ }
+}
diff --git a/src/main/java/org/jabref/gui/preferences/ExportSortingPrefsTab.java b/src/main/java/org/jabref/gui/preferences/ExportSortingPrefsTab.java
index c567619ee61..000f2bd8053 100644
--- a/src/main/java/org/jabref/gui/preferences/ExportSortingPrefsTab.java
+++ b/src/main/java/org/jabref/gui/preferences/ExportSortingPrefsTab.java
@@ -1,17 +1,11 @@
package org.jabref.gui.preferences;
-import javafx.event.ActionEvent;
-import javafx.event.EventHandler;
import javafx.scene.Node;
-import javafx.scene.control.Label;
-import javafx.scene.control.RadioButton;
-import javafx.scene.control.Separator;
-import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.shape.Line;
-import org.jabref.gui.SaveOrderConfigDisplay;
+import org.jabref.gui.SaveOrderConfigDisplayView;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.JabRefPreferences;
@@ -20,53 +14,14 @@
*/
class ExportSortingPrefsTab extends Pane implements PrefsTab {
- private final JabRefPreferences prefs;
-
- private final RadioButton exportInOriginalOrder;
- private final RadioButton exportInTableOrder;
- private final RadioButton exportInSpecifiedOrder;
- private final SaveOrderConfigDisplay exportOrderPanel;
+ private final SaveOrderConfigDisplayView exportOrderPanel;
private final GridPane builder = new GridPane();
public ExportSortingPrefsTab(JabRefPreferences prefs) {
- this.prefs = prefs;
- // EXPORT SORT ORDER
- // create Components
- exportInOriginalOrder = new RadioButton(Localization.lang("Export entries in their original order"));
- exportInTableOrder = new RadioButton(Localization.lang("Export in current table sort order"));
- exportInSpecifiedOrder = new RadioButton(Localization.lang("Export entries ordered as specified"));
-
- final ToggleGroup group = new ToggleGroup();
- exportInOriginalOrder.setToggleGroup(group);
- exportInTableOrder.setToggleGroup(group);
- exportInSpecifiedOrder.setToggleGroup(group);
-
- exportOrderPanel = new SaveOrderConfigDisplay();
-
- EventHandler listener = (event) -> {
- boolean selected = event.getSource() == exportInSpecifiedOrder;
- exportOrderPanel.setEnabled(selected);
- };
-
- exportInOriginalOrder.setOnAction(listener);
- exportInTableOrder.setOnAction(listener);
- exportInSpecifiedOrder.setOnAction(listener);
+ exportOrderPanel = new SaveOrderConfigDisplayView(prefs.loadExportSaveOrder());
- Label exportSortOrder = new Label(Localization.lang("Export sort order"));
- exportSortOrder.getStyleClass().add("sectionHeader");
- // create GUI
- builder.add(exportSortOrder, 1, 1);
- builder.add(new Separator(), 2, 1);
- builder.add(exportInOriginalOrder, 1, 2);
- builder.add(new Line(), 2, 3);
- builder.add(exportInTableOrder, 1, 4);
- builder.add(new Line(), 2, 5);
- builder.add(exportInSpecifiedOrder, 1, 6);
- builder.add(new Line(), 2, 7);
-
- builder.add(exportOrderPanel.getJFXPanel(), 1, 8);
+ builder.add(exportOrderPanel, 1, 8);
builder.add(new Line(), 2, 9);
-
}
@Override
@@ -76,25 +31,12 @@ public Node getBuilder() {
@Override
public void setValues() {
- if (prefs.getBoolean(JabRefPreferences.EXPORT_IN_ORIGINAL_ORDER)) {
- exportInOriginalOrder.setSelected(true);
- } else if (prefs.getBoolean(JabRefPreferences.EXPORT_IN_SPECIFIED_ORDER)) {
- exportInSpecifiedOrder.setSelected(true);
- } else {
- exportInTableOrder.setSelected(true);
- }
-
- boolean selected = prefs.getBoolean(JabRefPreferences.EXPORT_IN_SPECIFIED_ORDER);
- exportOrderPanel.setEnabled(selected);
- exportOrderPanel.setSaveOrderConfig(prefs.loadExportSaveOrder());
+ //empty
}
@Override
public void storeSettings() {
- prefs.putBoolean(JabRefPreferences.EXPORT_IN_ORIGINAL_ORDER, exportInOriginalOrder.isSelected());
- prefs.putBoolean(JabRefPreferences.EXPORT_IN_SPECIFIED_ORDER, exportInSpecifiedOrder.isSelected());
-
- prefs.storeExportSaveOrder(exportOrderPanel.getSaveOrderConfig());
+ exportOrderPanel.storeConfig();
}
@Override
diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.css b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.css
index 2b2d8c34859..f79bfba706e 100644
--- a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.css
+++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.css
@@ -12,8 +12,3 @@
.preferencePaneContainer {
-fx-padding: 0em 1em 0em 3em;
}
-
-.sectionHeader {
- -fx-font-size: 1.5em;
- -fx-padding: 1em 0em 1em 0em;
-}
diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.fxml b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.fxml
new file mode 100644
index 00000000000..2e41e88e6c2
--- /dev/null
+++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.fxml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java
index 8881f6af654..e966cd2eb66 100644
--- a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java
+++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java
@@ -5,6 +5,7 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
+import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBar.ButtonData;
@@ -37,6 +38,7 @@
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.JabRefPreferencesFilter;
+import com.airhacks.afterburner.views.ViewLoader;
import org.fxmisc.easybind.EasyBind;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,6 +64,10 @@ public PreferencesDialog(JabRefFrame parent, TaskExecutor taskExecutor) {
setTitle(Localization.lang("JabRef preferences"));
getDialogPane().getScene().getStylesheets().add(this.getClass().getResource("PreferencesDialog.css").toExternalForm());
+ ViewLoader.view(this)
+ .load()
+ .setAsDialogPane(this);
+
ButtonType save = new ButtonType(Localization.lang("Save"), ButtonData.OK_DONE);
getDialogPane().getButtonTypes().addAll(save, ButtonType.CANCEL);
ControlHelper.setAction(save, getDialogPane(), event -> {
@@ -93,9 +99,15 @@ public PreferencesDialog(JabRefFrame parent, TaskExecutor taskExecutor) {
container = new BorderPane();
getDialogPane().setContent(container);
+
construct();
}
+ @FXML
+ private void initalize() {
+ //FIXME: Model whole dialog as fxml
+ }
+
private void construct() {
VBox vBox = new VBox();
vBox.setPrefWidth(160);
@@ -112,8 +124,8 @@ private void construct() {
});
tabsList.getSelectionModel().selectFirst();
new ViewModelListCellFactory()
- .withText(PrefsTab::getTabName)
- .install(tabsList);
+ .withText(PrefsTab::getTabName)
+ .install(tabsList);
VBox buttonContainer = new VBox();
buttonContainer.setAlignment(Pos.BOTTOM_LEFT);
@@ -133,37 +145,38 @@ private void construct() {
resetPreferences.setOnAction(e -> resetPreferences());
resetPreferences.setMaxWidth(Double.MAX_VALUE);
buttonContainer.getChildren().addAll(
- importPreferences,
- exportPreferences,
- showPreferences,
- resetPreferences);
+ importPreferences,
+ exportPreferences,
+ showPreferences,
+ resetPreferences);
VBox spacer = new VBox();
spacer.setPrefHeight(10.0);
VBox.setVgrow(tabsList, Priority.ALWAYS);
VBox.setVgrow(spacer, Priority.SOMETIMES);
vBox.getChildren().addAll(
- tabsList,
- spacer,
- buttonContainer);
+ tabsList,
+ spacer,
+ buttonContainer);
container.setLeft(vBox);
setValues();
+
}
private void resetPreferences() {
boolean resetPreferencesConfirmed = dialogService.showConfirmationDialogAndWait(
- Localization.lang("Reset preferences"),
- Localization.lang("Are you sure you want to reset all settings to default values?"),
- Localization.lang("Reset preferences"),
- Localization.lang("Cancel"));
+ Localization.lang("Reset preferences"),
+ Localization.lang("Are you sure you want to reset all settings to default values?"),
+ Localization.lang("Reset preferences"),
+ Localization.lang("Cancel"));
if (resetPreferencesConfirmed) {
try {
prefs.clear();
dialogService.showWarningDialogAndWait(Localization.lang("Reset preferences"),
- Localization.lang("You must restart JabRef for this to come into effect."));
+ Localization.lang("You must restart JabRef for this to come into effect."));
} catch (BackingStoreException ex) {
LOGGER.error("Error while resetting preferences", ex);
dialogService.showErrorDialogAndWait(Localization.lang("Reset preferences"), ex);
@@ -174,9 +187,9 @@ private void resetPreferences() {
private void importPreferences() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
- .addExtensionFilter(StandardFileType.XML)
- .withDefaultExtension(StandardFileType.XML)
- .withInitialDirectory(prefs.setLastPreferencesExportPath()).build();
+ .addExtensionFilter(StandardFileType.XML)
+ .withDefaultExtension(StandardFileType.XML)
+ .withInitialDirectory(prefs.setLastPreferencesExportPath()).build();
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> {
try {
@@ -184,7 +197,7 @@ private void importPreferences() {
updateAfterPreferenceChanges();
dialogService.showWarningDialogAndWait(Localization.lang("Import preferences"),
- Localization.lang("You must restart JabRef for this to come into effect."));
+ Localization.lang("You must restart JabRef for this to come into effect."));
} catch (JabRefException ex) {
LOGGER.error("Error while importing preferences", ex);
dialogService.showErrorDialogAndWait(Localization.lang("Import preferences"), ex);
@@ -229,10 +242,10 @@ public void setValues() {
private void exportPreferences() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
- .addExtensionFilter(StandardFileType.XML)
- .withDefaultExtension(StandardFileType.XML)
- .withInitialDirectory(prefs.setLastPreferencesExportPath())
- .build();
+ .addExtensionFilter(StandardFileType.XML)
+ .withDefaultExtension(StandardFileType.XML)
+ .withInitialDirectory(prefs.setLastPreferencesExportPath())
+ .build();
dialogService.showFileSaveDialog(fileDialogConfiguration)
.ifPresent(exportFile -> {
diff --git a/src/main/java/org/jabref/model/metadata/SaveOrderConfig.java b/src/main/java/org/jabref/model/metadata/SaveOrderConfig.java
index 63b43eb4d45..8bc318987a3 100644
--- a/src/main/java/org/jabref/model/metadata/SaveOrderConfig.java
+++ b/src/main/java/org/jabref/model/metadata/SaveOrderConfig.java
@@ -16,13 +16,15 @@ public class SaveOrderConfig {
private static final String SPECIFIED = "specified";
private final LinkedList sortCriteria = new LinkedList<>();
private boolean saveInOriginalOrder;
+ private boolean saveInSpecifiedOrder;
public SaveOrderConfig() {
setSaveInOriginalOrder();
}
- public SaveOrderConfig(boolean saveInOriginalOrder, SortCriterion first, SortCriterion second, SortCriterion third) {
+ public SaveOrderConfig(boolean saveInOriginalOrder, boolean saveInSpecifiedOrder, SortCriterion first, SortCriterion second, SortCriterion third) {
this.saveInOriginalOrder = saveInOriginalOrder;
+ this.saveInSpecifiedOrder = saveInSpecifiedOrder;
sortCriteria.add(first);
sortCriteria.add(second);
sortCriteria.add(third);
@@ -61,6 +63,10 @@ public boolean saveInOriginalOrder() {
return saveInOriginalOrder;
}
+ public boolean saveInSpecifiedOrder() {
+ return saveInSpecifiedOrder;
+ }
+
public LinkedList getSortCriteria() {
return sortCriteria;
}
@@ -79,14 +85,15 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
- return Objects.hash(saveInOriginalOrder, sortCriteria);
+ return Objects.hash(saveInOriginalOrder, saveInSpecifiedOrder, sortCriteria);
}
@Override
public String toString() {
- return "SaveOrderConfig{" + "saveInOriginalOrder=" + saveInOriginalOrder +
- ", sortCriteria=" + sortCriteria +
- '}';
+ return "SaveOrderConfig{" + "saveInOriginalOrder=" + saveInOriginalOrder
+ + "saveInSpecifiedOrder =" + saveInSpecifiedOrder
+ + ", sortCriteria=" + sortCriteria +
+ '}';
}
public void setSaveInOriginalOrder() {
@@ -95,6 +102,7 @@ public void setSaveInOriginalOrder() {
public void setSaveInSpecifiedOrder() {
this.saveInOriginalOrder = false;
+ this.saveInSpecifiedOrder = true;
}
/**
@@ -139,8 +147,8 @@ public SortCriterion() {
@Override
public String toString() {
return "SortCriterion{" + "field='" + field + '\'' +
- ", descending=" + descending +
- '}';
+ ", descending=" + descending +
+ '}';
}
@Override
@@ -153,7 +161,7 @@ public boolean equals(Object o) {
}
SortCriterion that = (SortCriterion) o;
return Objects.equals(descending, that.descending) &&
- Objects.equals(field, that.field);
+ Objects.equals(field, that.field);
}
@Override
diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java
index 4970e4de5c2..88eae71f20a 100644
--- a/src/main/java/org/jabref/preferences/JabRefPreferences.java
+++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java
@@ -913,6 +913,7 @@ public Map getSidePanePreferredPositions() {
return preferredPositions;
}
+ @Override
public String getUser() {
try {
return get(DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName();
@@ -1396,10 +1397,12 @@ public String getWrappedUsername() {
return '[' + get(DEFAULT_OWNER) + ']';
}
+ @Override
public Charset getDefaultEncoding() {
return Charset.forName(get(DEFAULT_ENCODING));
}
+ @Override
public void setDefaultEncoding(Charset encoding) {
put(DEFAULT_ENCODING, encoding.name());
}
@@ -1692,10 +1695,13 @@ public void setRemotePreferences(RemotePreferences remotePreferences) {
putBoolean(USE_REMOTE_SERVER, remotePreferences.useRemoteServer());
}
+ @Override
public void storeExportSaveOrder(SaveOrderConfig config) {
putBoolean(EXPORT_PRIMARY_SORT_DESCENDING, config.getSortCriteria().get(0).descending);
putBoolean(EXPORT_SECONDARY_SORT_DESCENDING, config.getSortCriteria().get(1).descending);
putBoolean(EXPORT_TERTIARY_SORT_DESCENDING, config.getSortCriteria().get(2).descending);
+ putBoolean(EXPORT_IN_ORIGINAL_ORDER, config.saveInOriginalOrder());
+ putBoolean(EXPORT_IN_SPECIFIED_ORDER, config.saveInSpecifiedOrder());
put(EXPORT_PRIMARY_SORT_FIELD, config.getSortCriteria().get(0).field);
put(EXPORT_SECONDARY_SORT_FIELD, config.getSortCriteria().get(1).field);
@@ -1714,8 +1720,9 @@ private SaveOrderConfig loadTableSaveOrder() {
return config;
}
+ @Override
public SaveOrderConfig loadExportSaveOrder() {
- return new SaveOrderConfig(true,
+ return new SaveOrderConfig(getBoolean(EXPORT_IN_ORIGINAL_ORDER), getBoolean(EXPORT_IN_SPECIFIED_ORDER),
new SaveOrderConfig.SortCriterion(get(EXPORT_PRIMARY_SORT_FIELD), getBoolean(EXPORT_PRIMARY_SORT_DESCENDING)),
new SaveOrderConfig.SortCriterion(get(EXPORT_SECONDARY_SORT_FIELD), getBoolean(EXPORT_SECONDARY_SORT_DESCENDING)),
new SaveOrderConfig.SortCriterion(get(EXPORT_TERTIARY_SORT_FIELD), getBoolean(EXPORT_TERTIARY_SORT_DESCENDING))
diff --git a/src/main/java/org/jabref/preferences/PreferencesService.java b/src/main/java/org/jabref/preferences/PreferencesService.java
index 726b2ec4966..fea7e8d52b7 100644
--- a/src/main/java/org/jabref/preferences/PreferencesService.java
+++ b/src/main/java/org/jabref/preferences/PreferencesService.java
@@ -1,5 +1,6 @@
package org.jabref.preferences;
+import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
@@ -15,6 +16,7 @@
import org.jabref.logic.protectedterms.ProtectedTermsLoader;
import org.jabref.logic.util.UpdateFieldPreferences;
import org.jabref.model.metadata.FilePreferences;
+import org.jabref.model.metadata.SaveOrderConfig;
public interface PreferencesService {
@@ -70,8 +72,18 @@ public interface PreferencesService {
String getExportWorkingDirectory();
+ Charset getDefaultEncoding();
+
+ void setDefaultEncoding(Charset encoding);
+
+ String getUser();
+
void setExportWorkingDirectory(String layoutFileDirString);
+ SaveOrderConfig loadExportSaveOrder();
+
+ void storeExportSaveOrder(SaveOrderConfig config);
+
boolean shouldWarnAboutDuplicatesForImport();
void setShouldWarnAboutDuplicatesForImport(boolean value);
diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties
index 0a4929876ab..1c95118f7c1 100644
--- a/src/main/resources/l10n/JabRef_en.properties
+++ b/src/main/resources/l10n/JabRef_en.properties
@@ -1398,8 +1398,8 @@ Export\ sort\ order=Export sort order
Export\ sorting=Export sorting
Newline\ separator=Newline separator
+Save\ in\ current\ table\ sort\ order=Save in current table sort order
Save\ entries\ ordered\ as\ specified=Save entries ordered as specified
-Save\ sort\ order=Save sort order
Show\ extra\ columns=Show extra columns
Parsing\ error=Parsing error
illegal\ backslash\ expression=illegal backslash expression
diff --git a/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java b/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java
index e30ecf77ca8..a7f2ef36a4c 100644
--- a/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java
+++ b/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java
@@ -435,7 +435,7 @@ void writeSaveActions() throws Exception {
@Test
void writeSaveOrderConfig() throws Exception {
- SaveOrderConfig saveOrderConfig = new SaveOrderConfig(false, new SaveOrderConfig.SortCriterion("author", false),
+ SaveOrderConfig saveOrderConfig = new SaveOrderConfig(false, true, new SaveOrderConfig.SortCriterion("author", false),
new SaveOrderConfig.SortCriterion("year", true),
new SaveOrderConfig.SortCriterion("abstract", false));
metaData.setSaveOrderConfig(saveOrderConfig);
@@ -495,7 +495,7 @@ void writeFileDirectories() throws Exception {
@Test
void writeEntriesSorted() throws Exception {
- SaveOrderConfig saveOrderConfig = new SaveOrderConfig(false,
+ SaveOrderConfig saveOrderConfig = new SaveOrderConfig(false, true,
new SaveOrderConfig.SortCriterion("author", false),
new SaveOrderConfig.SortCriterion("year", true),
new SaveOrderConfig.SortCriterion("abstract", false));
diff --git a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java
index 59e5d7d250e..116cfd198aa 100644
--- a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java
+++ b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java
@@ -57,7 +57,7 @@ class BibtexParserTest {
private ImportFormatPreferences importFormatPreferences;
private BibtexParser parser;
- private FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor();
+ private final FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor();
@BeforeEach
void setUp() {
@@ -1338,7 +1338,7 @@ void integrationTestSaveOrderConfig() throws IOException {
Optional saveOrderConfig = result.getMetaData().getSaveOrderConfig();
- assertEquals(new SaveOrderConfig(false, new SaveOrderConfig.SortCriterion("author", false),
+ assertEquals(new SaveOrderConfig(false, true, new SaveOrderConfig.SortCriterion("author", false),
new SaveOrderConfig.SortCriterion("year", true), new SaveOrderConfig.SortCriterion("abstract", false)),
saveOrderConfig.get());
}