Class AiUploadTrigger

java.lang.Object
com.vaadin.flow.component.Component
io.jmix.aichat.component.upload.AiUploadTrigger
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<AiUploadTrigger>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<AiUploadTrigger>, com.vaadin.flow.component.FocusNotifier<AiUploadTrigger>, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.shared.HasThemeVariant<AiUploadTriggerVariant>, Serializable

@Tag("jmix-ai-upload-trigger") @JsModule("./src/ai-chat/upload/jmix-ai-upload-trigger.js") public class AiUploadTrigger extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.shared.HasThemeVariant<AiUploadTriggerVariant>, com.vaadin.flow.component.Focusable<AiUploadTrigger>, com.vaadin.flow.component.HasAriaLabel
A client-triggered upload button. On a client-side click it opens the file picker of a referenced AiChat by clicking the chat's hidden upload button in the same user gesture, so the browser's native picker opens and the chosen file flows through the existing upload pipeline into the chat's buffer.

Used standalone, or with AiUploadTriggerVariant.MENU_ITEM inside a dropdownButton's componentItem for a menu affordance. The button auto-disables while the referenced chat's attachments are disabled.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier

    com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier

    com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected @Nullable AiChat<?>
     
    protected boolean
     
    protected @Nullable com.vaadin.flow.shared.Registration
     
    protected @Nullable com.vaadin.flow.shared.Registration
     
    protected boolean
     
    protected @Nullable com.vaadin.flow.component.Component
     
    protected @Nullable com.vaadin.flow.component.Text
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable AiChat<?>
     
    @Nullable com.vaadin.flow.component.Component
     
    @Nullable String
     
    protected boolean
     
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
     
    protected void
    onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
     
    protected void
     
    protected void
    removeOwnChild(com.vaadin.flow.dom.Element child)
     
    protected void
     
    void
    setAiChat(@Nullable AiChat<?> aiChat)
    Binds the trigger to the chat whose attachments it opens.
    void
    setEnabled(boolean enabled)
     
    void
    setIcon(@Nullable com.vaadin.flow.component.Component icon)
    Sets the trigger's icon, replacing any previous one.
    void
    setText(@Nullable String text)
    Sets the trigger's label, or clears it when null.
    protected void
    Re-applies everything that depends on which of the label and the icon are present.
    protected void
     
    protected void
    Places the icon according to whether a label is present.
    protected void
    Marks an icon-only control with the icon theme, the way Button does.
    protected void
     

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttached

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.BlurNotifier

    addBlurListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.Focusable

    addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndex

    Methods inherited from interface com.vaadin.flow.component.FocusNotifier

    addFocusListener

    Methods inherited from interface com.vaadin.flow.component.HasAriaLabel

    getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledBy, setAriaLabelledBy

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    bindEnabled, isEnabled

    Methods inherited from interface com.vaadin.flow.component.HasSize

    bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.HasTheme

    addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName

    Methods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant

    addThemeVariants, bindThemeVariant, bindThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariants
  • Field Details

    • aiChat

      protected @Nullable AiChat<?> aiChat
    • icon

      protected @Nullable com.vaadin.flow.component.Component icon
    • textNode

      protected @Nullable com.vaadin.flow.component.Text textNode
    • explicitlyEnabled

      protected boolean explicitlyEnabled
    • attachmentsAvailable

      protected boolean attachmentsAvailable
    • attachmentsEnabledRegistration

      protected @Nullable com.vaadin.flow.shared.Registration attachmentsEnabledRegistration
    • chatAttachRegistration

      protected @Nullable com.vaadin.flow.shared.Registration chatAttachRegistration
  • Constructor Details

    • AiUploadTrigger

      public AiUploadTrigger()
  • Method Details

    • setText

      public void setText(@Nullable String text)
      Sets the trigger's label, or clears it when null. An icon-only trigger renders as a square button.
      Parameters:
      text - the label, or null to clear
    • getText

      public @Nullable String getText()
      Returns:
      the trigger's label, or null if it has none
    • setIcon

      public void setIcon(@Nullable com.vaadin.flow.component.Component icon)
      Sets the trigger's icon, replacing any previous one.
      Parameters:
      icon - the icon, or null to clear
    • getIcon

      public @Nullable com.vaadin.flow.component.Component getIcon()
      Returns:
      the trigger's icon, or null if it has none
    • updateContent

      protected void updateContent()
      Re-applies everything that depends on which of the label and the icon are present.
    • updateIconSlot

      protected void updateIconSlot()
      Places the icon according to whether a label is present. Beside a label the icon sits in the prefix slot; icon-only, it moves into the default (label) slot so the empty label part collapses out of the flex flow and no inter-slot gap widens the control (the Vaadin 25 icon-in-label model).
    • updateIconTheme

      protected void updateIconTheme()
      Marks an icon-only control with the icon theme, the way Button does. The tag reuses the Vaadin button styles, and those size a label-less button by that theme alone - in Lumo it swaps the label-width padding for a square one, so without it the icon-only button renders too wide.
    • isIconOnly

      protected boolean isIconOnly()
    • removeOwnChild

      protected void removeOwnChild(com.vaadin.flow.dom.Element child)
    • setAiChat

      public void setAiChat(@Nullable AiChat<?> aiChat)
      Binds the trigger to the chat whose attachments it opens. The trigger follows that chat's attachments-enabled state, disabling itself while attachments are off.
      Parameters:
      aiChat - the chat to target, or null to unbind
    • getAiChat

      public @Nullable AiChat<?> getAiChat()
      Returns:
      the chat this trigger is bound to, or null if none
    • setEnabled

      public void setEnabled(boolean enabled)
      Specified by:
      setEnabled in interface com.vaadin.flow.component.HasEnabled
    • updateEffectiveEnabled

      protected void updateEffectiveEnabled()
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • onDetach

      protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
      Overrides:
      onDetach in class com.vaadin.flow.component.Component
    • wireTarget

      protected void wireTarget()
    • pushTarget

      protected void pushTarget()
    • removeRegistrations

      protected void removeRegistrations()