Interface IPluginFormDesignerResource

  • All Superinterfaces:
    IFCPlugin, INamedUiElement, INameProviding, ITransferable, Serializable

    public interface IPluginFormDesignerResource
    extends IFCPlugin
    Interface for plugins to add additional resources (CSS or JavaScript) to the form designer. Such resources can also be added via form widget plugins, but that requires creating a new widget. This plugin lets you add resources without having to create a widget.
    Since:
    8.1.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • getCssResource

        default IResourceDescriptor getCssResource​(IPluginFormDesignerResourceGetResourceParams params)
                                            throws URISyntaxException
        Returns the resource descriptors for additional CSS files that are loaded when the form designer is opened. Each file should contain additional styles required for the designer UI, such as for custom property editors.

        Styles from the CSS file are not available within the form (as the form preview in the designer is rendered in a separate shadow root). Use IPluginFormResource for styles that should apply to the form in general; or getCssResourceForForm for styles that should only apply to the form when opened in the form designer.

        The default implementation returns null, i.e. no additional resource.

        The returned resource may get cached with the IResourceDescriptor.getAbsoluteUri(). We recommend you add e.g. the version of the plugin as a cache parameter to the URI.

        You need to return a resource descriptor. For example, if the resources exists as a class path resource, you can use:

         return List.of(UrlResourceDescriptor.forClasspathResource(getClass(), "path/to/dir/style.css", UTF_8));
         
        Parameters:
        params - Parameters for obtaining the resource. The resource content should depend only on these parameters, as it may be cached.
        Returns:
        The resource descriptors for the CSS files to include in the form designer UI context.
        Throws:
        URISyntaxException - When the resource descriptor could not be created due to an invalid URL.
      • getCssResourceForForm

        default IResourceDescriptor getCssResourceForForm​(IPluginFormDesignerResourceGetResourceParams params)
                                                   throws URISyntaxException
        Returns the resource descriptors for additional CSS files that are loaded when the form designer is opened. Each file should contain additional styles required for the form preview within the designer, such as for custom form elements.

        Styles from the CSS file are not available within the form designer UI (as the form preview in the designer is rendered in a separate shadow root). Use getCssResource for styles that should apply to the form designer UI (such as styles for custom property editors)

        The default implementation returns null, i.e. no additional resource.

        The returned resource may get cached with the IResourceDescriptor.getAbsoluteUri(). We recommend you add e.g. the version of the plugin as a cache parameter to the URI.

        You need to return a resource descriptor. For example, if the resources exists as a class path resource, you can use:

         return List.of(UrlResourceDescriptor.forClasspathResource(getClass(), "path/to/dir/style.css", UTF_8));
         
        Parameters:
        params - Parameters for obtaining the resource. The resource content should depend only on these parameters, as it may be cached.
        Returns:
        The resource descriptors for the CSS files to include in the form preview context of the form designer.
        Throws:
        URISyntaxException - When the resource descriptor could not be created due to an invalid URL.
      • getJavaScriptResource

        default IResourceDescriptor getJavaScriptResource​(IPluginFormDesignerResourceGetResourceParams params)
                                                   throws URISyntaxException
        Returns the resource descriptors for additional JavaScript files that are loaded when the form designer is opened. These file can contain additional the setup logic for the form designer, such as adding custom properties or editors.

        The default implementation returns null, i.e. no additional resource.

        See the node module fc-form-designer (available via the custom XIMA npm registry) for more details regarding the contents of the JavaScript file. That module contains the TypeScript declaration files with the client side API.

        The returned resource may get cached with the IResourceDescriptor.getAbsoluteUri(). Use getJavaScriptRuntimeData if you need to provide custom data to the client-side JavaScript, such as a list of available entities. We recommend you add e.g. the version of the plugin as a cache parameter to the URI.

        You need to return a resource descriptor. For example, if the resources exists as a class path resource, you can use:

         return UrlResourceDescriptor.forClasspathResource(getClass(), "path/to/dir/script.js", UTF_8);
         
        Parameters:
        params - Parameters for obtaining the resource. The resource content should depend only on these parameters, as it may be cached.
        Returns:
        The resource descriptors for the JavacScript files to include in the form designer.
        Throws:
        URISyntaxException - When the resource descriptor could not be created due to an invalid URL.
      • getJavaScriptRuntimeData

        default Map<String,​Object> getJavaScriptRuntimeData​(IPluginFormDesignerResourceGetRuntimeDataParams params)
        This method can be used to provide additional data to the client-side JavaScript code for the widget.

        The returned data is stringified as a JSON object and made available to the JavaScript code via window.Designer.instance().config.pluginData['plugin-name'], where plugin-name is IFCPlugin.getName().

        Parameters:
        params - Parameters with details about the current form designer context, such as the opened form.
        Returns:
        Additional data made available to the JavaScript code. Can be a JSONObject.
        Throws:
        RuntimeException - Exceptions are caught, logged, and ignored otherwise.