Package org.zkoss.zul.theme
Class StandardThemeProvider
java.lang.Object
org.zkoss.zul.theme.StandardThemeProvider
- All Implemented Interfaces:
ThemeProvider
- Direct Known Subclasses:
StandardThemeProvider
A standard implementation of ThemeProvider for ZK CE, which works with the
Marble theme (ZK 11.0 and later; formerly the Breeze series themes)
- Author:
- simonpai, jumperchen, neillee
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.zkoss.zk.ui.util.ThemeProvider
ThemeProvider.Aide -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCalled when a WCS (Widget CSS descriptor) file is about to be loaded.beforeWidgetCSS(Execution exec, String uri) Called when a WCS (Widget CSS descriptor) file is about to load the CSS file associated with a widget.protected static StringgetThemeURIs(Execution exec, List<Object> uris) Marble ships a reset stylesheet that must be loaded immediately before ZK's widget-CSS bundle (zk.wcs) so it keeps its "first" cascade position in the page.intgetWCSCacheControl(Execution exec, String uri) Returns the number of hours that the specified WCS (Widget CSS descriptor) file won't be changed.protected static booleanReturns whether the current theme is the default theme (Marble), which ships its own reset stylesheet and no Font Awesome.
-
Field Details
-
DEFAULT_WCS
Default theme css file- See Also:
-
-
Constructor Details
-
StandardThemeProvider
public StandardThemeProvider()
-
-
Method Details
-
getThemeFileSuffix
-
isDefaultTheme
protected static boolean isDefaultTheme()Returns whether the current theme is the default theme (Marble), which ships its own reset stylesheet and no Font Awesome.- Since:
- 11.0.0
-
getThemeURIs
Marble ships a reset stylesheet that must be loaded immediately before ZK's widget-CSS bundle (zk.wcs) so it keeps its "first" cascade position in the page. For the default theme this method inserts the reset URI right before the first entry that starts withDEFAULT_WCS; for any other theme it only applies the theme suffix to that entry, since a legacy theme resets in its own norm.css.dsp.Which reset stylesheet is served is controlled by the library property
org.zkoss.zul.theme.browserDefault(boolean, defaultfalse):false(default) — serve the standard global reset (~./zul/css/reset.css), which overrides browser defaults page-wide.true— serve the host-safe reset (~./zul/css/reset-embed.css), scoped so it does not override a host page's own styles; use this when a ZK page is embedded inside another (non-ZK) page.
Since ZK 11.0.0 this method inserts the reset stylesheet for the default theme; earlier versions only applied the non-default-theme suffix to the widget-CSS bundle.
- Specified by:
getThemeURIsin interfaceThemeProvider- Parameters:
exec- the current execution (never null), where you can retrieve the desktop, request and response. Note: if your Web application supports multiple devices, you have to checkDesktop.getDevice().uris- the default set of theme's URIs, i.e., the themes defined in language definitions (lang.xml and lang-addon.xml) and the configuration (thetheme-urielements in web.xml). Each URI is an instance of of eitherStringorStyleSheet. Notice that, unless it is customized by application specific lang-addon, all URIs are, by default, String instances.- Returns:
- the collection of the theme's URIs
that the current desktop shall use.
Each URI is an instance of of either
StringorStyleSheet.
-
getWCSCacheControl
Description copied from interface:ThemeProviderReturns the number of hours that the specified WCS (Widget CSS descriptor) file won't be changed. In other words, the client is allowed to cache the file until the returned hours expires.- Specified by:
getWCSCacheControlin interfaceThemeProvideruri- the URI of the WCS file, e.g., ~./zul/css/zk.wcs- Returns:
- number of hours that the WCS file is allowed to cache. If it is never changed until next ZK upgrade, you could return 8760 (the default if ThemeProvider is not specified). If you don't want the client to cache, return a non-positive number.
-
beforeWCS
Description copied from interface:ThemeProviderCalled when a WCS (Widget CSS descriptor) file is about to be loaded. This method then returns the real URI of the WCS file to load. If no need to change, just return theuriparameter.If you want to change the font size, you can set the attributes of the execution accordingly as follows.
- fontSizeM
- The default font size. Default: 12px
- fontSizeMS
- The font size for menus. Default: 11px
- fontSizeS
- The font size for smaller fonts, such as toolbar. Default: 11px
- fontSizeXS
- The font size for extreme small fonts. Default 10px
- fontFamilyT
- The font family for titles. Default: arial, sans-serif
- fontFamilyC
- The font family for content. Default: arial, sans-serif
For example,
String beforeWCS(Execution exec, String uri) { exec.setAttribute("fontSizeM", "15px"); return uri; }- Specified by:
beforeWCSin interfaceThemeProvider- Parameters:
exec- the current execution (never null), where you can retrieve the request and response. However, unlikeThemeProvider.getThemeURIs(org.zkoss.zk.ui.Execution, java.util.List<java.lang.Object>), the desktop might not be available when this method is called.uri- the URI of the WCS file, e.g., ~./zul/css/zk.wcs- Returns:
- the real URI of the WCS file to load. If null is returned, the WCS file is ignored.
-
beforeWidgetCSS
Description copied from interface:ThemeProviderCalled when a WCS (Widget CSS descriptor) file is about to load the CSS file associated with a widget. This method then returns the real URI of the WCS file to load. If no need to change, just return theuriparameter.This method is usually overridden to load the CSS files from a different directory. For example,
String beforeWidgetCSS(Execution exec, String uri) { return uri.startsWith("~./") ? "~./foo/" + uri.substring(3): uri; }- Specified by:
beforeWidgetCSSin interfaceThemeProvider- Parameters:
exec- the current execution (never null), where you can retrieve the request ad response. However, unlikeThemeProvider.getThemeURIs(org.zkoss.zk.ui.Execution, java.util.List<java.lang.Object>), the desktop might not be available when this method is called.uri- the URI of the CSS file associated with a widget, e.g., ~./js/zul/wgt/css/a.css.dsp- Returns:
- the real URI of the CSS file to load If null is returned, the CSS file is ignored.
-