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. Clicking the card body opens the conversation. 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 static final Stringprotected static final Stringprotected @Nullable Stringprotected static final Stringprotected static final Stringprotected @Nullable Stringprotected @Nullable Runnableprotected 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 TypeMethodDescriptionvoidbuild()(Re)assembles the card content from the currently configured properties.protected com.vaadin.flow.component.orderedlayout.VerticalLayoutcreateBody(com.vaadin.flow.component.Component icon, String title, Runnable openHandler, @Nullable String createdDate) Stacks the title row and (optionally) the date as the clickable body of the card.protected com.vaadin.flow.component.card.Cardprotected com.vaadin.flow.component.html.SpancreateDate(String createdDate) 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.orderedlayout.VerticalLayout body) Outer row that lets the clickable body grow and parks an optional delete button alongside it.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.CardvoidsetCreatedDate(@Nullable String createdDate) Sets the formatted creation date; 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.voidsetIcon(com.vaadin.flow.component.Component icon) Sets the title-row icon (required).voidsetOpenHandler(Runnable openHandler) Sets the handler invoked when the card body is clicked (required).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, setVisibleMethods 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 -
openHandler
-
createdDate
-
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
-
setCreatedDate
Sets the formatted creation date; whennullthe date line is omitted. Callbuild()afterwards to apply the change.- Parameters:
createdDate- formatted creation date, ornullto omit the date line
-
setOpenHandler
Sets the handler invoked when the card body is clicked (required). Callbuild()afterwards to apply the change.- Parameters:
openHandler- handler invoked when the card body is clicked
-
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)andsetOpenHandler(Runnable)are required and must be set beforehand. -
createBody
protected com.vaadin.flow.component.orderedlayout.VerticalLayout createBody(com.vaadin.flow.component.Component icon, String title, Runnable openHandler, @Nullable String createdDate) Stacks the title row and (optionally) the date as the clickable body of the card. The whole body is the open-conversation hit area.- Parameters:
icon- title-row icontitle- conversation titleopenHandler- handler invoked when the body is clickedcreatedDate- formatted creation date, ornullto omit the date line- Returns:
- the assembled card body
-
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.orderedlayout.VerticalLayout body) Outer row that lets the clickable body grow and parks an optional delete button alongside it.- Parameters:
body- the clickable card body- 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()
-