Package de.xima.fc.common.form_theme
Class StaticFormTheme.Builder
- java.lang.Object
-
- de.xima.fc.common.form_theme.StaticFormTheme.Builder
-
- Enclosing class:
- StaticFormTheme
public static final class StaticFormTheme.Builder extends Object
Builder for aform theme
. Requires that the set of available files is known beforehand.The builder lets configure various options. It also lets you add files to the theme. The available files must be known beforehand, but the contents can be loaded dynamically. You can either specify the content for each file separately, or use a global loader that is able to load files for a given context and file path.
- Since:
- 8.3.0
- Author:
- XIMA MEDIA GmbH
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StaticFormTheme.Builder
addCssClass(String... cssClasses)
Adds the CSS classes to the form theme, seeIFormTheme.getCssClasses()
.StaticFormTheme.Builder
addFile(EFormThemeResourceContext context, String filePath, StaticFormTheme.FormThemeFileMeta meta)
Adds a file to the form theme.StaticFormTheme.Builder
addFile(String context, String filePath, StaticFormTheme.FormThemeFileMeta meta)
Adds a file to the form theme.StaticFormTheme.Builder
addFilePath(EFormThemeResourceContext context, String... filePaths)
Adds a file to the form theme, without any metadata.StaticFormTheme.Builder
addFilePath(String context, String... filePaths)
Adds a file to the form theme, without any metadata.StaticFormTheme.Builder
addFilePaths(Map<String,? extends Collection<String>> filePaths)
Adds files to the form theme, without any metadata.IFormTheme
build()
Creates a new form theme with the current configuration.StaticFormTheme.Builder
cssClasses(Set<String> cssClasses)
Sets the CSS classes for the form theme, seeIFormTheme.getCssClasses()
.StaticFormTheme.Builder
displayName(String displayName)
Sets the display name for the form theme, seeIFormTheme.getDisplayName(Locale)
.StaticFormTheme.Builder
displayName(Function<Locale,String> displayName)
Sets the display name for the form theme, seeIFormTheme.getDisplayName(Locale)
.StaticFormTheme.Builder
fallbackFileLoader(StaticFormTheme.IFormThemeFileLoader fallbackFileLoader)
Sets the fallback loader for the content of a form theme file, seeIFormTheme#openFile
.StaticFormTheme.Builder
fallbackInheritanceModeProvider(StaticFormTheme.IFormThemeInheritanceModeProvider fallbackInheritanceModeProvider)
Sets the fallback inheritance mode provider for the form theme, seeIFormTheme#getFileInheritanceMode
.StaticFormTheme.Builder
fallbackOfferCssClassesAsSuggestionsProvider(StaticFormTheme.IFormThemeOfferCssClassesAsSuggestionsProvider fallbackOfferCssClassesAsSuggestionsProvider)
Sets the fallback provider for the flag that indicates whether to offer CSS classes as suggestions, for a file in a form theme.StaticFormTheme.Builder
files(Map<String,Map<String,StaticFormTheme.FormThemeFileMeta>> files)
Set the files of the form theme, overriding any previously set files.StaticFormTheme.Builder
groupName(String groupName)
Sets the group name for the form theme, seeIFormTheme.getGroupName(Locale)
.StaticFormTheme.Builder
groupName(Function<Locale,String> groupName)
Sets the group name for the form theme, seeIFormTheme.getGroupName(Locale)
.StaticFormTheme.Builder
parent(FormThemeReference parent)
Sets the parent form theme for the form theme, seeIFormTheme.getParentFormTheme()
.
-
-
-
Method Detail
-
addCssClass
@CanIgnoreReturnValue public StaticFormTheme.Builder addCssClass(String... cssClasses)
Adds the CSS classes to the form theme, seeIFormTheme.getCssClasses()
. Preserves any previously set CSS classes.- Parameters:
cssClasses
- The CSS classes for the form theme.- Returns:
- This builder for chaining method calls.
-
addFile
@CanIgnoreReturnValue public StaticFormTheme.Builder addFile(String context, String filePath, StaticFormTheme.FormThemeFileMeta meta)
Adds a file to the form theme.- Parameters:
context
- The resource context of the file, seeEFormThemeResourceContext
for well-known contexts.filePath
- The path of the file.meta
- The metadata of the file, seeStaticFormTheme.FormThemeFileMeta
.- Returns:
- This builder for chaining method calls.
-
addFile
@CanIgnoreReturnValue public StaticFormTheme.Builder addFile(EFormThemeResourceContext context, String filePath, StaticFormTheme.FormThemeFileMeta meta)
Adds a file to the form theme.- Parameters:
context
- The resource context of the file.filePath
- The path of the file.meta
- The metadata of the file, seeStaticFormTheme.FormThemeFileMeta
.- Returns:
- This builder for chaining method calls.
-
addFilePath
@CanIgnoreReturnValue public StaticFormTheme.Builder addFilePath(String context, String... filePaths)
Adds a file to the form theme, without any metadata. Effectively, this will fall back to the global fallbackfile loader
andinheritance mode provider
.- Parameters:
context
- The resource context of the file, seeEFormThemeResourceContext
for well-known contexts.filePaths
- The paths of the files to add.- Returns:
- This builder for chaining method calls.
-
addFilePath
@CanIgnoreReturnValue public StaticFormTheme.Builder addFilePath(EFormThemeResourceContext context, String... filePaths)
Adds a file to the form theme, without any metadata. Effectively, this will fall back to the global fallbackfile loader
andinheritance mode provider
.- Parameters:
context
- The resource context of the file.filePaths
- The paths of the files to add.- Returns:
- This builder for chaining method calls.
-
addFilePaths
@CanIgnoreReturnValue public StaticFormTheme.Builder addFilePaths(Map<String,? extends Collection<String>> filePaths)
Adds files to the form theme, without any metadata. Effectively, this will fall back to the global fallbackfile loader
andinheritance mode provider
.- Parameters:
filePaths
- A map where the key is resource context of the file, seeEFormThemeResourceContext
for well-known contexts. The value is the set of file paths for that file.- Returns:
- This builder for chaining method calls.
-
build
public IFormTheme build()
Creates a new form theme with the current configuration. Subsequent changes to the builder do not affect the returned form theme.- Returns:
- A new form theme.
-
cssClasses
@CanIgnoreReturnValue public StaticFormTheme.Builder cssClasses(Set<String> cssClasses)
Sets the CSS classes for the form theme, seeIFormTheme.getCssClasses()
. Overrides any previously set CSS classes.- Parameters:
cssClasses
- The CSS classes for the form theme.- Returns:
- This builder for chaining method calls.
-
displayName
@CanIgnoreReturnValue public StaticFormTheme.Builder displayName(Function<Locale,String> displayName)
Sets the display name for the form theme, seeIFormTheme.getDisplayName(Locale)
. Overrides any previously set display name.- Parameters:
displayName
- The display name for the form theme.- Returns:
- This builder for chaining method calls.
-
displayName
@CanIgnoreReturnValue public StaticFormTheme.Builder displayName(String displayName)
Sets the display name for the form theme, seeIFormTheme.getDisplayName(Locale)
. Overrides any previously set display name.- Parameters:
displayName
- The display name for the form theme.- Returns:
- This builder for chaining method calls.
-
fallbackFileLoader
@CanIgnoreReturnValue public StaticFormTheme.Builder fallbackFileLoader(StaticFormTheme.IFormThemeFileLoader fallbackFileLoader)
Sets the fallback loader for the content of a form theme file, seeIFormTheme#openFile
. The fallback loader is used when no loader was specified for a file. Overrides any previously set fallback loader.When not set, the default fallback loader will be used, which cannot load any files and throws a
FileNotFoundException
.- Parameters:
fallbackFileLoader
- The fallback loader for the content of a form theme file.- Returns:
- This builder for chaining method calls.
-
fallbackInheritanceModeProvider
@CanIgnoreReturnValue public StaticFormTheme.Builder fallbackInheritanceModeProvider(StaticFormTheme.IFormThemeInheritanceModeProvider fallbackInheritanceModeProvider)
Sets the fallback inheritance mode provider for the form theme, seeIFormTheme#getFileInheritanceMode
. The fallback inheritance mode provider is used when no inheritance mode was specified for a file. Overrides any previously set fallback inheritance mode provider.When not set, the default inheritance mode provider will be used, which merges CSS and JavaScript files, and overrides all other files (such as images or fonts).
- Parameters:
fallbackInheritanceModeProvider
- The fallback inheritance mode provider for the form theme.- Returns:
- This builder for chaining method calls.
-
fallbackOfferCssClassesAsSuggestionsProvider
@CanIgnoreReturnValue public StaticFormTheme.Builder fallbackOfferCssClassesAsSuggestionsProvider(StaticFormTheme.IFormThemeOfferCssClassesAsSuggestionsProvider fallbackOfferCssClassesAsSuggestionsProvider)
Sets the fallback provider for the flag that indicates whether to offer CSS classes as suggestions, for a file in a form theme. SeeisOfferCssClassesAsSuggestions
. The fallback provider is used when no flag was specified explicitly for a file.When not set, the default provider will be used, which defaults to true for all CSS files.
- Parameters:
fallbackOfferCssClassesAsSuggestionsProvider
- The fallback provider to use.- Returns:
- This builder for chaining method calls.
-
files
@CanIgnoreReturnValue public StaticFormTheme.Builder files(Map<String,Map<String,StaticFormTheme.FormThemeFileMeta>> files)
Set the files of the form theme, overriding any previously set files. The files are specified as a map where the key is the resource context of the file, seeEFormThemeResourceContext
for well-known contexts. The value is another map where the key is the file path and the value is the metadata of the file, seeStaticFormTheme.FormThemeFileMeta
.- Parameters:
files
- A map with the files to set.- Returns:
- This builder for chaining method calls.
-
groupName
@CanIgnoreReturnValue public StaticFormTheme.Builder groupName(Function<Locale,String> groupName)
Sets the group name for the form theme, seeIFormTheme.getGroupName(Locale)
. Overrides any previously set group name.- Parameters:
groupName
- The group name for the form theme.- Returns:
- This builder for chaining method calls.
-
groupName
@CanIgnoreReturnValue public StaticFormTheme.Builder groupName(String groupName)
Sets the group name for the form theme, seeIFormTheme.getGroupName(Locale)
. Overrides any previously set group name.- Parameters:
groupName
- The group name for the form theme.- Returns:
- This builder for chaining method calls.
-
parent
@CanIgnoreReturnValue public StaticFormTheme.Builder parent(FormThemeReference parent)
Sets the parent form theme for the form theme, seeIFormTheme.getParentFormTheme()
. Overrides any previously set parent form theme.- Parameters:
parent
- The parent form theme for the form theme.- Returns:
- This builder for chaining method calls.
-
-