Top Description Fields Constructors Methods
org.jabref.gui.theme

public Class ThemeManager

extends Object
Class Inheritance
Imports
java.io.IOException, java.net.URL, java.nio.file.Path, java.util.Collections, .List, .Objects, .Set, .WeakHashMap, java.util.function.Consumer, javafx.application.ColorScheme, .Platform, javafx.scene.Scene, javafx.scene.web.WebEngine, org.jabref.gui.util.BindingsHelper, .UiTaskExecutor, org.jabref.model.util.FileUpdateListener, .FileUpdateMonitor, org.jabref.preferences.WorkspacePreferences, com.google.common.annotations.VisibleForTesting, org.slf4j.Logger, .LoggerFactory

Installs and manages style files and provides live reloading. JabRef provides two inbuilt themes and a user customizable one: Light, Dark and Custom. The Light theme is basically the base.css theme. Every other theme is loaded as an addition to base.css.

For type Custom, Theme will protect against removal of the CSS file, degrading as gracefully as possible. If the file becomes unavailable while the application is running, some Scenes that have not yet had the CSS installed may not be themed. The PreviewViewer, which uses WebEngine, supports data URLs and so generally is not affected by removal of the file; however Theme package will not attempt to URL-encode large style sheets so as to protect memory usage (see StyleSheetFile#MAX_IN_MEMORY_CSS_LENGTH).

See Also
Custom themes in the Jabref documentation.

Field Summary

Modifier and TypeField and Description
private final StyleSheet
private final FileUpdateMonitor
private static final Logger
private Scene
private Theme
private final Consumer<Runnable>
private final Set<WebEngine>
private final WorkspacePreferences

Constructor Summary

AccessConstructor and Description
public
ThemeManager(WorkspacePreferences workspacePreferences, FileUpdateMonitor fileUpdateMonitor, Consumer<Runnable> updateRunner)

Method Summary

Modifier and TypeMethod and Description
private void
private void
private void
pack-priv Theme

Returns:

the currently active theme
getActiveTheme
()

public void
installCss(Scene
the scene to install the css into
mainWindowScene
)

Installs the base css file as a stylesheet in the given scene.

public void
installCss(WebEngine
the web engine to install the css into
webEngine
)

Installs the css file as a stylesheet in the given web engine.

private void
private void
private void
private void
public void
updateFontStyle(Scene
is the scene, the font size should be applied to
scene
)

Updates the font size settings of a scene.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseStyleSheetback to summary
private final StyleSheet baseStyleSheet
fileUpdateMonitorback to summary
private final FileUpdateMonitor fileUpdateMonitor
LOGGERback to summary
private static final Logger LOGGER
mainWindowSceneback to summary
private Scene mainWindowScene
themeback to summary
private Theme theme
updateRunnerback to summary
private final Consumer<Runnable> updateRunner
webEnginesback to summary
private final Set<WebEngine> webEngines
workspacePreferencesback to summary
private final WorkspacePreferences workspacePreferences

Constructor Detail

ThemeManagerback to summary
public ThemeManager(WorkspacePreferences workspacePreferences, FileUpdateMonitor fileUpdateMonitor, Consumer<Runnable> updateRunner)

Method Detail

additionalCssLiveUpdateback to summary
private void additionalCssLiveUpdate()
addStylesheetToWatchlistback to summary
private void addStylesheetToWatchlist(StyleSheet styleSheet, FileUpdateListener updateMethod)
baseCssLiveUpdateback to summary
private void baseCssLiveUpdate()
getActiveThemeback to summary
pack-priv Theme getActiveTheme()
Returns:Theme

the currently active theme

Annotations
@VisibleForTesting
installCssback to summary
public void installCss(Scene mainWindowScene)

Installs the base css file as a stylesheet in the given scene. Changes in the css file lead to a redraw of the scene using the new css file.

Parameters
mainWindowScene:Scene

the scene to install the css into

installCssback to summary
public void installCss(WebEngine webEngine)

Installs the css file as a stylesheet in the given web engine. Changes in the css file lead to a redraw of the web engine using the new css file.

Parameters
webEngine:WebEngine

the web engine to install the css into

removeStylesheetFromWatchListback to summary
private void removeStylesheetFromWatchList(StyleSheet styleSheet)
updateAdditionalCssback to summary
private void updateAdditionalCss()
updateBaseCssback to summary
private void updateBaseCss()
updateFontSettingsback to summary
private void updateFontSettings()
updateFontStyleback to summary
public void updateFontStyle(Scene scene)

Updates the font size settings of a scene. This method needs to be called from every custom dialog constructor, since javafx overwrites the style if applied before showing the dialog

Parameters
scene:Scene

is the scene, the font size should be applied to

updateThemeSettingsback to summary
private void updateThemeSettings()