From c3c565414da7a8576f917fa2ed9ad5109f9111a4 Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 01:23:52 +0530 Subject: [PATCH 01/11] Fix #13402: Make sidebar width proportional to window size and persist across sessions --- .../org/jabref/gui/frame/JabRefFrame.java | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 4280e9b5ff4..eca8368d95c 100644 --- a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -213,6 +213,7 @@ public JabRefFrame(Stage mainStage, initKeyBindings(); frameDndHandler.initDragAndDrop(); initBindings(); + initSidebarResizeListener(); } private void initLayout() { @@ -295,13 +296,32 @@ private void updateEditorPane() { } public void updateHorizontalDividerPosition() { - if (mainStage.isShowing() && !sidePane.getChildren().isEmpty()) { - horizontalSplit.setDividerPositions(preferences.getGuiPreferences().getHorizontalDividerPosition() / horizontalSplit.getWidth()); - horizontalDividerSubscription = EasyBind.valueAt(horizontalSplit.getDividers(), 0) - .mapObservable(SplitPane.Divider::positionProperty) - .listenToValues((_, newValue) -> preferences.getGuiPreferences().setHorizontalDividerPosition(newValue.doubleValue())); + if (mainStage.isShowing() && !sidePane.getChildren().isEmpty()) { + double savedProportion = preferences.getGuiPreferences().getHorizontalDividerPosition(); + + // Fix: fallback to 0.2 if saved value is invalid + if (savedProportion <= 0.0 || savedProportion >= 1.0 || Double.isNaN(savedProportion)) { + savedProportion = 0.2; + } + + horizontalSplit.setDividerPositions(savedProportion); + + // Subscribe to save user-adjusted sidebar position + if (horizontalDividerSubscription != null) { + horizontalDividerSubscription.unsubscribe(); } + + horizontalDividerSubscription = EasyBind.valueAt(horizontalSplit.getDividers(), 0) + .mapObservable(SplitPane.Divider::positionProperty) + .listenToValues((_, newValue) -> { + double newPos = newValue.doubleValue(); + if (newPos > 0.0 && newPos < 1.0) { + preferences.getGuiPreferences().setHorizontalDividerPosition(newPos); + } + }); } +} + public void updateVerticalDividerPosition() { if (mainStage.isShowing() && panelMode.get() == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) { @@ -447,6 +467,15 @@ private void initBindings() { EasyBind.subscribe(preferences.getWorkspacePreferences().hideTabBarProperty(), _ -> updateTabBarVisible()); } + private void initSidebarResizeListener() { + mainStage.widthProperty().addListener((obs, oldVal, newVal) -> { + if (!sidePane.getChildren().isEmpty()) { + updateHorizontalDividerPosition(); + } + }); +} + + private void updateTabBarVisible() { if (preferences.getWorkspacePreferences().shouldHideTabBar() && stateManager.getOpenDatabases().size() <= 1) { if (!tabbedPane.getStyleClass().contains("hide-tab-bar")) { From 7de6fd646f87694711c5c17e8e24681b930ee214 Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 01:54:20 +0530 Subject: [PATCH 02/11] Update CHANGELOG.md to describe sidebar fix --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52485dda5ce..f617c1fa149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# Changelog + # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -9,6 +9,10 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv ## [Unreleased] +### Fixed +- Sidebar width now persists across sessions and resizes proportionally to window width [#13402](https://github.com/JabRef/jabref/issues/13402) + + ### Added - We introduced a settings parameter to manage citations' relations local storage time-to-live with a default value set to 30 days. [#11189](https://github.com/JabRef/jabref/issues/11189) From 4054604db79ed0914c6b863446b9325ab1f676ec Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 02:04:23 +0530 Subject: [PATCH 03/11] Update CHANGELOG.md to describe sidebar fix --- CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f617c1fa149..b7be80bc2e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ - # Changelog +# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -8,11 +8,8 @@ In case, there is no issue present, the pull request implementing the feature is Note that this project **does not** adhere to [Semantic Versioning](https://semver.org/). ## [Unreleased] - -### Fixed - Sidebar width now persists across sessions and resizes proportionally to window width [#13402](https://github.com/JabRef/jabref/issues/13402) - ### Added - We introduced a settings parameter to manage citations' relations local storage time-to-live with a default value set to 30 days. [#11189](https://github.com/JabRef/jabref/issues/11189) From e93f07859192394de2f81e861a0c9e099a401652 Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 02:07:26 +0530 Subject: [PATCH 04/11] Update CHANGELOG.md to describe sidebar fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7be80bc2e0..daab1540847 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ In case, there is no issue present, the pull request implementing the feature is Note that this project **does not** adhere to [Semantic Versioning](https://semver.org/). ## [Unreleased] + - Sidebar width now persists across sessions and resizes proportionally to window width [#13402](https://github.com/JabRef/jabref/issues/13402) ### Added From 5d621bb127881e5c40f1ee58518f16f47d7ddb6b Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 02:14:29 +0530 Subject: [PATCH 05/11] Removed extra blank lines between the methods --- .../java/org/jabref/gui/frame/JabRefFrame.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java index eca8368d95c..d4ede534799 100644 --- a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -319,9 +319,8 @@ public void updateHorizontalDividerPosition() { preferences.getGuiPreferences().setHorizontalDividerPosition(newPos); } }); - } -} - + } + } public void updateVerticalDividerPosition() { if (mainStage.isShowing() && panelMode.get() == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) { @@ -468,13 +467,12 @@ private void initBindings() { } private void initSidebarResizeListener() { - mainStage.widthProperty().addListener((obs, oldVal, newVal) -> { - if (!sidePane.getChildren().isEmpty()) { - updateHorizontalDividerPosition(); - } - }); -} - + mainStage.widthProperty().addListener((obs, oldVal, newVal) -> { + if (!sidePane.getChildren().isEmpty()) { + updateHorizontalDividerPosition(); + } + }); + } private void updateTabBarVisible() { if (preferences.getWorkspacePreferences().shouldHideTabBar() && stateManager.getOpenDatabases().size() <= 1) { From a136181f165f39064f90563dbb8e865d11cf8d9a Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 02:30:29 +0530 Subject: [PATCH 06/11] Removed unnecessary comments from the code --- jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java index d4ede534799..e1103c0d5f1 100644 --- a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -299,14 +299,12 @@ public void updateHorizontalDividerPosition() { if (mainStage.isShowing() && !sidePane.getChildren().isEmpty()) { double savedProportion = preferences.getGuiPreferences().getHorizontalDividerPosition(); - // Fix: fallback to 0.2 if saved value is invalid if (savedProportion <= 0.0 || savedProportion >= 1.0 || Double.isNaN(savedProportion)) { savedProportion = 0.2; } horizontalSplit.setDividerPositions(savedProportion); - // Subscribe to save user-adjusted sidebar position if (horizontalDividerSubscription != null) { horizontalDividerSubscription.unsubscribe(); } From 50bb101832031342477b9c243ecfdf6277c1b333 Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 02:36:53 +0530 Subject: [PATCH 07/11] Extract default sidebar divider position into constant --- .../java/org/jabref/gui/frame/JabRefFrame.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java index e1103c0d5f1..c0e41d0faf3 100644 --- a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -112,6 +112,8 @@ private enum PanelMode { MAIN_TABLE, MAIN_TABLE_AND_ENTRY_EDITOR } private final EntryEditor entryEditor; private final ObjectProperty panelMode = new SimpleObjectProperty<>(PanelMode.MAIN_TABLE); + private static final double DEFAULT_SIDEBAR_DIVIDER_POSITION = 0.2; + // We need to keep a reference to the subscription, otherwise the binding gets garbage collected private Subscription horizontalDividerSubscription; private Subscription verticalDividerSubscription; @@ -296,14 +298,12 @@ private void updateEditorPane() { } public void updateHorizontalDividerPosition() { - if (mainStage.isShowing() && !sidePane.getChildren().isEmpty()) { - double savedProportion = preferences.getGuiPreferences().getHorizontalDividerPosition(); - - if (savedProportion <= 0.0 || savedProportion >= 1.0 || Double.isNaN(savedProportion)) { - savedProportion = 0.2; + if (mainStage.isShowing() && !sidePane.getChildren().isEmpty()) { + double savedProportion = preferences.getGuiPreferences().getHorizontalDividerPosition(); + if (Double.isNaN(savedProportion) || savedProportion <= 0 || savedProportion >= 1) { + savedProportion = DEFAULT_SIDEBAR_DIVIDER_POSITION; } - - horizontalSplit.setDividerPositions(savedProportion); + horizontalSplit.setDividerPositions(savedProportion); if (horizontalDividerSubscription != null) { horizontalDividerSubscription.unsubscribe(); From df94a74ea53b78da3d02da0d19d89229c250b580 Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 02:44:20 +0530 Subject: [PATCH 08/11] Moved the constant to the start of the file! --- jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java index c0e41d0faf3..7564e9e32ec 100644 --- a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -83,6 +83,7 @@ public class JabRefFrame extends BorderPane implements LibraryTabContainer, UiMe private enum PanelMode { MAIN_TABLE, MAIN_TABLE_AND_ENTRY_EDITOR } public static final String FRAME_TITLE = "JabRef"; + private static final double DEFAULT_SIDEBAR_DIVIDER_POSITION = 0.2; private static final Logger LOGGER = LoggerFactory.getLogger(JabRefFrame.class); @@ -112,8 +113,6 @@ private enum PanelMode { MAIN_TABLE, MAIN_TABLE_AND_ENTRY_EDITOR } private final EntryEditor entryEditor; private final ObjectProperty panelMode = new SimpleObjectProperty<>(PanelMode.MAIN_TABLE); - private static final double DEFAULT_SIDEBAR_DIVIDER_POSITION = 0.2; - // We need to keep a reference to the subscription, otherwise the binding gets garbage collected private Subscription horizontalDividerSubscription; private Subscription verticalDividerSubscription; From 8bfd8adccec0cc64d1d0f3c41d10a8f38cf2fd2d Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 02:47:20 +0530 Subject: [PATCH 09/11] Moved the constant to the right position! --- jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 7564e9e32ec..7e10ecdbcc0 100644 --- a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -83,9 +83,9 @@ public class JabRefFrame extends BorderPane implements LibraryTabContainer, UiMe private enum PanelMode { MAIN_TABLE, MAIN_TABLE_AND_ENTRY_EDITOR } public static final String FRAME_TITLE = "JabRef"; - private static final double DEFAULT_SIDEBAR_DIVIDER_POSITION = 0.2; - + private static final Logger LOGGER = LoggerFactory.getLogger(JabRefFrame.class); + private static final double DEFAULT_SIDEBAR_DIVIDER_POSITION = 0.2; private final GuiPreferences preferences; private final AiService aiService; From 0f501ad28978a408c8191eb8f72caf4fef8b92aa Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 03:03:48 +0530 Subject: [PATCH 10/11] Add sidebar persistence change to 'Changed' section of changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index daab1540847..8d46df128a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,6 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv ## [Unreleased] -- Sidebar width now persists across sessions and resizes proportionally to window width [#13402](https://github.com/JabRef/jabref/issues/13402) - ### Added - We introduced a settings parameter to manage citations' relations local storage time-to-live with a default value set to 30 days. [#11189](https://github.com/JabRef/jabref/issues/11189) @@ -42,6 +40,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We added a highlighted diff regarding changes to the Group Tree Structure of a bib file, made outside JabRef. [#11221](https://github.com/JabRef/jabref/issues/11221) - We added a new setting in the 'Entry Editor' preferences to hide the 'File Annotations' tab when no annotations are available. [#13143](https://github.com/JabRef/jabref/issues/13143) - We added support for multi-file import across different formats. [#13269](https://github.com/JabRef/jabref/issues/13269) +- We made the sidebar (SidePane) width persist across sessions and resize proportionally to the window width. [#13402](https://github.com/JabRef/jabref/issues/13402) + ### Changed From a14e9d7956313e13a064742d4d151efd288f4e65 Mon Sep 17 00:00:00 2001 From: Sahil Bijlani Date: Sun, 29 Jun 2025 03:13:40 +0530 Subject: [PATCH 11/11] removed extra blank lines --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d46df128a4..daff870eb51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,7 +42,6 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We added support for multi-file import across different formats. [#13269](https://github.com/JabRef/jabref/issues/13269) - We made the sidebar (SidePane) width persist across sessions and resize proportionally to the window width. [#13402](https://github.com/JabRef/jabref/issues/13402) - ### Changed - We moved some functionality from the graphical application `jabref` with new command verbs `generate-citation-keys`, `check-consistency`, `fetch`, `search`, `convert`, `generate-bib-from-aux`, `preferences` and `pdf` to the new toolkit. [#13012](https://github.com/JabRef/jabref/pull/13012) [#110](https://github.com/JabRef/jabref/issues/110)