From 69dff919b16a7bb9993488fa53453a3ab16c485c Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Sat, 13 Sep 2025 17:12:48 +0200 Subject: [PATCH 1/7] Prevent brief flash of the default JavaFX (Modena) theme on startup --- .../main/java/org/jabref/gui/JabRefGUI.java | 2 +- .../org/jabref/gui/theme/ThemeManager.java | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/JabRefGUI.java b/jabgui/src/main/java/org/jabref/gui/JabRefGUI.java index bbfa03714f0..265ee794790 100644 --- a/jabgui/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/jabgui/src/main/java/org/jabref/gui/JabRefGUI.java @@ -292,7 +292,7 @@ private void openWindow() { Scene scene = new Scene(JabRefGUI.mainFrame); LOGGER.debug("installing CSS"); - themeManager.installCss(scene); + themeManager.installCssImmediately(scene); LOGGER.debug("Handle TextEditor key bindings"); scene.addEventFilter(KeyEvent.KEY_PRESSED, event -> { diff --git a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java index 6e2682c6379..39a950bbcad 100644 --- a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java +++ b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java @@ -93,19 +93,26 @@ public ThemeManager(WorkspacePreferences workspacePreferences, updateThemeSettings(); } - /// Installs the base and additional css files as stylesheets in the given scene. + /// Installs the base and additional CSS files as stylesheets in the given scene. + /// + /// This method is primarily intended to be called by `JabRefGUI` during startup. + /// Using `installCss` directly would cause a delay in theme application, resulting + /// in a brief flash of the default JavaFX theme (Modena CSS) before the intended theme appears. + public void installCssImmediately(Scene scene) { + List stylesheets = Stream + .of(baseStyleSheet.getSceneStylesheet(), + theme.getAdditionalStylesheet().map(StyleSheet::getSceneStylesheet).orElse(null)) + .filter(Objects::nonNull) + .map(URL::toExternalForm) + .toList(); + scene.getStylesheets().setAll(stylesheets); + } + + /// Registers a runnable on JavaFX thread to install the base and additional css files as stylesheets in the given scene. public void installCss(@NonNull Scene scene) { // Because of race condition in JavaFX, IndexOutOfBounds will be thrown, despite // all the invocation to this method come directly from the UI thread - UiTaskExecutor.runInJavaFXThread(() -> { - List stylesheets = Stream - .of(baseStyleSheet.getSceneStylesheet(), - theme.getAdditionalStylesheet().map(StyleSheet::getSceneStylesheet).orElse(null) - ).filter(Objects::nonNull) - .map(URL::toExternalForm) - .toList(); - scene.getStylesheets().setAll(stylesheets); - }); + UiTaskExecutor.runInJavaFXThread(() -> installCssImmediately(scene)); } /// Installs the css file as a stylesheet in the given web engine. Changes in the From 7361b5ae8d9549bac8df04de9142575560551057 Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Sat, 13 Sep 2025 17:23:48 +0200 Subject: [PATCH 2/7] Avoid spamming IndexOutOfBoundsException when the theme is updated at runtime - IndexOutOfBoundsException keeps being thrown although the theme is applied correctly. By catching the exception, we avoid spamming the exception to user. --- .../main/java/org/jabref/gui/theme/ThemeManager.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java index 39a950bbcad..4c7a0327a45 100644 --- a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java +++ b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java @@ -112,7 +112,15 @@ public void installCssImmediately(Scene scene) { public void installCss(@NonNull Scene scene) { // Because of race condition in JavaFX, IndexOutOfBounds will be thrown, despite // all the invocation to this method come directly from the UI thread - UiTaskExecutor.runInJavaFXThread(() -> installCssImmediately(scene)); + UiTaskExecutor.runInJavaFXThread(() -> { + try { + installCssImmediately(scene); + } catch (IndexOutOfBoundsException e) { + // IndexOutOfBoundsException keeps being thrown although the theme is applied correctly. + // By catching the exception, we avoid spamming the exception to user. + LOGGER.error("IndexOutOfBoundsException while installing Css", e); + } + }); } /// Installs the css file as a stylesheet in the given web engine. Changes in the From 3ecff72b44bd286cd0ad39021094f60177f0edb7 Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Sat, 13 Sep 2025 17:24:46 +0200 Subject: [PATCH 3/7] Fix button-bar buttons truncating long text with ellipsis --- jabgui/src/main/resources/org/jabref/gui/Base.css | 6 ------ 1 file changed, 6 deletions(-) diff --git a/jabgui/src/main/resources/org/jabref/gui/Base.css b/jabgui/src/main/resources/org/jabref/gui/Base.css index cdb132504ad..3af664e07bc 100644 --- a/jabgui/src/main/resources/org/jabref/gui/Base.css +++ b/jabgui/src/main/resources/org/jabref/gui/Base.css @@ -414,12 +414,6 @@ TextFlow > .tooltip-text-monospaced { -fx-padding: 0.5em 1em 0.5em 1em; } -.dialog-pane .button-bar .button { - -fx-min-width: 6em; - -fx-pref-width: 6em; - -fx-max-width: 6em; -} - .menu-button > .label { -fx-padding: 0 8 0 8; } From 475d24bb1a49ddc7b27bbcf6907dad92ed5ee4dc Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Sat, 13 Sep 2025 17:53:10 +0200 Subject: [PATCH 4/7] Update Changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87e03674bf0..608941c07bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -136,6 +136,9 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where hierarchical keywords would only show the parent keyword in the entry editor. [#11390](https://github.com/JabRef/jabref/issues/11390) - We fixed an issue where some file choosers regarding LaTeX-aux files did not open in the directory of the last selected file. [#13861](https://github.com/JabRef/jabref/pull/13861) - We fixed an issue where the LaTeX file directory was not stored correctly in combination with the usage of groups from aux files. [#8344](https://github.com/JabRef/jabref/issues/8344) +- We prevented a brief flash of the default JavaFX (Modena) theme on startup. [#13877](https://github.com/JabRef/jabref/pull/13877) +- We fixed an issue where updating the theme at runtime could spam `IndexOutOfBoundsException` errors. [#13877](https://github.com/JabRef/jabref/pull/13877) +- We fixed an issue where button-bar buttons truncated long text with ellipsis. [#13877](https://github.com/JabRef/jabref/pull/13877) ### Removed From 364dd1d0ae321d71fafdfa19b37f51bbcaf8d231 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 13 Sep 2025 21:36:10 +0200 Subject: [PATCH 5/7] use clear --- .../main/java/org/jabref/gui/theme/ThemeManager.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java index 4c7a0327a45..f298160d7f1 100644 --- a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java +++ b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java @@ -99,13 +99,16 @@ public ThemeManager(WorkspacePreferences workspacePreferences, /// Using `installCss` directly would cause a delay in theme application, resulting /// in a brief flash of the default JavaFX theme (Modena CSS) before the intended theme appears. public void installCssImmediately(Scene scene) { - List stylesheets = Stream + List stylesheets = scene.getStylesheets(); + scene.getStylesheets().clear(); + List baseOrThemeStylesheet = Stream .of(baseStyleSheet.getSceneStylesheet(), - theme.getAdditionalStylesheet().map(StyleSheet::getSceneStylesheet).orElse(null)) - .filter(Objects::nonNull) + theme.getAdditionalStylesheet().map(StyleSheet::getSceneStylesheet).orElse(null) + ).filter(Objects::nonNull) .map(URL::toExternalForm) .toList(); - scene.getStylesheets().setAll(stylesheets); + + stylesheets.addAll(baseOrThemeStylesheet); } /// Registers a runnable on JavaFX thread to install the base and additional css files as stylesheets in the given scene. From 421df4ed2b230c50bfd14d3ba65f5aacc7c0f545 Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Mon, 15 Sep 2025 13:58:57 +0200 Subject: [PATCH 6/7] Revert "Avoid spamming IndexOutOfBoundsException when the theme is updated at runtime" This reverts commit 7361b5ae8d9549bac8df04de9142575560551057. --- .../main/java/org/jabref/gui/theme/ThemeManager.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java index f298160d7f1..30bd67efb9d 100644 --- a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java +++ b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java @@ -115,15 +115,7 @@ public void installCssImmediately(Scene scene) { public void installCss(@NonNull Scene scene) { // Because of race condition in JavaFX, IndexOutOfBounds will be thrown, despite // all the invocation to this method come directly from the UI thread - UiTaskExecutor.runInJavaFXThread(() -> { - try { - installCssImmediately(scene); - } catch (IndexOutOfBoundsException e) { - // IndexOutOfBoundsException keeps being thrown although the theme is applied correctly. - // By catching the exception, we avoid spamming the exception to user. - LOGGER.error("IndexOutOfBoundsException while installing Css", e); - } - }); + UiTaskExecutor.runInJavaFXThread(() -> installCssImmediately(scene)); } /// Installs the css file as a stylesheet in the given web engine. Changes in the From d579ef1fb717f68927e70f58fdd4b34ea55db34f Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Mon, 15 Sep 2025 13:59:42 +0200 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 608941c07bd..01b50bcd7f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -137,7 +137,6 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where some file choosers regarding LaTeX-aux files did not open in the directory of the last selected file. [#13861](https://github.com/JabRef/jabref/pull/13861) - We fixed an issue where the LaTeX file directory was not stored correctly in combination with the usage of groups from aux files. [#8344](https://github.com/JabRef/jabref/issues/8344) - We prevented a brief flash of the default JavaFX (Modena) theme on startup. [#13877](https://github.com/JabRef/jabref/pull/13877) -- We fixed an issue where updating the theme at runtime could spam `IndexOutOfBoundsException` errors. [#13877](https://github.com/JabRef/jabref/pull/13877) - We fixed an issue where button-bar buttons truncated long text with ellipsis. [#13877](https://github.com/JabRef/jabref/pull/13877) ### Removed