Interface IPluginFormElementTemplate
-
- All Superinterfaces:
IFCPlugin
,INamedUiElement
,INameProviding
,ITransferable
,Serializable
- All Known Subinterfaces:
IPluginFormElementTemplateStatic
public interface IPluginFormElementTemplate extends IFCPlugin
Interface for plugins that wish to provide custom template for the form designer. Form templates are shown in the left drawer panel of the form designer. Users can add templates to their forms.In contrast to
catalog
plugins, a form element template may be a container that contains multiple elements.See also
IPluginFormElementTemplate
for more details.If you only want to provide static templates from the plugin's class path (e.g.
src/main/resources
, seeIPluginFormElementTemplateStatic
.A simple plugin with in-memory data (don't do this!) that provides two templates might look as follows:
import java.net.URI; import java.util.Map; import java.util.Set; import de.xima.fc.interfaces.plugin.lifecycle.IPluginInitializeData; import de.xima.fc.interfaces.plugin.lifecycle.IPluginShutdownData; import de.xima.fc.interfaces.plugin.param.form.IPluginFormElementTemplateParams; import de.xima.fc.interfaces.plugin.retval.form.IPluginFormElementTemplateList; import de.xima.fc.interfaces.plugin.retval.form.IPluginFormElementTemplateLoader; import de.xima.fc.plugin.exception.FCPluginException; import de.xima.fc.plugin.interfaces.form.IPluginFormElementTemplate; import de.xima.fc.plugin.models.retval.form.DefaultFormElementTemplateList; import de.xima.fc.plugin.models.retval.form.DefaultFormElementTemplateLoader; import de.xima.fc.plugin.models.retval.form.DefaultPluginFormElementTemplateDescriptor; public class DemoFormElementTemplatePlugin implements IPluginFormElementTemplate { private final static String TEMPLATE_TEXT_FIELD // = "{\"charsetName\":\"UTF-8\",\"persist\":\"...\",\"source\":{\"type\":\"clipboard\"},\"versionsNummer\":1}"; private final static String TEMPLATE_FIELD_SET // = "{\"charsetName\":\"UTF-8\",\"persist\":\"...\",\"source\":{\"type\":\"clipboard\"},\"versionsNummer\":1}"; private final static String ICON_TEXT_FIELD = "iVBORw0KGgoAAAANSUhEUgAAAOEAA..."; private final static Map<URI, String> PERSIST_JSONS = Map.of( // URI.create("inmemory:/text-field/persist"), TEMPLATE_TEXT_FIELD, // URI.create("inmemory:/field-set/persist"), TEMPLATE_FIELD_SET // ); private final static Map<URI, String> ICONS = Map.of( // URI.create("inmemory:/text-field/icon"), ICON_TEXT_FIELD // ); private volatile IPluginFormElementTemplateList templates = DefaultFormElementTemplateList.empty(); @Override public String getName() { return "demo-template"; } @Override public IPluginFormElementTemplateList getTemplateList(IPluginFormElementTemplateParams params) { return templates; } @Override public IPluginFormElementTemplateLoader getTemplateLoader() { return DefaultFormElementTemplateLoader.mapBase64(PERSIST_JSONS, ICONS); } @Override public void initialize(IPluginInitializeData initializeData) throws FCPluginException { templates = DefaultFormElementTemplateList.builder() // .addTemplates(DefaultPluginFormElementTemplateDescriptor.builder("foo") // .className("XTextField") // .name("template 1") // .description("Template with text field") // .persistJson(URI.create("inmemory:/text-field/persist")) // .tags(Set.of("my-tag")) // .icon("image/png", URI.create("inmemory:/text-field/icon")) // .build() // ) // .addTemplates(DefaultPluginFormElementTemplateDescriptor.builder("bar") // .className("XPage") // .name("template 2") // .description("template with field set") // .persistJson(URI.create("inmemory:/field-set/persist")) // .tags(Set.of("your-tag")) // .build() // ) // .build(); } @Override public void shutdown(IPluginShutdownData shutdownData) throws FCPluginException { templates = DefaultFormElementTemplateList.empty(); } }
- Since:
- 8.0.1
- Author:
- XIMA MEDIA GmbH
- See Also:
IPluginFormElementTemplateStatic
-
-
Field Summary
-
Fields inherited from interface de.xima.fc.plugin.interfaces.IFCPlugin
CONFIG_FILENAME
-
Fields inherited from interface de.xima.fc.interfaces.INamedUiElement
ATTR_DISPLAY_NAME
-
Fields inherited from interface de.xima.fc.entities.interfaces.INameProviding
ATTR_NAME, COL_NAME
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IPluginFormElementTemplateList
getTemplateList(IPluginFormElementTemplateParams params)
Finds all templates that should be made available for a given form.IPluginFormElementTemplateLoader
getTemplateLoader()
-
Methods inherited from interface de.xima.fc.plugin.interfaces.IFCPlugin
getDescription, getDescription, getDisplayName, getName, initialize, initPlugin, install, shutdown, shutdown, uninstall, validateConfigurationData
-
-
-
-
Method Detail
-
getTemplateList
IPluginFormElementTemplateList getTemplateList(IPluginFormElementTemplateParams params)
Finds all templates that should be made available for a given form.- Parameters:
params
- Parameters with the current form for which to find additional templates. Implementors may choose to ignore the parameters if the templates should be available for all forms.- Returns:
- The return value with the additional templates.
- Throws:
RuntimeException
- Any exceptions are treated as if an empty return value with no templates had been returned.
-
getTemplateLoader
IPluginFormElementTemplateLoader getTemplateLoader()
- Returns:
- The loader for retrieving the icon and persist JSON data of the templates.
-
-