Class Themes


  • public class Themes
    extends java.lang.Object
    Facade for accessing internal theming subsystem In most cases, users need not use the underlying theme registry and theme resolver directly.
    Author:
    sam, neillee
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String BREEZE_DISPLAY
      Deprecated.
      since 6.5.2
      static java.lang.String BREEZE_NAME
      Deprecated.
      since 6.5.2
      static int BREEZE_PRIORITY
      Deprecated.
      since 6.5.2
    • Constructor Summary

      Constructors 
      Constructor Description
      Themes()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getCurrentTheme()
      Returns the current theme name
      static java.lang.String getDisplayName​(java.lang.String themeName)
      Return the display name (human name) of the theme
      static int getPriority​(java.lang.String themeName)
      Return the priority of the given theme
      static java.lang.String getTheme​(Execution exe)
      Returns the theme specified using the current theme resolution strategy Default strategy is to use cookies
      static java.lang.String[] getThemes()
      Returns an array of registered theme names
      static boolean hasTheme​(java.lang.String themeName)
      Returns true if the theme is registered
      static void register​(java.lang.String themeName)
      Register the theme, so it becomes available in the theme list
      static void register​(java.lang.String themeName, java.lang.String displayName, int priority)
      Register the theme with details
      static void register​(java.lang.String themeName, java.lang.String displayName, int priority, StandardTheme.ThemeOrigin origin)
      Register the theme, its display name, its priority; and also specifies its origin (e.g. from JAR or from FOLDER).
      static void register​(java.lang.String themeName, StandardTheme.ThemeOrigin origin)
      Register the theme, and specifies its origin (e.g. from JAR or from FOLDER) Please use Themes.register("custom", Themes.ThemeOrigin.FOLDER) to make your custom theme available if the theme resource is inside a folder
      static void setDisplayName​(java.lang.String themeName, java.lang.String displayName)
      Set the display name (human name) of the theme
      static void setPriority​(java.lang.String themeName, int priority)
      Set the priority of the theme.
      static void setTheme​(Execution exe, java.lang.String themeName)
      Sets the theme name using the current theme resolution strategy Default strategy is to use cookies
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BREEZE_NAME

        public static final java.lang.String BREEZE_NAME
        Deprecated.
        since 6.5.2
        Should use StandardTheme.DEFAULT_NAME
        See Also:
        Constant Field Values
      • BREEZE_DISPLAY

        public static final java.lang.String BREEZE_DISPLAY
        Deprecated.
        since 6.5.2
        Should use StandardTheme.DEFAULT_DISPLAY
        See Also:
        Constant Field Values
      • BREEZE_PRIORITY

        public static final int BREEZE_PRIORITY
        Deprecated.
        since 6.5.2
        Should use StandardTheme.DEFAULT_PRIORITY
        See Also:
        Constant Field Values
    • Constructor Detail

      • Themes

        public Themes()
    • Method Detail

      • setTheme

        public static void setTheme​(Execution exe,
                                    java.lang.String themeName)
        Sets the theme name using the current theme resolution strategy Default strategy is to use cookies
        Parameters:
        exe - Execution
        themeName - the new intended theme name
      • getTheme

        public static java.lang.String getTheme​(Execution exe)
        Returns the theme specified using the current theme resolution strategy Default strategy is to use cookies
        Parameters:
        exe - Execution
        Returns:
        the name of the theme or a fall back theme name determined by the theme resolution strategy used.
      • getCurrentTheme

        public static java.lang.String getCurrentTheme()
        Returns the current theme name
        Returns:
        the current theme name
      • hasTheme

        public static boolean hasTheme​(java.lang.String themeName)
        Returns true if the theme is registered
        Parameters:
        themeName - the name of the theme
        Returns:
        true if the theme with the given name is registered
      • getThemes

        public static java.lang.String[] getThemes()
        Returns an array of registered theme names
        Returns:
        an array of registered theme names
      • register

        public static void register​(java.lang.String themeName)
        Register the theme, so it becomes available in the theme list
        Parameters:
        themeName - the name of the theme to be registered Since 6.5.2, to register additional tablet themes, just prepend theme names with the "tablet:" prefix (ZK EE only). For example, Themes.register("tablet:dark") would register a tablet theme with the name "dark".
      • register

        public static void register​(java.lang.String themeName,
                                    StandardTheme.ThemeOrigin origin)
        Register the theme, and specifies its origin (e.g. from JAR or from FOLDER) Please use Themes.register("custom", Themes.ThemeOrigin.FOLDER) to make your custom theme available if the theme resource is inside a folder
        Parameters:
        themeName - theme name Since 6.5.2, to register additional tablet themes, just prepend theme names with the "tablet:" prefix (ZK EE only). For example, Themes.register("tablet:dark") would register a tablet theme with the name "dark".
        origin - origin of the theme resource
        Since:
        6.5.2
      • register

        public static void register​(java.lang.String themeName,
                                    java.lang.String displayName,
                                    int priority)
        Register the theme with details
        Parameters:
        themeName - theme name Since 6.5.2, to register additional tablet themes, just prepend theme names with the "tablet:" prefix (ZK EE only). For example, Themes.register("tablet:dark") would register a tablet theme with the name "dark".
        displayName - The human name of the theme
        priority - Priority is higher if the value the smaller
      • register

        public static void register​(java.lang.String themeName,
                                    java.lang.String displayName,
                                    int priority,
                                    StandardTheme.ThemeOrigin origin)
        Register the theme, its display name, its priority; and also specifies its origin (e.g. from JAR or from FOLDER). Please use Themes.register("custom", "Custom Theme", 100, Themes.ThemeOrigin.FOLDER) to make your custom theme available if the theme resource is inside a folder.
        Parameters:
        themeName - theme name Since 6.5.2, to register additional tablet themes, just prepend theme names with the "tablet:" prefix (ZK EE only). For example, Themes.register("tablet:dark") would register a tablet theme with the name "dark".
        displayName - a more descriptive name for the theme, for display purpose
        priority - priority of the theme
        origin - origin of the theme resource
        Since:
        6.5.2
      • setDisplayName

        public static void setDisplayName​(java.lang.String themeName,
                                          java.lang.String displayName)
        Set the display name (human name) of the theme
        Parameters:
        themeName - theme name Since 6.5.2, to identify tablet themes for changing display names, just prepend theme names with the "tablet:" prefix (ZK EE only). For example, Themes.setDisplayName("tablet:dark", "foo") would change the display name for the tablet theme with the name "dark".
        displayName - the new name to be displayed
      • getDisplayName

        public static java.lang.String getDisplayName​(java.lang.String themeName)
        Return the display name (human name) of the theme
        Parameters:
        themeName - theme name Since 6.5.2, to identify tablet themes for getting display names, just prepend theme names with the "tablet:" prefix (ZK EE only). For example, Themes.getDisplayName("tablet:dark") would return the display name for the tablet theme with the name "dark".
        Returns:
        the display name
      • setPriority

        public static void setPriority​(java.lang.String themeName,
                                       int priority)
        Set the priority of the theme.
        Parameters:
        themeName - theme name Since 6.5.2, to identify tablet themes for changing priorities, just prepend theme names with the "tablet:" prefix (ZK EE only). For example, Themes.setPriority("tablet:dark", 100) would change the display name for the tablet theme with the name "dark".
        priority - Priority is higher if the value the smaller
      • getPriority

        public static int getPriority​(java.lang.String themeName)
        Return the priority of the given theme
        Parameters:
        themeName - theme name Since 6.5.2, to identify tablet themes for getting priorities, just prepend theme names with the "tablet:" prefix (ZK EE only). For example, Themes.getDisplayName("tablet:dark") would return the priority for the tablet theme with the name "dark".
        Returns:
        the priority of the given theme