diff --git a/src/main/java/org/jabref/gui/preferences/preview/PreviewTab.fxml b/src/main/java/org/jabref/gui/preferences/preview/PreviewTab.fxml
index 0b31d99de58..2e7c2b27126 100644
--- a/src/main/java/org/jabref/gui/preferences/preview/PreviewTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/preview/PreviewTab.fxml
@@ -22,6 +22,7 @@
+
diff --git a/src/main/java/org/jabref/gui/preferences/preview/PreviewTab.java b/src/main/java/org/jabref/gui/preferences/preview/PreviewTab.java
index 933edb523e0..5a0c87926f7 100644
--- a/src/main/java/org/jabref/gui/preferences/preview/PreviewTab.java
+++ b/src/main/java/org/jabref/gui/preferences/preview/PreviewTab.java
@@ -1,10 +1,13 @@
package org.jabref.gui.preferences.preview;
+import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import javafx.application.Platform;
import javafx.beans.property.ListProperty;
+import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
@@ -18,6 +21,7 @@
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
+import javafx.stage.FileChooser;
import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
@@ -32,6 +36,7 @@
import org.jabref.gui.util.BindingsHelper;
import org.jabref.gui.util.IconValidationDecorator;
import org.jabref.gui.util.ViewModelListCellFactory;
+import org.jabref.logic.bst.BstPreviewLayout;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.preview.PreviewLayout;
import org.jabref.logic.util.TestEntry;
@@ -104,6 +109,21 @@ public String getTabName() {
return Localization.lang("Entry preview");
}
+ @FXML
+ private void selectBstFile(ActionEvent event) {
+ FileChooser fileChooser = new FileChooser();
+ fileChooser.setTitle("Select BST File");
+ fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("BST Files", "*.bst"));
+
+ File selectedFile = fileChooser.showOpenDialog(null);
+ if (selectedFile != null) {
+ String filePath = selectedFile.getAbsolutePath();
+ BstPreviewLayout bstPreviewLayout = new BstPreviewLayout(Path.of(filePath));
+ viewModel.availableListProperty().add(bstPreviewLayout);
+ previewViewer.setEntry(TestEntry.getTestEntry());
+ }
+}
+
public void initialize() {
this.viewModel = new PreviewTabViewModel(dialogService, preferencesService.getPreviewPreferences(), taskExecutor, stateManager);
lastKeyPressTime = System.currentTimeMillis();
diff --git a/src/main/java/org/jabref/gui/preferences/preview/PreviewTabViewModel.java b/src/main/java/org/jabref/gui/preferences/preview/PreviewTabViewModel.java
index d315d65997d..e36ad24b39d 100644
--- a/src/main/java/org/jabref/gui/preferences/preview/PreviewTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/preview/PreviewTabViewModel.java
@@ -157,8 +157,10 @@ public void setPreviewLayout(PreviewLayout selectedLayout) {
sourceTextProperty.setValue(layout.getText().replace("__NEWLINE__", "\n"));
selectedIsEditableProperty.setValue(true);
} else {
- sourceTextProperty.setValue(((CitationStylePreviewLayout) selectedLayout).getSource());
- selectedIsEditableProperty.setValue(false);
+ if (selectedLayout instanceof CitationStylePreviewLayout) {
+ sourceTextProperty.setValue(((CitationStylePreviewLayout) selectedLayout).getSource());
+ selectedIsEditableProperty.setValue(false);
+ }
}
}