Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to the changed section


### 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)
Expand Down
36 changes: 30 additions & 6 deletions jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +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";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why more spaces?

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;
Expand Down Expand Up @@ -213,6 +214,7 @@ public JabRefFrame(Stage mainStage,
initKeyBindings();
frameDndHandler.initDragAndDrop();
initBindings();
initSidebarResizeListener();
}

private void initLayout() {
Expand Down Expand Up @@ -296,12 +298,26 @@ 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()));
double savedProportion = preferences.getGuiPreferences().getHorizontalDividerPosition();
if (Double.isNaN(savedProportion) || savedProportion <= 0 || savedProportion >= 1) {
savedProportion = DEFAULT_SIDEBAR_DIVIDER_POSITION;
}
horizontalSplit.setDividerPositions(savedProportion);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent is off


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);
}
});
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

strange indent


public void updateVerticalDividerPosition() {
if (mainStage.isShowing() && panelMode.get() == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) {
Expand Down Expand Up @@ -447,6 +463,14 @@ private void initBindings() {
EasyBind.subscribe(preferences.getWorkspacePreferences().hideTabBarProperty(), _ -> updateTabBarVisible());
}

private void initSidebarResizeListener() {
mainStage.widthProperty().addListener((obs, oldVal, newVal) -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no _ used here?

if (!sidePane.getChildren().isEmpty()) {
updateHorizontalDividerPosition();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, inside, always a new listener is created. This will let the memory grow and grow and grow and grow and grow.

}
});
}

private void updateTabBarVisible() {
if (preferences.getWorkspacePreferences().shouldHideTabBar() && stateManager.getOpenDatabases().size() <= 1) {
if (!tabbedPane.getStyleClass().contains("hide-tab-bar")) {
Expand Down