Class DefaultPluginFormElementTemplateDescriptor
- java.lang.Object
-
- de.xima.fc.plugin.models.retval.form.DefaultPluginFormElementTemplateDescriptor
-
- All Implemented Interfaces:
IPluginFormElementTemplateDescriptor
,Serializable
public final class DefaultPluginFormElementTemplateDescriptor extends Object implements IPluginFormElementTemplateDescriptor
Default implementation forIPluginFormElementTemplateDescriptor
with a simple builder.- Since:
- 8.0.1
- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultPluginFormElementTemplateDescriptor.Builder
Simple builder for aIPluginFormElementTemplateDescriptor
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DefaultPluginFormElementTemplateDescriptor.Builder
builder(String id)
String
getClassName()
The name of the type of the main form element represented by this template.String
getDescription(Locale locale)
The localized description for the template that may be shown in the form designer.IPluginFormElementTemplateIcon
getIcon(Locale locale)
Get the icon with the URI for the icon's data.String
getId()
Gets the unique ID of the template.String
getName(Locale locale)
The localized display name for the template.URI
getPersistJson()
Gets the URI for the persist JSON with the content of the template.Set<String>
getTags(Locale locale)
Gets the localized tags of the template.
-
-
-
Method Detail
-
getClassName
public String getClassName()
Description copied from interface:IPluginFormElementTemplateDescriptor
The name of the type of the main form element represented by this template. For example, when the template is a fieldset, this should returnXFieldSet
(=XFieldSet
.class.getSimpleName()
).- Specified by:
getClassName
in interfaceIPluginFormElementTemplateDescriptor
- Returns:
- The class name of the form element.
-
getDescription
public String getDescription(Locale locale)
Description copied from interface:IPluginFormElementTemplateDescriptor
The localized description for the template that may be shown in the form designer.- Specified by:
getDescription
in interfaceIPluginFormElementTemplateDescriptor
- Parameters:
locale
- Locale for localizing the description.- Returns:
- The localized description of the template.
-
getIcon
public IPluginFormElementTemplateIcon getIcon(Locale locale) throws URISyntaxException
Description copied from interface:IPluginFormElementTemplateDescriptor
Get the icon with the URI for the icon's data. The URI is then passed toloadIcon
.The icon is shown, for example, in the panel in the form designer with the available templates. May return
null
, in which case a generic icon is used.- Specified by:
getIcon
in interfaceIPluginFormElementTemplateDescriptor
- Parameters:
locale
- Locale for localizing the icon.- Returns:
- An input stream with the icon for the template, or
null
when no custom icon is available. - Throws:
URISyntaxException
- When an URI could not be resolved. If this exception is thrown, a generic icon is used instead.
-
getId
public String getId()
Description copied from interface:IPluginFormElementTemplateDescriptor
Gets the unique ID of the template. The ID must be unique only within the set of templates returned by the plugin.- Specified by:
getId
in interfaceIPluginFormElementTemplateDescriptor
- Returns:
- The ID of this template.
-
getName
public String getName(Locale locale)
Description copied from interface:IPluginFormElementTemplateDescriptor
The localized display name for the template.- Specified by:
getName
in interfaceIPluginFormElementTemplateDescriptor
- Parameters:
locale
- Locale for localizing the name.- Returns:
- The localized name of the template.
-
getPersistJson
public URI getPersistJson() throws URISyntaxException
Description copied from interface:IPluginFormElementTemplateDescriptor
Gets the URI for the persist JSON with the content of the template. The URI is then passed toloadPersistJson
.The persist JSON is a JSON string representing a JSON object. The encoding of the persist JSON string must be UTF-8. It has the following structure:
{ "charsetName": "UTF-8", "persist": "...", "versionsNummer": 1 }
The propertiescharsetName
andversionsNummer
should always be set toUTF-8
and1
, respectively. The propertypersist
is another string representing a JSON object with the following structure:{ "items": [ { "properties": { ... }, "className": "XTextField" }, // more items ], "version": { "time": "23:10:09", "date": "09.08.2023", "timestamp": 20230809231009, "version": "hippocamp-9.0.0-SNAPSHOT", "majorVersion": "9", "minorVersion": "0", "patchVersion": "0", "number": 0 } }
Theversion
refers to the formcycle version where the template was created. This version is used to update existing templates when e.g. a later formcycle version adds new properties.The
items
are a list of items contained in the template. The first item is always the main item and must have itsclassName
set to the same value asIPluginFormElementTemplateDescriptor.getClassName()
. All following items, if present, must be children of the main item, and must have theirXPropertyEnum.parentid
set to either the main item or another child of the main item.The property
properties
is an object with the configuration of the form element. The keys areEnum.name()
, the values are the corresponding values for theXPropertyEnum
.Note 1: The resource might be cached with the returned URI as the cache key. Plugins should append e.g. a version parameter (such as the plugin version) to the URI if needed.
Note 2: If you simply want provide static templates with form elements that you have already configured in the form designer, you can simply select the form element in the form designer, press Ctrl+c to copy the form element, go to a text editor and press Ctrl+v to paste the JSON string with the form element into the editor. This is the JSON string that you need to return in this method.
- Specified by:
getPersistJson
in interfaceIPluginFormElementTemplateDescriptor
- Returns:
- An input stream for the persist JSON content of the template.
- Throws:
URISyntaxException
- When a URI could not be resolved. If this exception is thrown, the template is skipped as if it had not been returned by the plugin.
-
getTags
public Set<String> getTags(Locale locale)
Description copied from interface:IPluginFormElementTemplateDescriptor
Gets the localized tags of the template. The tags are used, for example, to filter the available templates by their tag name.- Specified by:
getTags
in interfaceIPluginFormElementTemplateDescriptor
- Parameters:
locale
- Locale for localizing the tags.- Returns:
- The localized tags of the template, if any.
-
builder
public static DefaultPluginFormElementTemplateDescriptor.Builder builder(String id)
- Parameters:
id
- SeeIPluginFormElementTemplateDescriptor.getId()
- Returns:
- A builder for a
IPluginFormElementTemplateDescriptor
.
-
-