diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 462786823ae..c5da1a5125f 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -753,7 +753,7 @@ private MenuBar createMenu() { new SeparatorMenuItem(), - factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(this, dialogService, stateManager)), + factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(this, stateManager)), factory.createMenuItem(StandardActions.EDIT_PREAMBLE, new PreambleEditor(stateManager, undoManager, this.getDialogService())), factory.createMenuItem(StandardActions.EDIT_STRINGS, new BibtexStringEditorAction(stateManager)), factory.createMenuItem(StandardActions.MANAGE_CITE_KEY_PATTERNS, new BibtexKeyPatternAction(this, stateManager)) diff --git a/src/main/java/org/jabref/gui/SaveOrderConfigDisplayViewModel.java b/src/main/java/org/jabref/gui/SaveOrderConfigDisplayViewModel.java deleted file mode 100644 index 89ef04f1c25..00000000000 --- a/src/main/java/org/jabref/gui/SaveOrderConfigDisplayViewModel.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.jabref.gui; - -import java.util.Objects; -import java.util.Set; - -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.collections.FXCollections; - -import org.jabref.model.entry.field.Field; -import org.jabref.model.entry.field.FieldFactory; -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 ObjectProperty savePriSortSelectedValueProperty = new SimpleObjectProperty<>(null); - private final ObjectProperty saveSecSortSelectedValueProperty = new SimpleObjectProperty<>(null); - private final ObjectProperty saveTerSortSelectedValueProperty = new SimpleObjectProperty<>(null); - - private final BooleanProperty saveInOriginalProperty = new SimpleBooleanProperty(); - private final BooleanProperty saveInTableOrderProperty = new SimpleBooleanProperty(); - private final BooleanProperty saveInSpecifiedOrderProperty = new SimpleBooleanProperty(); - - private final PreferencesService prefs; - - public SaveOrderConfigDisplayViewModel(PreferencesService prefs) { - this.prefs = prefs; - - Set fieldNames = FieldFactory.getCommonFields(); - priSortFieldsProperty.addAll(fieldNames); - secSortFieldsProperty.addAll(fieldNames); - terSortFieldsProperty.addAll(fieldNames); - } - - public ListProperty priSortFieldsProperty() { - return priSortFieldsProperty; - } - - public ListProperty secSortFieldsProperty() { - return secSortFieldsProperty; - } - - public ListProperty terSortFieldsProperty() { - return terSortFieldsProperty; - } - - public SaveOrderConfig getSaveOrderConfig() { - SortCriterion primary = new SortCriterion(savePriSortSelectedValueProperty.get(), savePriDescPropertySelected.getValue()); - SortCriterion secondary = new SortCriterion(saveSecSortSelectedValueProperty.get(), saveSecDescPropertySelected.getValue()); - SortCriterion tertiary = new SortCriterion(saveTerSortSelectedValueProperty.get(), saveTerDescPropertySelected.getValue()); - - return new SaveOrderConfig(saveInOriginalProperty.getValue(), saveInSpecifiedOrderProperty.getValue(), primary, secondary, tertiary); - } - - 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); - } - - } - - public BooleanProperty savePriDescPropertySelected() { - return savePriDescPropertySelected; - } - - public BooleanProperty saveSecDescPropertySelected() { - return saveSecDescPropertySelected; - } - - public BooleanProperty saveTerDescPropertySelected() { - return saveTerDescPropertySelected; - } - - public ObjectProperty savePriSortSelectedValueProperty() { - return savePriSortSelectedValueProperty; - } - - public ObjectProperty saveSecSortSelectedValueProperty() { - return saveSecSortSelectedValueProperty; - } - - public ObjectProperty 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/cleanup/CleanupPresetPanel.fxml b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.fxml index 1ca9d6ebafa..608cdc12823 100644 --- a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.fxml +++ b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.fxml @@ -4,6 +4,7 @@ + @@ -28,6 +29,5 @@ - - + diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java index 563fb7ac9e4..3ea9fa7c8c7 100644 --- a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java +++ b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java @@ -6,13 +6,16 @@ import java.util.Optional; import java.util.Set; +import javafx.collections.FXCollections; import javafx.fxml.FXML; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; import javafx.scene.layout.VBox; +import org.jabref.gui.commonfxcontrols.FieldFormatterCleanupsPanel; import org.jabref.logic.cleanup.CleanupPreset; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.field.StandardField; import org.jabref.model.metadata.FilePreferences; @@ -33,8 +36,7 @@ public class CleanupPresetPanel extends VBox { @FXML private CheckBox cleanUpUpgradeExternalLinks; @FXML private CheckBox cleanUpBiblatex; @FXML private CheckBox cleanUpBibtex; - @FXML private VBox formatterContainer; - private FieldFormatterCleanupsPanel cleanUpFormatters; + @FXML private FieldFormatterCleanupsPanel formatterCleanupsPanel; public CleanupPresetPanel(BibDatabaseContext databaseContext, CleanupPreset cleanupPreset, FilePreferences filePreferences) { this.databaseContext = Objects.requireNonNull(databaseContext); @@ -63,9 +65,6 @@ private void init(CleanupPreset cleanupPreset, FilePreferences filePreferences) cleanUpUpgradeExternalLinks.setText(Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", StandardField.FILE.getDisplayName())); - cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:")); - formatterContainer.getChildren().setAll(cleanUpFormatters); - String currentPattern = Localization.lang("Filename format pattern") .concat(": ") .concat(filePreferences.getFileNamePattern()); @@ -87,7 +86,8 @@ private void updateDisplay(CleanupPreset preset) { cleanUpBiblatex.setSelected(preset.isActive(CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX)); cleanUpBibtex.setSelected(preset.isActive(CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX)); cleanUpISSN.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEAN_UP_ISSN)); - cleanUpFormatters.setValues(preset.getFormatterCleanups()); + formatterCleanupsPanel.cleanupsDisableProperty().setValue(!preset.getFormatterCleanups().isEnabled()); + formatterCleanupsPanel.cleanupsProperty().setValue(FXCollections.observableArrayList(preset.getFormatterCleanups().getConfiguredActions())); } public CleanupPreset getCleanupPreset() { @@ -127,6 +127,8 @@ public CleanupPreset getCleanupPreset() { activeJobs.add(CleanupPreset.CleanupStep.FIX_FILE_LINKS); - return new CleanupPreset(activeJobs, cleanUpFormatters.getFormatterCleanups()); + return new CleanupPreset(activeJobs, new FieldFormatterCleanups( + !formatterCleanupsPanel.cleanupsDisableProperty().getValue(), + formatterCleanupsPanel.cleanupsProperty())); } } diff --git a/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java b/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java deleted file mode 100644 index 70cc748e2b7..00000000000 --- a/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java +++ /dev/null @@ -1,252 +0,0 @@ -package org.jabref.gui.cleanup; - -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; - -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.ComboBox; -import javafx.scene.control.Label; -import javafx.scene.control.ListView; -import javafx.scene.control.SelectionMode; -import javafx.scene.layout.ColumnConstraints; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.RowConstraints; - -import org.jabref.Globals; -import org.jabref.JabRefGUI; -import org.jabref.gui.util.ViewModelListCellFactory; -import org.jabref.logic.cleanup.Cleanups; -import org.jabref.logic.formatter.casechanger.ProtectTermsFormatter; -import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.FieldFormatterCleanup; -import org.jabref.model.cleanup.FieldFormatterCleanups; -import org.jabref.model.cleanup.Formatter; -import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.entry.field.Field; -import org.jabref.model.entry.field.FieldFactory; -import org.jabref.model.entry.field.InternalField; -import org.jabref.model.metadata.MetaData; - -import org.fxmisc.easybind.EasyBind; - -public class FieldFormatterCleanupsPanel extends GridPane { - - private static final String DESCRIPTION = Localization.lang("Description") + ": "; - private final CheckBox cleanupEnabled; - private final List availableFormatters; - private FieldFormatterCleanups fieldFormatterCleanups; - private ListView actionsList; - private ComboBox formattersCombobox; - private ComboBox selectFieldCombobox; - private Button addButton; - private Label descriptionAreaText; - private Button removeSelectedButton; - private Button removeAllButton; - private Button recommendButton; - private ObservableList actions; - - public FieldFormatterCleanupsPanel(String description) { - cleanupEnabled = new CheckBox(description); - availableFormatters = Cleanups.getBuiltInFormatters(); - availableFormatters.add(new ProtectTermsFormatter(Globals.protectedTermsLoader)); - } - - public void setValues(MetaData metaData) { - Objects.requireNonNull(metaData); - Optional saveActions = metaData.getSaveActions(); - setValues(saveActions.orElse(Cleanups.DEFAULT_SAVE_ACTIONS)); - } - - public void setValues(FieldFormatterCleanups formatterCleanups) { - fieldFormatterCleanups = formatterCleanups; - - // first clear existing content - this.getChildren().clear(); - - List configuredActions = fieldFormatterCleanups.getConfiguredActions(); - actions = FXCollections.observableArrayList(configuredActions); - buildLayout(); - } - - private void buildLayout() { - setHgap(10.0); - setVgap(4.0); - - ColumnConstraints first = new ColumnConstraints(); - first.setPrefWidth(25); - ColumnConstraints second = new ColumnConstraints(); - second.setPrefWidth(175); - ColumnConstraints third = new ColumnConstraints(); - third.setPrefWidth(200); - ColumnConstraints fourth = new ColumnConstraints(); - fourth.setPrefWidth(200); - getColumnConstraints().addAll(first, second, third, fourth); - RowConstraints firstR = new RowConstraints(); - firstR.setPrefHeight(25); - RowConstraints secondR = new RowConstraints(); - secondR.setPrefHeight(100); - RowConstraints thirdR = new RowConstraints(); - thirdR.setPrefHeight(50); - RowConstraints fourthR = new RowConstraints(); - fourthR.setPrefHeight(50); - RowConstraints fifthR = new RowConstraints(); - fifthR.setPrefHeight(50); - getRowConstraints().addAll(firstR, secondR, thirdR, fourthR, fifthR); - add(cleanupEnabled, 0, 0, 4, 1); - - actionsList = new ListView<>(actions); - actionsList.setMinHeight(100.0); - actionsList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); - - new ViewModelListCellFactory() - .withText(action -> action.getField().getDisplayName() + ": " + action.getFormatter().getName()) - .withStringTooltip(action -> action.getFormatter().getDescription()) - .install(actionsList); - add(actionsList, 1, 1, 3, 1); - - removeAllButton = new Button(Localization.lang("Remove all")); - removeAllButton.setOnAction(e -> actions.clear()); - - BibDatabaseContext databaseContext = JabRefGUI.getMainFrame().getCurrentBasePanel().getBibDatabaseContext(); - - recommendButton = new Button(Localization.lang("Reset to recommended")); - boolean isBiblatex = databaseContext.isBiblatexMode(); - - recommendButton.setOnAction(e -> { - if (isBiblatex) { - actions.setAll(Cleanups.RECOMMEND_BIBLATEX_ACTIONS.getConfiguredActions()); - } else { - actions.setAll(Cleanups.RECOMMEND_BIBTEX_ACTIONS.getConfiguredActions()); - } - }); - - removeSelectedButton = new Button(Localization.lang("Remove selected")); - removeSelectedButton.setOnAction(e -> actions.remove(actionsList.getSelectionModel().getSelectedItem())); - descriptionAreaText = new Label(DESCRIPTION); - descriptionAreaText.setWrapText(true); - - add(recommendButton, 1, 2, 1, 1); - add(removeSelectedButton, 2, 2, 1, 1); - add(removeAllButton, 3, 2, 1, 1); - add(getSelectorPanel(), 1, 3, 3, 1); - add(descriptionAreaText, 1, 4, 3, 1); - - updateDescription(); - - // make sure the layout is set according to the checkbox - cleanupEnabled.selectedProperty().addListener(new EnablementStatusListener<>(fieldFormatterCleanups.isEnabled())); - cleanupEnabled.setSelected(fieldFormatterCleanups.isEnabled()); - } - - private void updateDescription() { - FieldFormatterCleanup formatterCleanup = getFieldFormatterCleanup(); - if (formatterCleanup.getFormatter() != null) { - descriptionAreaText.setText(DESCRIPTION + formatterCleanup.getFormatter().getDescription()); - } else { - Formatter selectedFormatter = formattersCombobox.getValue(); - if (selectedFormatter != null) { - descriptionAreaText.setText(DESCRIPTION + selectedFormatter.getDescription()); - } else { - descriptionAreaText.setText(DESCRIPTION); - } - } - } - - /** - * This panel contains the two comboboxes and the Add button - */ - private GridPane getSelectorPanel() { - GridPane builder = new GridPane(); - builder.setHgap(10.0); - Set fields = FieldFactory.getCommonFields(); - fields.add(InternalField.KEY_FIELD); - Set fieldsString = fields.stream().map(Field::getDisplayName).sorted().collect(Collectors.toCollection(TreeSet::new)); - selectFieldCombobox = new ComboBox<>(FXCollections.observableArrayList(fieldsString)); - selectFieldCombobox.setEditable(true); - builder.add(selectFieldCombobox, 1, 1); - - formattersCombobox = new ComboBox<>(FXCollections.observableArrayList(availableFormatters)); - new ViewModelListCellFactory() - .withText(Formatter::getName) - .withStringTooltip(Formatter::getDescription) - .install(formattersCombobox); - EasyBind.subscribe(formattersCombobox.valueProperty(), e -> updateDescription()); - formattersCombobox.getSelectionModel().selectFirst(); - builder.add(formattersCombobox, 3, 1); - - addButton = new Button(Localization.lang("Add")); - addButton.setOnAction(e -> { - FieldFormatterCleanup newAction = getFieldFormatterCleanup(); - - if (!actions.contains(newAction)) { - actions.add(newAction); - } - }); - builder.add(addButton, 5, 1); - - return builder; - } - - public void storeSettings(MetaData metaData) { - Objects.requireNonNull(metaData); - - FieldFormatterCleanups formatterCleanups = getFormatterCleanups(); - - // if all actions have been removed, remove the save actions from the MetaData - if (formatterCleanups.getConfiguredActions().isEmpty()) { - metaData.clearSaveActions(); - return; - } - - metaData.setSaveActions(formatterCleanups); - } - - public FieldFormatterCleanups getFormatterCleanups() { - return new FieldFormatterCleanups(cleanupEnabled.isSelected(), actions); - } - - public boolean hasChanged() { - return !fieldFormatterCleanups.equals(getFormatterCleanups()); - } - - public boolean isDefaultSaveActions() { - return Cleanups.DEFAULT_SAVE_ACTIONS.equals(getFormatterCleanups()); - } - - private FieldFormatterCleanup getFieldFormatterCleanup() { - Formatter selectedFormatter = formattersCombobox.getValue(); - Field field = FieldFactory.parseField(selectFieldCombobox.getSelectionModel().getSelectedItem()); - return new FieldFormatterCleanup(field, selectedFormatter); - } - - class EnablementStatusListener implements ChangeListener { - - public EnablementStatusListener(boolean initialStatus) { - setStatus(initialStatus); - } - - private void setStatus(boolean status) { - actionsList.setDisable(!status); - selectFieldCombobox.setDisable(!status); - formattersCombobox.setDisable(!status); - addButton.setDisable(!status); - removeSelectedButton.setDisable(!status); - removeAllButton.setDisable(!status); - recommendButton.setDisable(!status); - } - - @Override - public void changed(ObservableValue observable, T oldValue, T newValue) { - setStatus(cleanupEnabled.isSelected()); - } - } -} diff --git a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTable.fxml b/src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanel.fxml similarity index 90% rename from src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTable.fxml rename to src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanel.fxml index 5b2924eb764..0031e6a1fd4 100644 --- a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTable.fxml +++ b/src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanel.fxml @@ -5,7 +5,7 @@ + fx:controller="org.jabref.gui.commonfxcontrols.BibtexKeyPatternPanel"> diff --git a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTableView.java b/src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanel.java similarity index 79% rename from src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTableView.java rename to src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanel.java index 124e8b8c48c..a6f96bb25b5 100644 --- a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTableView.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanel.java @@ -1,4 +1,4 @@ -package org.jabref.gui.bibtexkeypattern; +package org.jabref.gui.commonfxcontrols; import java.util.Collection; @@ -21,21 +21,21 @@ import com.airhacks.afterburner.views.ViewLoader; -public class BibtexKeyPatternTableView extends TableView { +public class BibtexKeyPatternPanel extends TableView { - @FXML public TableColumn entryTypeColumn; - @FXML public TableColumn patternColumn; - @FXML public TableColumn actionsColumn; + @FXML public TableColumn entryTypeColumn; + @FXML public TableColumn patternColumn; + @FXML public TableColumn actionsColumn; - private BibtexKeyPatternTableViewModel viewModel; + private BibtexKeyPatternPanelViewModel viewModel; private long lastKeyPressTime; private String tableSearchTerm; - public BibtexKeyPatternTableView(JabRefPreferences preferences, Collection entryTypeList, AbstractBibtexKeyPattern keyPattern) { + public BibtexKeyPatternPanel(JabRefPreferences preferences, Collection entryTypeList, AbstractBibtexKeyPattern keyPattern) { super(); - viewModel = new BibtexKeyPatternTableViewModel(preferences, entryTypeList, keyPattern); + viewModel = new BibtexKeyPatternPanelViewModel(preferences, entryTypeList, keyPattern); ViewLoader.view(this) .root(this) @@ -49,11 +49,11 @@ private void initialize() { entryTypeColumn.setSortable(true); entryTypeColumn.setReorderable(false); entryTypeColumn.setCellValueFactory(cellData -> cellData.getValue().entryType()); - new ValueTableCellFactory() + new ValueTableCellFactory() .withText(EntryType::getDisplayName) .install(entryTypeColumn); this.setOnSort(event -> - viewModel.patternListProperty().sort(BibtexKeyPatternTableViewModel.defaultOnTopComparator)); + viewModel.patternListProperty().sort(BibtexKeyPatternPanelViewModel.defaultOnTopComparator)); patternColumn.setSortable(true); patternColumn.setReorderable(false); @@ -61,13 +61,13 @@ private void initialize() { patternColumn.setCellFactory(TextFieldTableCell.forTableColumn()); patternColumn.setEditable(true); patternColumn.setOnEditCommit( - (TableColumn.CellEditEvent event) -> + (TableColumn.CellEditEvent event) -> event.getRowValue().setPattern(event.getNewValue())); actionsColumn.setSortable(false); actionsColumn.setReorderable(false); actionsColumn.setCellValueFactory(cellData -> cellData.getValue().entryType()); - new ValueTableCellFactory() + new ValueTableCellFactory() .withGraphic(entryType -> IconTheme.JabRefIcons.REFRESH.getGraphicNode()) .withTooltip(entryType -> String.format(Localization.lang("Reset %s to default value"), entryType.getDisplayName())) @@ -84,9 +84,9 @@ private void initialize() { public void resetAll() { viewModel.resetAll(); } - public ListProperty patternListProperty() { return viewModel.patternListProperty(); } + public ListProperty patternListProperty() { return viewModel.patternListProperty(); } - public ObjectProperty defaultKeyPatternProperty() { return viewModel.defaultKeyPatternProperty(); } + public ObjectProperty defaultKeyPatternProperty() { return viewModel.defaultKeyPatternProperty(); } private void jumpToSearchKey(KeyEvent keypressed) { if (keypressed.getCharacter() == null) { @@ -105,15 +105,15 @@ private void jumpToSearchKey(KeyEvent keypressed) { .findFirst().ifPresent(this::scrollTo); } - private static class HighlightTableRow extends TableRow { + private static class HighlightTableRow extends TableRow { @Override - public void updateItem(BibtexKeyPatternTableItemModel item, boolean empty) { + public void updateItem(BibtexKeyPatternPanelItemModel item, boolean empty) { super.updateItem(item, empty); if (item == null || item.getEntryType() == null) { setStyle(""); } else if (isSelected()) { setStyle("-fx-background-color: -fx-selection-bar"); - } else if (item.getEntryType().getName().equals(BibtexKeyPatternTableViewModel.ENTRY_TYPE_DEFAULT_NAME)) { + } else if (item.getEntryType().getName().equals(BibtexKeyPatternPanelViewModel.ENTRY_TYPE_DEFAULT_NAME)) { setStyle("-fx-background-color: -fx-default-button"); } else { setStyle(""); diff --git a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTableItemModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanelItemModel.java similarity index 88% rename from src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTableItemModel.java rename to src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanelItemModel.java index 7431346de46..f65180bd6a1 100644 --- a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTableItemModel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanelItemModel.java @@ -1,4 +1,4 @@ -package org.jabref.gui.bibtexkeypattern; +package org.jabref.gui.commonfxcontrols; import java.util.Objects; @@ -9,11 +9,11 @@ import org.jabref.model.entry.types.EntryType; -public class BibtexKeyPatternTableItemModel { +public class BibtexKeyPatternPanelItemModel { private final ObjectProperty entryType = new SimpleObjectProperty<>(); private final StringProperty pattern = new SimpleStringProperty(""); - public BibtexKeyPatternTableItemModel(EntryType entryType, String pattern) { + public BibtexKeyPatternPanelItemModel(EntryType entryType, String pattern) { Objects.requireNonNull(entryType); Objects.requireNonNull(pattern); this.entryType.setValue(entryType); diff --git a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTableViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanelViewModel.java similarity index 83% rename from src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTableViewModel.java rename to src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanelViewModel.java index 971347b4b3f..ccd765635bf 100644 --- a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternTableViewModel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/BibtexKeyPatternPanelViewModel.java @@ -1,4 +1,4 @@ -package org.jabref.gui.bibtexkeypattern; +package org.jabref.gui.commonfxcontrols; import java.util.Collection; import java.util.Comparator; @@ -15,11 +15,11 @@ import org.jabref.model.entry.types.EntryType; import org.jabref.preferences.JabRefPreferences; -public class BibtexKeyPatternTableViewModel { +public class BibtexKeyPatternPanelViewModel { public static final String ENTRY_TYPE_DEFAULT_NAME = "default"; - public static Comparator defaultOnTopComparator = (o1, o2) -> { + public static Comparator defaultOnTopComparator = (o1, o2) -> { String itemOneName = o1.getEntryType().getName(); String itemTwoName = o2.getEntryType().getName(); @@ -34,13 +34,13 @@ public class BibtexKeyPatternTableViewModel { return 0; }; - private final ListProperty patternListProperty = new SimpleListProperty<>(); - private final ObjectProperty defaultItemProperty = new SimpleObjectProperty<>(); + private final ListProperty patternListProperty = new SimpleListProperty<>(); + private final ObjectProperty defaultItemProperty = new SimpleObjectProperty<>(); private final AbstractBibtexKeyPattern initialKeyPattern; private final Collection bibEntryTypeList; private final JabRefPreferences preferences; - public BibtexKeyPatternTableViewModel(JabRefPreferences preferences, Collection entryTypeList, AbstractBibtexKeyPattern initialKeyPattern) { + public BibtexKeyPatternPanelViewModel(JabRefPreferences preferences, Collection entryTypeList, AbstractBibtexKeyPattern initialKeyPattern) { this.preferences = preferences; this.bibEntryTypeList = entryTypeList; this.initialKeyPattern = initialKeyPattern; @@ -54,7 +54,7 @@ public void setValues() { defaultPattern = initialKeyPattern.getDefaultValue().get(0); } - defaultItemProperty.setValue(new BibtexKeyPatternTableItemModel(new DefaultEntryType(), defaultPattern)); + defaultItemProperty.setValue(new BibtexKeyPatternPanelItemModel(new DefaultEntryType(), defaultPattern)); patternListProperty.setValue(FXCollections.observableArrayList()); patternListProperty.add(defaultItemProperty.getValue()); @@ -67,11 +67,11 @@ public void setValues() { } else { pattern = initialKeyPattern.getPatterns().get(entryType).get(0); } - patternListProperty.add(new BibtexKeyPatternTableItemModel(entryType, pattern)); + patternListProperty.add(new BibtexKeyPatternPanelItemModel(entryType, pattern)); }); } - public void setItemToDefaultPattern(BibtexKeyPatternTableItemModel item) { + public void setItemToDefaultPattern(BibtexKeyPatternPanelItemModel item) { item.setPattern((String) preferences.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)); } @@ -80,9 +80,9 @@ public void resetAll() { defaultItemProperty.getValue().setPattern((String) preferences.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)); } - public ListProperty patternListProperty() { return patternListProperty; } + public ListProperty patternListProperty() { return patternListProperty; } - public ObjectProperty defaultKeyPatternProperty() { return defaultItemProperty; } + public ObjectProperty defaultKeyPatternProperty() { return defaultItemProperty; } public static class DefaultEntryType implements EntryType { @Override diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.fxml b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.fxml new file mode 100644 index 00000000000..cecf5153b6b --- /dev/null +++ b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.fxml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java new file mode 100644 index 00000000000..5f6e1e064b1 --- /dev/null +++ b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java @@ -0,0 +1,135 @@ +package org.jabref.gui.commonfxcontrols; + +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.ListProperty; +import javafx.beans.property.ReadOnlyObjectWrapper; +import javafx.fxml.FXML; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ComboBox; +import javafx.scene.control.SelectionMode; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.input.KeyCode; +import javafx.scene.layout.VBox; + +import org.jabref.gui.icon.IconTheme; +import org.jabref.gui.util.FieldsUtil; +import org.jabref.gui.util.ValueTableCellFactory; +import org.jabref.gui.util.ViewModelListCellFactory; +import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.FieldFormatterCleanup; +import org.jabref.model.cleanup.Formatter; +import org.jabref.model.entry.field.Field; + +import com.airhacks.afterburner.views.ViewLoader; + +public class FieldFormatterCleanupsPanel extends VBox { + + @FXML private CheckBox cleanupsEnabled; + @FXML private TableView cleanupsList; + @FXML private TableColumn fieldColumn; + @FXML private TableColumn formatterColumn; + @FXML private TableColumn actionsColumn; + @FXML private ComboBox addableFields; + @FXML private ComboBox addableFormatters; + + private FieldFormatterCleanupsPanelViewModel viewModel; + + public FieldFormatterCleanupsPanel() { + ViewLoader.view(this) + .root(this) + .load(); + } + + @FXML + private void initialize() { + this.viewModel = new FieldFormatterCleanupsPanelViewModel(); + + setupTable(); + setupCombos(); + setupBindings(); + } + + private void setupTable() { + cleanupsList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + + // ToDo: To be editable the list needs a view model wrapper for FieldFormatterCleanup + + fieldColumn.setCellValueFactory(cellData -> new ReadOnlyObjectWrapper<>(cellData.getValue().getField())); + new ValueTableCellFactory() + .withText(Field::getDisplayName) + .install(fieldColumn); + + formatterColumn.setCellValueFactory(cellData -> new ReadOnlyObjectWrapper<>(cellData.getValue().getFormatter())); + new ValueTableCellFactory() + .withText(Formatter::getName) + .install(formatterColumn); + + actionsColumn.setCellValueFactory(cellData -> new ReadOnlyObjectWrapper<>(cellData.getValue().getField())); + new ValueTableCellFactory() + .withGraphic(field -> IconTheme.JabRefIcons.DELETE_ENTRY.getGraphicNode()) + .withTooltip(field -> Localization.lang("Remove formatter for %0", field.getDisplayName())) + .withOnMouseClickedEvent(item -> event -> viewModel.removeCleanup(cleanupsList.getSelectionModel().getSelectedItem())) + .install(actionsColumn); + + viewModel.selectedCleanupProperty().setValue(cleanupsList.getSelectionModel()); + + cleanupsList.setOnKeyPressed(event -> { + if (event.getCode() == KeyCode.DELETE) { + viewModel.removeCleanup(cleanupsList.getSelectionModel().getSelectedItem()); + } + }); + } + + private void setupCombos() { + new ViewModelListCellFactory() + .withText(Field::getDisplayName) + .install(addableFields); + addableFields.setConverter(FieldsUtil.fieldStringConverter); + addableFields.setOnKeyPressed(event -> { + if (event.getCode() == KeyCode.TAB || event.getCode() == KeyCode.ENTER) { + addableFormatters.requestFocus(); + event.consume(); + } + }); + + new ViewModelListCellFactory() + .withText(Formatter::getName) + .withStringTooltip(Formatter::getDescription) + .install(addableFormatters); + addableFormatters.setOnKeyPressed(event -> { + if (event.getCode() == KeyCode.ENTER) { + viewModel.addCleanup(); + event.consume(); + } + }); + } + + private void setupBindings() { + cleanupsEnabled.selectedProperty().bindBidirectional(cleanupsDisableProperty()); + cleanupsList.itemsProperty().bind(viewModel.cleanupsListProperty()); + addableFields.itemsProperty().bind(viewModel.availableFieldsProperty()); + addableFields.valueProperty().bindBidirectional(viewModel.selectedFieldProperty()); + addableFormatters.itemsProperty().bind(viewModel.availableFormattersProperty()); + addableFormatters.valueProperty().bindBidirectional(viewModel.selectedFormatterProperty()); + } + + @FXML + private void resetToRecommended() { + viewModel.resetToRecommended(); + } + + @FXML + private void clearAll() { + viewModel.clearAll(); + } + + @FXML + private void addCleanup() { + viewModel.addCleanup(); + } + + public BooleanProperty cleanupsDisableProperty() { return viewModel.cleanupsDisableProperty(); } + + public ListProperty cleanupsProperty() { return viewModel.cleanupsListProperty(); } +} diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java new file mode 100644 index 00000000000..86705892e2e --- /dev/null +++ b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java @@ -0,0 +1,78 @@ +package org.jabref.gui.commonfxcontrols; + +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.collections.FXCollections; +import javafx.scene.control.SelectionModel; + +import org.jabref.Globals; +import org.jabref.gui.util.NoSelectionModel; +import org.jabref.logic.cleanup.Cleanups; +import org.jabref.model.cleanup.FieldFormatterCleanup; +import org.jabref.model.cleanup.Formatter; +import org.jabref.model.entry.field.Field; +import org.jabref.model.entry.field.FieldFactory; + +public class FieldFormatterCleanupsPanelViewModel { + + private final BooleanProperty cleanupsDisableProperty = new SimpleBooleanProperty(); + private final ListProperty cleanupsListProperty = new SimpleListProperty<>(FXCollections.observableArrayList()); + private final ObjectProperty> selectedCleanupProperty = new SimpleObjectProperty<>(new NoSelectionModel<>()); + private final ListProperty availableFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList(FieldFactory.getCommonFields())); + private final ObjectProperty selectedFieldProperty = new SimpleObjectProperty<>(); + private final ListProperty availableFormattersProperty = new SimpleListProperty<>(FXCollections.observableArrayList(Cleanups.getBuiltInFormatters())); + private final ObjectProperty selectedFormatterProperty = new SimpleObjectProperty<>(); + + public FieldFormatterCleanupsPanelViewModel() { + } + + public void resetToRecommended() { + Globals.stateManager.getActiveDatabase().ifPresent(databaseContext -> { + if (databaseContext.isBiblatexMode()) { + cleanupsListProperty.setAll(Cleanups.RECOMMEND_BIBLATEX_ACTIONS.getConfiguredActions()); + } else { + cleanupsListProperty.setAll(Cleanups.RECOMMEND_BIBTEX_ACTIONS.getConfiguredActions()); + } + }); + } + + public void clearAll() { + cleanupsListProperty.clear(); + } + + public void addCleanup() { + if (selectedFieldProperty.getValue() == null || selectedFormatterProperty.getValue() == null) { + return; + } + + FieldFormatterCleanup cleanup = new FieldFormatterCleanup( + selectedFieldProperty.getValue(), + selectedFormatterProperty.getValue()); + + if (cleanupsListProperty.stream().noneMatch(item -> item.equals(cleanup))) { + cleanupsListProperty.add(cleanup); + } + } + + public void removeCleanup(FieldFormatterCleanup cleanup) { + cleanupsListProperty.remove(cleanup); + } + + public BooleanProperty cleanupsDisableProperty() { return cleanupsDisableProperty; } + + public ListProperty cleanupsListProperty() { return cleanupsListProperty; } + + public ObjectProperty> selectedCleanupProperty() { return selectedCleanupProperty; } + + public ListProperty availableFieldsProperty() { return availableFieldsProperty; } + + public ObjectProperty selectedFieldProperty() { return selectedFieldProperty; } + + public ListProperty availableFormattersProperty() { return availableFormattersProperty; } + + public ObjectProperty selectedFormatterProperty() { return selectedFormatterProperty; } +} diff --git a/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.fxml b/src/main/java/org/jabref/gui/commonfxcontrols/SaveOrderConfigPanel.fxml similarity index 97% rename from src/main/java/org/jabref/gui/SaveOrderConfigDisplay.fxml rename to src/main/java/org/jabref/gui/commonfxcontrols/SaveOrderConfigPanel.fxml index 17e458f2e81..e0d26cf19d3 100644 --- a/src/main/java/org/jabref/gui/SaveOrderConfigDisplay.fxml +++ b/src/main/java/org/jabref/gui/commonfxcontrols/SaveOrderConfigPanel.fxml @@ -12,7 +12,7 @@ + fx:controller="org.jabref.gui.commonfxcontrols.SaveOrderConfigPanel"> diff --git a/src/main/java/org/jabref/gui/SaveOrderConfigDisplayView.java b/src/main/java/org/jabref/gui/commonfxcontrols/SaveOrderConfigPanel.java similarity index 55% rename from src/main/java/org/jabref/gui/SaveOrderConfigDisplayView.java rename to src/main/java/org/jabref/gui/commonfxcontrols/SaveOrderConfigPanel.java index 15679bc9ac2..b3ae2db5549 100644 --- a/src/main/java/org/jabref/gui/SaveOrderConfigDisplayView.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/SaveOrderConfigPanel.java @@ -1,26 +1,23 @@ -package org.jabref.gui; - -import javax.inject.Inject; +package org.jabref.gui.commonfxcontrols; +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.ListProperty; +import javafx.beans.property.ObjectProperty; 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.VBox; import org.jabref.gui.util.FieldsUtil; import org.jabref.gui.util.ViewModelListCellFactory; import org.jabref.logic.l10n.Localization; import org.jabref.model.entry.field.Field; -import org.jabref.model.metadata.SaveOrderConfig; -import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; -public class SaveOrderConfigDisplayView extends VBox { +public class SaveOrderConfigPanel extends VBox { - @FXML private ToggleGroup saveOrderToggleGroup; @FXML private RadioButton exportInSpecifiedOrder; @FXML private RadioButton exportInTableOrder; @FXML private RadioButton exportInOriginalOrder; @@ -30,11 +27,10 @@ public class SaveOrderConfigDisplayView extends VBox { @FXML private CheckBox savePriDesc; @FXML private CheckBox saveSecDesc; @FXML private CheckBox saveTerDesc; - @Inject private PreferencesService preferencesService; - private SaveOrderConfigDisplayViewModel viewModel; + private SaveOrderConfigPanelViewModel viewModel; - public SaveOrderConfigDisplayView() { + public SaveOrderConfigPanel() { ViewLoader.view(this) .root(this) .load(); @@ -42,8 +38,7 @@ public SaveOrderConfigDisplayView() { @FXML private void initialize() { - - viewModel = new SaveOrderConfigDisplayViewModel(preferencesService); + viewModel = new SaveOrderConfigPanelViewModel(); exportInOriginalOrder.selectedProperty().bindBidirectional(viewModel.saveInOriginalProperty()); exportInTableOrder.selectedProperty().bindBidirectional(viewModel.saveInTableOrderProperty()); @@ -52,32 +47,27 @@ private void initialize() { new ViewModelListCellFactory() .withText(FieldsUtil::getNameWithType) .install(savePriSort); - savePriSort.itemsProperty().bindBidirectional(viewModel.priSortFieldsProperty()); - savePriSort.valueProperty().bindBidirectional(viewModel.savePriSortSelectedValueProperty()); + savePriSort.itemsProperty().bindBidirectional(viewModel.primarySortFieldsProperty()); + savePriSort.valueProperty().bindBidirectional(viewModel.savePrimarySortSelectedValueProperty()); savePriSort.setConverter(FieldsUtil.fieldStringConverter); new ViewModelListCellFactory() .withText(FieldsUtil::getNameWithType) .install(saveSecSort); - saveSecSort.itemsProperty().bindBidirectional(viewModel.secSortFieldsProperty()); - saveSecSort.valueProperty().bindBidirectional(viewModel.saveSecSortSelectedValueProperty()); + saveSecSort.itemsProperty().bindBidirectional(viewModel.secondarySortFieldsProperty()); + saveSecSort.valueProperty().bindBidirectional(viewModel.saveSecondarySortSelectedValueProperty()); saveSecSort.setConverter(FieldsUtil.fieldStringConverter); new ViewModelListCellFactory() .withText(FieldsUtil::getNameWithType) .install(saveTerSort); - saveTerSort.itemsProperty().bindBidirectional(viewModel.terSortFieldsProperty()); - saveTerSort.valueProperty().bindBidirectional(viewModel.saveTerSortSelectedValueProperty()); + saveTerSort.itemsProperty().bindBidirectional(viewModel.tertiarySortFieldsProperty()); + saveTerSort.valueProperty().bindBidirectional(viewModel.saveTertiarySortSelectedValueProperty()); saveTerSort.setConverter(FieldsUtil.fieldStringConverter); - savePriDesc.selectedProperty().bindBidirectional(viewModel.savePriDescPropertySelected()); - saveSecDesc.selectedProperty().bindBidirectional(viewModel.saveSecDescPropertySelected()); - saveTerDesc.selectedProperty().bindBidirectional(viewModel.saveTerDescPropertySelected()); - - } - - public void setValues(SaveOrderConfig config) { - viewModel.setSaveOrderConfig(config); + savePriDesc.selectedProperty().bindBidirectional(viewModel.savePrimaryDescPropertySelected()); + saveSecDesc.selectedProperty().bindBidirectional(viewModel.saveSecondaryDescPropertySelected()); + saveTerDesc.selectedProperty().bindBidirectional(viewModel.saveTertiaryDescPropertySelected()); } public void changeExportDescriptionToSave() { @@ -86,12 +76,51 @@ public void changeExportDescriptionToSave() { exportInTableOrder.setText(Localization.lang("Save in current table sort order")); } - public void storeConfig() { - viewModel.storeConfigInPrefs(); + public BooleanProperty saveInOriginalProperty() { + return viewModel.saveInOriginalProperty(); + } + + public BooleanProperty saveInTableOrderProperty() { + return viewModel.saveInTableOrderProperty(); + } + + public BooleanProperty saveInSpecifiedOrderProperty() { + return viewModel.saveInSpecifiedOrderProperty(); + } + + public ListProperty primarySortFieldsProperty() { + return viewModel.primarySortFieldsProperty(); + } + + public ListProperty secondarySortFieldsProperty() { + return viewModel.secondarySortFieldsProperty(); + } + + public ListProperty tertiarySortFieldsProperty() { + return viewModel.tertiarySortFieldsProperty(); + } + + public ObjectProperty savePrimarySortSelectedValueProperty() { + return viewModel.savePrimarySortSelectedValueProperty(); + } + + public ObjectProperty saveSecondarySortSelectedValueProperty() { + return viewModel.saveSecondarySortSelectedValueProperty(); + } + + public ObjectProperty saveTertiarySortSelectedValueProperty() { + return viewModel.saveTertiarySortSelectedValueProperty(); } - public SaveOrderConfig getSaveOrderConfig() { - return viewModel.getSaveOrderConfig(); + public BooleanProperty savePrimaryDescPropertySelected() { + return viewModel.savePrimaryDescPropertySelected(); } + public BooleanProperty saveSecondaryDescPropertySelected() { + return viewModel.saveSecondaryDescPropertySelected(); + } + + public BooleanProperty saveTertiaryDescPropertySelected() { + return viewModel.saveTertiaryDescPropertySelected(); + } } diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/SaveOrderConfigPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/SaveOrderConfigPanelViewModel.java new file mode 100644 index 00000000000..0fb898392b1 --- /dev/null +++ b/src/main/java/org/jabref/gui/commonfxcontrols/SaveOrderConfigPanelViewModel.java @@ -0,0 +1,81 @@ +package org.jabref.gui.commonfxcontrols; + +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.collections.FXCollections; + +import org.jabref.model.entry.field.Field; + +public class SaveOrderConfigPanelViewModel { + + private final ListProperty primarySortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList()); + private final ListProperty secondarySortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList()); + private final ListProperty tertiarySortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList()); + + private final BooleanProperty savePrimaryDescPropertySelected = new SimpleBooleanProperty(); + private final BooleanProperty saveSecondaryDescPropertySelected = new SimpleBooleanProperty(); + private final BooleanProperty saveTertiaryDescPropertySelected = new SimpleBooleanProperty(); + + private final ObjectProperty savePrimarySortSelectedValueProperty = new SimpleObjectProperty<>(null); + private final ObjectProperty saveSecondarySortSelectedValueProperty = new SimpleObjectProperty<>(null); + private final ObjectProperty saveTertiarySortSelectedValueProperty = new SimpleObjectProperty<>(null); + + private final BooleanProperty saveInOriginalProperty = new SimpleBooleanProperty(); + private final BooleanProperty saveInTableOrderProperty = new SimpleBooleanProperty(); + private final BooleanProperty saveInSpecifiedOrderProperty = new SimpleBooleanProperty(); + + public SaveOrderConfigPanelViewModel() { + } + + public BooleanProperty saveInOriginalProperty() { + return saveInOriginalProperty; + } + + public BooleanProperty saveInTableOrderProperty() { + return saveInTableOrderProperty; + } + + public BooleanProperty saveInSpecifiedOrderProperty() { + return saveInSpecifiedOrderProperty; + } + + public ListProperty primarySortFieldsProperty() { + return primarySortFieldsProperty; + } + + public ListProperty secondarySortFieldsProperty() { + return secondarySortFieldsProperty; + } + + public ListProperty tertiarySortFieldsProperty() { + return tertiarySortFieldsProperty; + } + + public ObjectProperty savePrimarySortSelectedValueProperty() { + return savePrimarySortSelectedValueProperty; + } + + public ObjectProperty saveSecondarySortSelectedValueProperty() { + return saveSecondarySortSelectedValueProperty; + } + + public ObjectProperty saveTertiarySortSelectedValueProperty() { + return saveTertiarySortSelectedValueProperty; + } + + public BooleanProperty savePrimaryDescPropertySelected() { + return savePrimaryDescPropertySelected; + } + + public BooleanProperty saveSecondaryDescPropertySelected() { + return saveSecondaryDescPropertySelected; + } + + public BooleanProperty saveTertiaryDescPropertySelected() { + return saveTertiaryDescPropertySelected; + } +} diff --git a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesAction.java b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesAction.java index 6c513dbc9ce..e5a1960cd9f 100644 --- a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesAction.java +++ b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesAction.java @@ -1,6 +1,5 @@ package org.jabref.gui.libraryproperties; -import org.jabref.gui.DialogService; import org.jabref.gui.JabRefFrame; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; @@ -10,20 +9,15 @@ public class LibraryPropertiesAction extends SimpleCommand { private final JabRefFrame frame; - private final DialogService dialogService; - public LibraryPropertiesAction(JabRefFrame frame, DialogService dialogService, StateManager stateManager) { + public LibraryPropertiesAction(JabRefFrame frame, StateManager stateManager) { this.frame = frame; - this.dialogService = dialogService; - this.executable.bind(needsDatabase(stateManager)); } @Override public void execute() { - LibraryPropertiesDialogView propertiesDialog = new LibraryPropertiesDialogView(frame.getCurrentBasePanel(), dialogService); + LibraryPropertiesDialogView propertiesDialog = new LibraryPropertiesDialogView(frame.getCurrentBasePanel()); propertiesDialog.showAndWait(); - } - } diff --git a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialog.fxml b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialog.fxml index 50faf887c78..e95edf125bb 100644 --- a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialog.fxml +++ b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialog.fxml @@ -2,7 +2,7 @@ - + @@ -16,65 +16,79 @@ + + + + - + - - - + + + - - - - - - - + + + + + + + -