diff --git a/CHANGELOG.md b/CHANGELOG.md index 410b5341a73..b972f15d2cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where drag and dropping entries created a shallow copy. [#11160](https://github.com/JabRef/jabref/issues/11160) - We fixed an issue where imports to a custom group would only work for the first entry [#11085](https://github.com/JabRef/jabref/issues/11085), [#11269](https://github.com/JabRef/jabref/issues/11269) - We fixed an issue where a new entry was not added to the selected group [#8933](https://github.com/JabRef/jabref/issues/8933) +- We fixed an issue where the horizontal position of the Entry Preview inside the entry editor was not remembered across restarts [#11281](https://github.com/JabRef/jabref/issues/11281) ### Removed diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditorPreferences.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditorPreferences.java index ae0fda0194c..fcca2b100ad 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditorPreferences.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditorPreferences.java @@ -49,6 +49,7 @@ public static JournalPopupEnabled fromString(String status) { private final ObjectProperty enablementStatus; private final BooleanProperty shouldShowSciteTab; private final BooleanProperty showUserCommentsFields; + private final DoubleProperty previewWidthDividerPosition; public EntryEditorPreferences(Map> entryEditorTabList, Map> defaultEntryEditorTabList, @@ -62,7 +63,8 @@ public EntryEditorPreferences(Map> entryEditorTabList, boolean autolinkFilesEnabled, JournalPopupEnabled journalPopupEnabled, boolean showSciteTab, - boolean showUserCommentsFields) { + boolean showUserCommentsFields, + double previewWidthDividerPosition) { this.entryEditorTabList = new SimpleMapProperty<>(FXCollections.observableMap(entryEditorTabList)); this.defaultEntryEditorTabList = new SimpleMapProperty<>(FXCollections.observableMap(defaultEntryEditorTabList)); @@ -77,6 +79,7 @@ public EntryEditorPreferences(Map> entryEditorTabList, this.enablementStatus = new SimpleObjectProperty<>(journalPopupEnabled); this.shouldShowSciteTab = new SimpleBooleanProperty(showSciteTab); this.showUserCommentsFields = new SimpleBooleanProperty(showUserCommentsFields); + this.previewWidthDividerPosition = new SimpleDoubleProperty(previewWidthDividerPosition); } public ObservableMap> getEntryEditorTabs() { @@ -226,4 +229,19 @@ public BooleanProperty showUserCommentsFieldsProperty() { public void setShowUserCommentsFields(boolean showUserCommentsFields) { this.showUserCommentsFields.set(showUserCommentsFields); } + + public void setPreviewWidthDividerPosition(double previewWidthDividerPosition) { + this.previewWidthDividerPosition.set(previewWidthDividerPosition); + } + + /** + * Holds the horizontal divider position when the Preview is shown in the entry editor + */ + public DoubleProperty previewWidthDividerPositionProperty() { + return previewWidthDividerPosition; + } + + public Double getPreviewWidthDividerPosition() { + return previewWidthDividerPosition.get(); + } } diff --git a/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java b/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java index 20e54396bfe..97348f5838a 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java @@ -41,6 +41,7 @@ import org.jabref.preferences.PreferencesService; import com.tobiasdiez.easybind.EasyBind; +import com.tobiasdiez.easybind.Subscription; /** * A single tab displayed in the EntryEditor holding several FieldEditors. @@ -61,6 +62,7 @@ abstract class FieldsEditorTab extends EntryEditorTab { private PreviewPanel previewPanel; private final UndoManager undoManager; private Collection fields = new ArrayList<>(); + private Subscription dividerPositionSubscription; public FieldsEditorTab(boolean compressed, BibDatabaseContext databaseContext, @@ -258,9 +260,22 @@ private void initPanel() { container.getItems().remove(previewPanel); } else { container.getItems().add(1, previewPanel); + container.setDividerPositions(preferences.getEntryEditorPreferences().getPreviewWidthDividerPosition()); } }); + + // save position + dividerPositionSubscription = EasyBind.valueAt(container.getDividers(), 0) + .mapObservable(SplitPane.Divider::positionProperty) + .subscribeToValues(this::savePreviewWidthDividerPosition); setContent(container); } } + + private void savePreviewWidthDividerPosition(Number position) { + if (!preferences.getPreviewPreferences().shouldShowPreviewAsExtraTab()) { + preferences.getEntryEditorPreferences().setPreviewWidthDividerPosition(position.doubleValue()); + } + } } + diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index d9c747b3a1e..59b01569a34 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -173,6 +173,10 @@ public class JabRefPreferences implements PreferencesService { public static final String BIBLATEX_DEFAULT_MODE = "biblatexMode"; public static final String NAMES_AS_IS = "namesAsIs"; public static final String ENTRY_EDITOR_HEIGHT = "entryEditorHeightFX"; + /** + * Holds the horizontal divider position of the preview view when it is shown inside the entry editor + */ + public static final String ENTRY_EDITOR_PREVIEW_DIVIDER_POS = "entryEditorPreviewDividerPos"; public static final String AUTO_RESIZE_MODE = "autoResizeMode"; public static final String WINDOW_MAXIMISED = "windowMaximised"; public static final String WINDOW_FULLSCREEN = "windowFullscreen"; @@ -602,6 +606,7 @@ private JabRefPreferences() { defaults.put(WINDOW_FULLSCREEN, Boolean.FALSE); defaults.put(AUTO_RESIZE_MODE, Boolean.FALSE); // By default disable "Fit table horizontally on the screen" defaults.put(ENTRY_EDITOR_HEIGHT, 0.65); + defaults.put(ENTRY_EDITOR_PREVIEW_DIVIDER_POS, 0.5); defaults.put(NAMES_AS_IS, Boolean.FALSE); // "Show names unchanged" defaults.put(NAMES_FIRST_LAST, Boolean.FALSE); // "Show 'Firstname Lastname'" defaults.put(NAMES_NATBIB, Boolean.TRUE); // "Natbib style" @@ -1488,7 +1493,8 @@ public EntryEditorPreferences getEntryEditorPreferences() { getBoolean(AUTOLINK_FILES_ENABLED), EntryEditorPreferences.JournalPopupEnabled.fromString(get(JOURNAL_POPUP)), getBoolean(SHOW_SCITE_TAB), - getBoolean(SHOW_USER_COMMENTS_FIELDS)); + getBoolean(SHOW_USER_COMMENTS_FIELDS), + getDouble(ENTRY_EDITOR_PREVIEW_DIVIDER_POS)); EasyBind.listen(entryEditorPreferences.entryEditorTabs(), (obs, oldValue, newValue) -> storeEntryEditorTabs(newValue)); // defaultEntryEditorTabs are read-only @@ -1503,7 +1509,7 @@ public EntryEditorPreferences getEntryEditorPreferences() { EasyBind.listen(entryEditorPreferences.enableJournalPopupProperty(), (obs, oldValue, newValue) -> put(JOURNAL_POPUP, newValue.toString())); EasyBind.listen(entryEditorPreferences.shouldShowLSciteTabProperty(), (obs, oldValue, newValue) -> putBoolean(SHOW_SCITE_TAB, newValue)); EasyBind.listen(entryEditorPreferences.showUserCommentsFieldsProperty(), (obs, oldValue, newValue) -> putBoolean(SHOW_USER_COMMENTS_FIELDS, newValue)); - + EasyBind.listen(entryEditorPreferences.previewWidthDividerPositionProperty(), (obs, oldValue, newValue) -> putDouble(ENTRY_EDITOR_PREVIEW_DIVIDER_POS, newValue.doubleValue())); return entryEditorPreferences; }