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 for IPluginFormElementTemplateDescriptor with a simple builder.
Since:
8.0.1
Author:
XIMA MEDIA GmbH
See Also:
  • Method Details

    • 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 return XFieldSet (=XFieldSet.class.getSimpleName()).
      Specified by:
      getClassName in interface IPluginFormElementTemplateDescriptor
      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 interface IPluginFormElementTemplateDescriptor
      Parameters:
      locale - Locale for localizing the description.
      Returns:
      The localized description of the template.
    • getIcon

      Description copied from interface: IPluginFormElementTemplateDescriptor
      Get the icon with the URI for the icon's data. The URI is then passed to loadIcon.

      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 interface IPluginFormElementTemplateDescriptor
      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 interface IPluginFormElementTemplateDescriptor
      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 interface IPluginFormElementTemplateDescriptor
      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 to loadPersistJson.

      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 properties charsetName and versionsNummer should always be set to UTF-8 and 1, respectively. The property persist 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
         }
       }
       
      The version 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 its className set to the same value as IPluginFormElementTemplateDescriptor.getClassName(). All following items, if present, must be children of the main item, and must have their XPropertyEnum.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 are Enum.name(), the values are the corresponding values for the XPropertyEnum.

      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 interface IPluginFormElementTemplateDescriptor
      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 interface IPluginFormElementTemplateDescriptor
      Parameters:
      locale - Locale for localizing the tags.
      Returns:
      The localized tags of the template, if any.
    • builder

      Parameters:
      id - See IPluginFormElementTemplateDescriptor.getId()
      Returns:
      A builder for a IPluginFormElementTemplateDescriptor.