Class ThemeManagerImpl
- java.lang.Object
-
- com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
-
- com.inductiveautomation.perspective.gateway.assets.AbstractAssetManager<java.lang.String,java.lang.String>
-
- com.inductiveautomation.perspective.gateway.assets.themes.ThemeManagerImpl
-
- All Implemented Interfaces:
ThemeManager
public class ThemeManagerImpl extends AbstractAssetManager<java.lang.String,java.lang.String> implements ThemeManager
-
-
Field Summary
-
Fields inherited from class com.inductiveautomation.perspective.gateway.assets.AbstractAssetManager
assetPath, cacheLock, perspectiveContext
-
-
Constructor Summary
Constructors Constructor Description ThemeManagerImpl(PerspectiveContext perspectiveContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.nio.file.CopyOption[]
copyOptions(byte[] existingAssetDigest, byte[] currentExistingAssetDigest)
protected java.util.Optional<java.lang.String>
generateKey(java.nio.file.Path path)
Generate a cache key for the givenPath
java.util.Optional<java.lang.String>
getTheme(java.lang.String themeName)
ENTRY Delivers a processed theme file.java.util.List<java.lang.String>
getThemesList()
Fetch a list of all of the available theme names.protected void
onCacheChanged()
Processes themes that are already in cache, and which have been requested via getTheme.protected java.util.Optional<java.lang.String>
parseValue(java.nio.file.Path path)
Parse the cache value for the givenPath
protected void
performUpgradeCheckAndBackup()
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.void
setup()
Setup the Asset Manager.-
Methods inherited from class com.inductiveautomation.perspective.gateway.assets.AbstractAssetManager
copyInputStreamToPath, copyInputStreamToPath, getCache, getCachedValue, getDigestCopy, getDigestFor, onShutdown, onStartup
-
Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
isRunning, shutdown, startup
-
-
-
-
Constructor Detail
-
ThemeManagerImpl
public ThemeManagerImpl(@Nonnull PerspectiveContext perspectiveContext)
-
-
Method Detail
-
setup
public void setup()
Description copied from class:AbstractAssetManager
Setup the Asset Manager. Copies any defaults into the asset home directory. Should be run beforeAbstractLifecycle.startup()
- Overrides:
setup
in classAbstractAssetManager<java.lang.String,java.lang.String>
-
performUpgradeCheckAndBackup
protected void performUpgradeCheckAndBackup() throws java.io.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:
java.io.IOException
-
getTheme
public java.util.Optional<java.lang.String> getTheme(java.lang.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 interfaceThemeManager
- 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 java.util.List<java.lang.String> getThemesList()
Description copied from interface:ThemeManager
Fetch a list of all of the available theme names.- Specified by:
getThemesList
in interfaceThemeManager
- Returns:
- A string list of available themes that may be fetched
using
ThemeManager.getTheme(String themeName)
.
-
generateKey
@Nonnull protected java.util.Optional<java.lang.String> generateKey(@Nonnull java.nio.file.Path path)
Description copied from class:AbstractAssetManager
Generate a cache key for the givenPath
- Specified by:
generateKey
in classAbstractAssetManager<java.lang.String,java.lang.String>
- Parameters:
path
- ThePath
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 java.util.Optional<java.lang.String> parseValue(@Nonnull java.nio.file.Path path)
Description copied from class:AbstractAssetManager
Parse the cache value for the givenPath
- Specified by:
parseValue
in classAbstractAssetManager<java.lang.String,java.lang.String>
- Parameters:
path
- ThePath
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 classAbstractAssetManager<java.lang.String,java.lang.String>
-
copyOptions
protected java.nio.file.CopyOption[] copyOptions(@Nonnull byte[] existingAssetDigest, @Nonnull byte[] currentExistingAssetDigest)
- Overrides:
copyOptions
in classAbstractAssetManager<java.lang.String,java.lang.String>
-
-