All Implemented Interfaces:
ThemeManager

public class ThemeManagerImpl extends AbstractAssetManager<String,String> implements ThemeManager
  • Constructor Details

    • ThemeManagerImpl

      public ThemeManagerImpl(@Nonnull PerspectiveContext perspectiveContext)
  • Method Details

    • setup

      public void setup()
      Description copied from class: AbstractAssetManager
      Setup the Asset Manager. Copies any defaults into the asset home directory. Should be run before AbstractLifecycle.startup()
      Overrides:
      setup in class AbstractAssetManager<String,String>
    • performUpgradeCheckAndBackup

      protected void performUpgradeCheckAndBackup() throws IOException
      Operates under the assumption that if the dark and light theme folders do not exist in the themes folder, then the user has not upgraded. In this case, we copy anything in the themes folder into a backup folder.
      Throws:
      IOException
    • getTheme

      public Optional<String> getTheme(String themeName)
      ENTRY Delivers a processed theme file. The first time a theme is requested, the processed css is stored in cache. Subsequent requests return the cached css.
      Specified by:
      getTheme in interface ThemeManager
      Parameters:
      themeName - - The base name, ie. theme-dark, of the theme to fetch. Assumes that the theme does not contain the css file extension.
      Returns:
      - Returns an optional string representing the requested theme as css.
    • getThemesList

      public List<String> getThemesList()
      Description copied from interface: ThemeManager
      Fetch a list of all of the available theme names.
      Specified by:
      getThemesList in interface ThemeManager
      Returns:
      A string list of available themes that may be fetched using ThemeManager.getTheme(String themeName).
    • generateKey

      @Nonnull protected Optional<String> generateKey(@Nonnull Path path)
      Description copied from class: AbstractAssetManager
      Generate a cache key for the given Path
      Specified by:
      generateKey in class AbstractAssetManager<String,String>
      Parameters:
      path - The Path for which we want to generate a cache key
      Returns:
      An Optional containing the cache key or an empty Optional if the cache key could not be generated
    • parseValue

      @Nonnull protected Optional<String> parseValue(@Nonnull Path path)
      Description copied from class: AbstractAssetManager
      Parse the cache value for the given Path
      Specified by:
      parseValue in class AbstractAssetManager<String,String>
      Parameters:
      path - The Path for which we want to generate a cache value
      Returns:
      An Optional containing the cache value or an empty Optional if the cache value could not be generated
    • onCacheChanged

      protected void onCacheChanged()
      Processes themes that are already in cache, and which have been requested via getTheme.
      Overrides:
      onCacheChanged in class AbstractAssetManager<String,String>
    • copyOptions

      protected CopyOption[] copyOptions(@Nonnull byte[] existingAssetDigest, @Nonnull byte[] currentExistingAssetDigest)
      Overrides:
      copyOptions in class AbstractAssetManager<String,String>