|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.kuali.rice.krad.datadictionary.DictionaryBeanBase org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase org.kuali.rice.krad.uif.view.ViewTheme
public class ViewTheme
Holds a configuration of CSS and JS assets that provides the base for one or more views
The list of CSS and JS files that are sourced in for a view come from its theme, along with any
additional files configured for the specific view. Generally an application will have one theme for the
entire application.
The theme has logic for 'dev' mode versus 'test/prod' mode. This is controlled through the
rice.krad.dev.mode
configuration variable. In development mode it will source in all the CSS
and JS files individually (to allow for easier debugging). In non-development mode it will source in a
minified file. The path for the minified files can be specified by setting getMinCssFile()
and
getMinScriptFile()
. If not set, it will be formed by using the getName()
,
getMinVersionSuffix()
, and min suffix (this is the file name generated by the theme builder). To
indicate the min file should not be sourced in regardless of the environment, set the property
isIncludeMinFiles()
to false
The path to the minified file is determined by getDirectory()
. It this is not set, it is defaulted to
be '/themes' plus the name of the theme (eg '/themes/kboot')
There are two ways the theme can be configured, manual or by convention. If you want to manually configured the
view theme, set isUsesThemeBuilder()
to false. For dev mode, you must then set the getMinCssSourceFiles()
and getMinScriptSourceFiles()
lists to the theme files. For configuration
by convention, only the theme getName()
is required. The directory will be assumed to be '/themes/{name}'.
Furthermore the list of min CSS and JS files will be retrieved from the theme.properties file created by the
theme builder
Constructor Summary | |
---|---|
ViewTheme()
|
Method Summary | ||
---|---|---|
void |
configureThemeDefaults()
Invoked by View#performApplyModel method to setup defaults for the theme |
|
|
copy()
Returns a clone of the View Theme. |
|
protected
|
copyProperties(T viewTheme)
Copies the properties over for the copy method. |
|
ConfigurationService |
getConfigurationService()
Helper method to retrieve an instance of ConfigurationService |
|
List<String> |
getCssFiles()
List of file paths (relative to the web root) or URLs that will be sourced into the view as CSS files |
|
String |
getDirectory()
Path to the directory (relative to the web root) that holds the assets for the theme |
|
String |
getImageDirectory()
Path to the directory (relative to the web root) that contains images for the theme |
|
String |
getMinCssFile()
File path for the minified CSS file |
|
List<String> |
getMinCssSourceFiles()
List of file paths (relative to web root) or URLs that make up the minified CSS file |
|
String |
getMinScriptFile()
File path for the minified JS file |
|
List<String> |
getMinScriptSourceFiles()
List of file paths (relative to web root) or URLs that make up the minified JS file |
|
String |
getMinVersionSuffix()
When the min file paths are not set, the min file names will be generated using the theme name, version, and the min suffix. |
|
String |
getName()
A name that identifies the view theme, when using the theme builder this should be the same as the directory (for example, if directory is '/themes/kboot', the theme name will be 'kboot') |
|
protected String[] |
getPropertyValue(Properties properties,
String key)
Helper method to retrieve the value of a property from the given Properties object as a string array (string is parsed using comma delimiter) |
|
List<String> |
getScriptFiles()
List of file paths (relative to the web root) or URLs that will be sourced into the view as JS files |
|
String |
getThemeDirectory()
Retrieves the directory associated with the theme |
|
protected Properties |
getThemeProperties()
Retrieves the theme properties associated with the theme |
|
protected boolean |
inDevMode()
Indicates whether operation is in development mode by checking the KRAD configuration parameter |
|
boolean |
isIncludeMinFiles()
Indicates the min files should be sourced into the CSS and JS lists when not in development mode (this is regardless of whether theme builder is being used or not) |
|
boolean |
isUsesThemeBuilder()
Indicates whether the theme has been built (or will be built) using the theme builder and therefore the theme configuration can be defaulted according to the conventions used by the builder |
|
void |
setCssFiles(List<String> cssFiles)
Setter for the list of CSS files that should be sourced in along with the minified files |
|
void |
setDirectory(String directory)
Setter for the theme directory path |
|
void |
setImageDirectory(String imageDirectory)
Setter for the directory that contains images for the theme |
|
void |
setIncludeMinFiles(boolean includeMinFiles)
Setter for including min files in the CSS and JS lists |
|
void |
setMinCssFile(String minCssFile)
Setter for the min CSS file path |
|
void |
setMinCssSourceFiles(List<String> minCssSourceFiles)
Setter for the min file CSS list |
|
protected void |
setMinFileLists()
Sets the getMinScriptSourceFiles() and getMinCssSourceFiles() lists from the
corresponding properties in the theme properties file |
|
void |
setMinScriptFile(String minScriptFile)
Setter for the min JS file path |
|
void |
setMinScriptSourceFiles(List<String> minScriptSourceFiles)
Setter for the min file JS list |
|
void |
setMinVersionSuffix(String minVersionSuffix)
Setter for the min file version string |
|
void |
setName(String name)
Setter for the theme name |
|
void |
setScriptFiles(List<String> scriptFiles)
Setter for the list of JS files that should be sourced in along with the minified files |
|
void |
setUsesThemeBuilder(boolean usesThemeBuilder)
Setter the indicates whether the theme uses the theme builder |
Methods inherited from class org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase |
---|
getExpressionGraph, getPropertyExpression, getPropertyExpressions, getRefreshExpressionGraph, setExpressionGraph, setPropertyExpressions, setRefreshExpressionGraph |
Methods inherited from class org.kuali.rice.krad.datadictionary.DictionaryBeanBase |
---|
getComponentCode, getNamespaceCode, setComponentCode, setNamespaceCode |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.kuali.rice.krad.datadictionary.DictionaryBean |
---|
getComponentCode, getNamespaceCode |
Constructor Detail |
---|
public ViewTheme()
Method Detail |
---|
public void configureThemeDefaults()
Checks whether we are in dev mode, if so it adds all the CSS and JS files as resources. If
isUsesThemeBuilder()
is true, retrieve the theme-derived.properties file in the theme
directory to get the listing of CSS and JS files for theme
When not in dev mode, builds the min file name and path for CSS and JS, which is added to
the list that is sourced in
public String getThemeDirectory()
If getDirectory()
is not configured, the theme directory is assumed to be located in the
'themes' folder of the web root. The directory name is assumed to be the name of the theme
protected void setMinFileLists()
getMinScriptSourceFiles()
and getMinCssSourceFiles()
lists from the
corresponding properties in the theme properties file
protected Properties getThemeProperties() throws IOException
The theme builder creates a file named UifConstants.THEME_DERIVED_PROPERTY_FILE
located in the theme directory. Here the path is formed and loaded into a properties object
IOException
protected String[] getPropertyValue(Properties properties, String key)
properties
- properties object to pull property value fromkey
- key for the property to retrieve
protected boolean inDevMode()
public String getName()
When using the theme builder (config by convention), the name is required configuration
public void setName(String name)
name
- public String getDirectory()
When using the theme builder the directory is not required and will default to '/themes/{name}'
public void setDirectory(String directory)
directory
- public String getImageDirectory()
Configured directory will populate the UifConstants.ContextVariableNames.THEME_IMAGES
context variable which can be referenced with an expression for an image source
When using the theme builder the image directory is not required and will default to a sub directory of the theme directory with name 'images'
public void setImageDirectory(String imageDirectory)
imageDirectory
- public String getMinVersionSuffix()
For application themes this can be set to the config parameter ${app.version}
public void setMinVersionSuffix(String minVersionSuffix)
minVersionSuffix
- public boolean isIncludeMinFiles()
Default is true for including min files
public void setIncludeMinFiles(boolean includeMinFiles)
includeMinFiles
- public String getMinCssFile()
When min file is not set it will be generated by using the theme directory, name, version, and min prefix. This corresponds to the min file names generated by the theme builder For example, with name 'kboot' and version '2.3.0' the min file name will be '/themes/kboot/stylesheets/kboot.2.3.0.min.css'
public void setMinCssFile(String minCssFile)
minCssFile
- public String getMinScriptFile()
When min file is not set it will be generated by using the theme directory, name, version, and min prefix. This corresponds to the min file names generated by the theme builder For example, with name 'kboot' and version '2.3.0' the min file name will be '/themes/kboot/scripts/kboot.2.3.0.min.js'
public void setMinScriptFile(String minScriptFile)
minScriptFile
- public List<String> getMinCssSourceFiles()
In development mode, instead of sourcing in the min CSS file, the list of files specified here will be included. This is to facilitate easier debugging. When using the theme builder this list is automatically retrieved and populated from the theme properties
public void setMinCssSourceFiles(List<String> minCssSourceFiles)
minCssSourceFiles
- public List<String> getMinScriptSourceFiles()
In development mode, instead of sourcing in the min JS file, the list of files specified here will be included. This is to facilitate easier debugging. When using the theme builder this list is automatically retrieved and populated from the theme properties
public void setMinScriptSourceFiles(List<String> minScriptSourceFiles)
minScriptSourceFiles
- public List<String> getCssFiles()
Generally this list should be left empty, and the min file lists configured instead (or none with theme builder). However if there are resources that are not part of the minified CSS file that should be included with the theme they can be added here The minified file path (or list of individual files that make up the minification) will be added to the beginning of this list. Therefore any entries explicitly added through configuration will be sourced in last
public void setCssFiles(List<String> cssFiles)
cssFiles
- public List<String> getScriptFiles()
Generally this list should be left empty, and the min file lists configured instead (or none with theme builder). However if there are resources that are not part of the minified JS file that should be included with the theme they can be added here The minified file path (or list of individual files that make up the minification) will be added to the beginning of this list. Therefore any entries explicitly added through configuration will be sourced in last
public void setScriptFiles(List<String> scriptFiles)
scriptFiles
- public boolean isUsesThemeBuilder()
When set to true, only the getName()
property is required to be configured for the theme. All
other configuration will be determined based on convention. When manually configuring the theme, this flag
should be turned off (by default this flag is on)
public void setUsesThemeBuilder(boolean usesThemeBuilder)
usesThemeBuilder
- public ConfigurationService getConfigurationService()
ConfigurationService
public <T> T copy()
copy
in class DictionaryBeanBase
protected <T> void copyProperties(T viewTheme)
copyProperties
in class UifDictionaryBeanBase
viewTheme
- ViewTheme instance to copy properties to
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |