Class AiConversationCard
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<com.vaadin.flow.component.card.Card>
io.jmix.aitoolsflowui.view.chathub.component.AiConversationCard
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasStyle,Serializable
public class AiConversationCard
extends com.vaadin.flow.component.Composite<com.vaadin.flow.component.card.Card>
Outlined card for a single conversation in the chat hub's recent list and
history side panel. The card body is a real link to the conversation, so it
supports opening in a new browser tab, copying the address and keyboard
activation; a plain click is handled in-app by the open handler instead of
following the link. The trash delete button is rendered only when a delete
handler is supplied (history panel); without one the card shows no delete
button.
Configure the card through the setters, then call build() to
(re)assemble its content from the current property values.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Nullable Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected @Nullable Stringprotected @Nullable Runnableprotected Stringprotected com.vaadin.flow.component.Componentprotected static final Stringprotected Runnableprotected static final Stringprotected Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbindOpenHandler(com.vaadin.flow.component.html.Anchor body, Runnable openHandler) Routes a plain click on the link to the open handler instead of letting the browser load the address.voidbuild()(Re)assembles the card content from the currently configured properties.protected com.vaadin.flow.component.html.AnchorcreateBody(com.vaadin.flow.component.Component icon, String title, String href, Runnable openHandler, @Nullable String activityDate) Stacks the title row and (optionally) the date as the link body of the card.protected com.vaadin.flow.component.card.Cardprotected com.vaadin.flow.component.html.SpancreateDate(String activityDate) protected com.vaadin.flow.component.button.ButtoncreateDeleteButton(Runnable deleteHandler, @Nullable String deleteAriaLabel) Trash button.protected com.vaadin.flow.component.orderedlayout.HorizontalLayoutcreateRow(com.vaadin.flow.component.html.Anchor body) Outer row that lets the link body grow and parks an optional delete button alongside it — outside the link, so deleting is not a click on the conversation.protected com.vaadin.flow.component.html.SpancreateTitle(String title) protected com.vaadin.flow.component.orderedlayout.HorizontalLayoutcreateTitleRow(com.vaadin.flow.component.Component icon, String title) Icon + title in one row, so the icon visually reads as a marker of the title rather than of the whole card.protected com.vaadin.flow.component.card.CardvoidsetActivityDate(@Nullable String activityDate) Sets the formatted last-activity date shown under the title; whennullthe date line is omitted.voidsetDeleteAriaLabel(@Nullable String deleteAriaLabel) Sets thearia-labelof the delete button.voidsetDeleteHandler(@Nullable Runnable deleteHandler) Sets the handler invoked by the delete button; whennullno delete button is rendered.voidSets the address the card body links to (required) — the conversation's own route.voidsetIcon(com.vaadin.flow.component.Component icon) Sets the title-row icon (required).voidsetOpenHandler(Runnable openHandler) Sets the handler invoked on a plain click on the card body (required), so that the click stays an in-app navigation instead of a page load.voidSets the conversation title (required).Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElementMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, 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.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
BASE_CN
- See Also:
-
ROW_CN
- See Also:
-
BODY_CN
- See Also:
-
TITLE_ROW_CN
- See Also:
-
ICON_CN
- See Also:
-
TITLE_CN
- See Also:
-
DATE_CN
- See Also:
-
DELETE_CN
- See Also:
-
title
-
icon
protected com.vaadin.flow.component.Component icon -
href
-
openHandler
-
activityDate
-
deleteHandler
-
deleteAriaLabel
-
-
Constructor Details
-
AiConversationCard
public AiConversationCard()
-
-
Method Details
-
initContent
protected com.vaadin.flow.component.card.Card initContent()- Overrides:
initContentin classcom.vaadin.flow.component.Composite<com.vaadin.flow.component.card.Card>
-
setIcon
public void setIcon(com.vaadin.flow.component.Component icon) Sets the title-row icon (required). Callbuild()afterwards to apply the change.- Parameters:
icon- title-row icon
-
setTitle
Sets the conversation title (required). Callbuild()afterwards to apply the change.- Parameters:
title- conversation title
-
setActivityDate
Sets the formatted last-activity date shown under the title; whennullthe date line is omitted. Callbuild()afterwards to apply the change.- Parameters:
activityDate- formatted last-activity date, ornullto omit the date line
-
setHref
Sets the address the card body links to (required) — the conversation's own route. It is what the browser uses for "open in new tab" and "copy link address"; a plain click goes tosetOpenHandler(Runnable)instead. Callbuild()afterwards to apply the change.- Parameters:
href- address of the conversation
-
setOpenHandler
Sets the handler invoked on a plain click on the card body (required), so that the click stays an in-app navigation instead of a page load. Modified and non-primary clicks are left to the browser. Callbuild()afterwards to apply the change.- Parameters:
openHandler- handler invoked on a plain click on the card body
-
setDeleteHandler
Sets the handler invoked by the delete button; whennullno delete button is rendered. Callbuild()afterwards to apply the change.- Parameters:
deleteHandler- handler invoked by the delete button, ornullto render no delete button
-
setDeleteAriaLabel
Sets thearia-labelof the delete button. Callbuild()afterwards to apply the change.- Parameters:
deleteAriaLabel-aria-labelfor the delete button, ornullfor none
-
build
public void build()(Re)assembles the card content from the currently configured properties. Call after the setters;setIcon(Component),setTitle(String),setHref(String)andsetOpenHandler(Runnable)are required and must be set beforehand. -
createBody
protected com.vaadin.flow.component.html.Anchor createBody(com.vaadin.flow.component.Component icon, String title, String href, Runnable openHandler, @Nullable String activityDate) Stacks the title row and (optionally) the date as the link body of the card. The whole body is the open-conversation hit area.- Parameters:
icon- title-row icontitle- conversation titlehref- address of the conversationopenHandler- handler invoked on a plain click on the bodyactivityDate- formatted last-activity date, ornullto omit the date line- Returns:
- the assembled card body
-
bindOpenHandler
Routes a plain click on the link to the open handler instead of letting the browser load the address. Everything else — a modified click, a middle click (which firesauxclick, notclick), the context menu — is left to the browser, which is what makes "open in new tab" and "copy link address" work.Suppressing the default action is part of the filter expression on purpose: Flow evaluates every event-data expression before it checks the filter, so
preventDefaultpassed as event data would also cancel the modified clicks that must reach the browser. The filter is evaluated once per event, so foldingpreventDefaultinto the guard cancels exactly the clicks that are handled here.- Parameters:
body- the link body of the cardopenHandler- handler invoked on a plain click
-
createTitleRow
protected com.vaadin.flow.component.orderedlayout.HorizontalLayout createTitleRow(com.vaadin.flow.component.Component icon, String title) Icon + title in one row, so the icon visually reads as a marker of the title rather than of the whole card.- Parameters:
icon- title-row icontitle- conversation title- Returns:
- the assembled title row
-
createTitle
-
createDate
-
createRow
protected com.vaadin.flow.component.orderedlayout.HorizontalLayout createRow(com.vaadin.flow.component.html.Anchor body) Outer row that lets the link body grow and parks an optional delete button alongside it — outside the link, so deleting is not a click on the conversation.- Parameters:
body- the link body of the card- Returns:
- the assembled outer row
-
createDeleteButton
@NullMarked protected com.vaadin.flow.component.button.Button createDeleteButton(Runnable deleteHandler, @Nullable String deleteAriaLabel) Trash button. Cross-theme:StyleUtility.Button.LINK_BUTTONgives the flat "tertiary-inline" look;iconanderrorare generic vaadin-button theme attributes (Lumo/Aura both honour them) — noLUMO_*variant prefixes.- Parameters:
deleteHandler- handler invoked when the button is clickeddeleteAriaLabel-aria-labelfor the button, ornullfor none- Returns:
- the assembled delete button
-
createContent
protected com.vaadin.flow.component.card.Card createContent()
-