Package io.jmix.aichat.component.upload
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
FieldsModifier and TypeFieldDescriptionprotected @Nullable AiChat<?> protected booleanprotected @Nullable com.vaadin.flow.shared.Registrationprotected @Nullable com.vaadin.flow.shared.Registrationprotected booleanprotected @Nullable com.vaadin.flow.component.Componentprotected @Nullable com.vaadin.flow.component.Text -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable AiChat<?> @Nullable com.vaadin.flow.component.ComponentgetIcon()@Nullable StringgetText()protected booleanprotected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) protected voidprotected voidremoveOwnChild(com.vaadin.flow.dom.Element child) protected voidvoidBinds the trigger to the chat whose attachments it opens.voidsetEnabled(boolean enabled) voidsetIcon(@Nullable com.vaadin.flow.component.Component icon) Sets the trigger's icon, replacing any previous one.voidSets the trigger's label, or clears it whennull.protected voidRe-applies everything that depends on which of the label and the icon are present.protected voidprotected voidPlaces the icon according to whether a label is present.protected voidMarks an icon-only control with theicontheme, the wayButtondoes.protected voidMethods 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, whenAttachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasAriaLabel
getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledBy, setAriaLabelledByMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabledMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, bindThemeVariant, bindThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariants
-
Field Details
-
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
Sets the trigger's label, or clears it whennull. An icon-only trigger renders as a square button.- Parameters:
text- the label, ornullto clear
-
getText
- Returns:
- the trigger's label, or
nullif 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, ornullto clear
-
getIcon
public @Nullable com.vaadin.flow.component.Component getIcon()- Returns:
- the trigger's icon, or
nullif 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 theprefixslot; 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 theicontheme, the wayButtondoes. 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
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, ornullto unbind
-
getAiChat
- Returns:
- the chat this trigger is bound to, or
nullif none
-
setEnabled
public void setEnabled(boolean enabled) - Specified by:
setEnabledin interfacecom.vaadin.flow.component.HasEnabled
-
updateEffectiveEnabled
protected void updateEffectiveEnabled() -
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.vaadin.flow.component.Component
-
wireTarget
protected void wireTarget() -
pushTarget
protected void pushTarget() -
removeRegistrations
protected void removeRegistrations()
-