Class StudioAiChatPreviewLoader

java.lang.Object
io.jmix.aichat.kit.meta.loader.StudioAiChatPreviewLoader
All Implemented Interfaces:
StudioPreviewComponentLoader

public class StudioAiChatPreviewLoader extends Object implements StudioPreviewComponentLoader
Studio preview loader for the AI chat components.

The components themselves are out of reach here: every one of them is built on the Spring-coupled io.jmix.flowui and this loader runs on Studio's spring-free preview classloader, which carries nothing but flowui-kit and this module. Plain-Vaadin stubs of the matching shape are used instead, so the designer shows a box of the right kind, in the right place, at the declared size.

Source loaders: io.jmix.aichat.xml.layout.loader.AiChatLoader and its siblings in that package.

  • Field Details

  • Constructor Details

    • StudioAiChatPreviewLoader

      public StudioAiChatPreviewLoader()
  • Method Details

    • isSupported

      public boolean isSupported(org.dom4j.Element element)
      Description copied from interface: StudioPreviewComponentLoader
      Define the element that this loader can load.
      Specified by:
      isSupported in interface StudioPreviewComponentLoader
    • load

      public @Nullable com.vaadin.flow.component.Component load(org.dom4j.Element componentElement, org.dom4j.Element viewElement)
      Description copied from interface: StudioPreviewComponentLoader
      Create vaadin component from component xml element.
      Specified by:
      load in interface StudioPreviewComponentLoader
      Parameters:
      componentElement - xml element of component
      viewElement - xml element of view containing componentElement
      See Also:
      • Element
    • load

      public @Nullable com.vaadin.flow.component.Component load(org.dom4j.Element componentElement, org.dom4j.Element viewElement, StudioPreviewEnvironment environment)
      Description copied from interface: StudioPreviewComponentLoader
      Create vaadin component from component xml element, with access to Studio-resolved context (e.g. localized messages, entity property captions).
      Specified by:
      load in interface StudioPreviewComponentLoader
      Parameters:
      componentElement - xml element of component
      viewElement - xml element of view containing componentElement
      environment - Studio-side environment; StudioPreviewEnvironment.NOOP when unavailable
      See Also:
      • Element
    • loadCode

      protected void loadCode(com.vaadin.flow.component.html.Pre codeBlock, org.dom4j.Element element, StudioPreviewEnvironment environment)
      Mirrors AiCodeBlockLoader#loadCode: the nested code element wins over the code attribute. Where the runtime rejects a present-but-blank element, the preview keeps the empty block instead — a descriptor being edited is blank half the time.
      Parameters:
      codeBlock - the preview stub to load into
      element - the descriptor element being previewed
      environment - the preview environment resolving localized strings
    • loadInputPlaceholder

      protected void loadInputPlaceholder(com.vaadin.flow.component.textfield.TextArea textArea, org.dom4j.Element element, StudioPreviewEnvironment environment)
      Carries the placeholder declared in the nested i18n element onto the composer stub. The field pass above finds nothing to apply on its own: the runtime component reads its placeholder from AiMessageInputI18n, and the schema has no placeholder attribute on the component element for loadFieldAttributes to pick up.

      The chat's i18n reaches a placeholder too, through its nested messageInput element, but the chat's stub is a VerticalLayout with no composer inside, so there is nothing there to put it on.

      Parameters:
      textArea - the composer stub to load into
      element - the descriptor element being previewed
      environment - the preview environment resolving localized strings
    • loadUploadTrigger

      protected void loadUploadTrigger(com.vaadin.flow.component.button.Button button, org.dom4j.Element element, StudioPreviewEnvironment environment)
      Loads the trigger's own text and icon. Both are carried because an upload trigger routinely declares only one of them, and a button with neither is an empty sliver.

      The icon is parsed defensively: ComponentUtils#parseIcon throws on a name that is not a VaadinIcon constant or a two-part set:name, which a half-typed icon="PAPERCLI" is. Dropping the icon and keeping the button follows the preview's own rule — render what you can and stay silent.

      Parameters:
      button - the preview stub to load into
      element - the descriptor element being previewed
      environment - the preview environment resolving localized strings