Class MessageListItem
- All Implemented Interfaces:
Serializable
MessageList
.- Author:
- Vaadin Ltd.
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates an empty message list item.MessageListItem
(String text) Creates a message list item with the provided text, which will be displayed as plain text in the message body.MessageListItem
(String text, Instant time, String userName) Creates a message list item with the provided text content, time and user name.MessageListItem
(String text, Instant time, String userName, String userImage) Creates a message list item with the provided text content, time and user name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addClassNames
(String... classNames) Adds one or more class names to this item.void
addThemeNames
(String... themeNames) Adds one or more theme names to this message.getText()
Gets the text content of the message.getTime()
Gets the time of sending the message.Gets the abbreviation of the message sender.Gets the color index of the message sender.Gets the URL to the message sender's image.Gets the image resource of the message sender's avatar.Gets the user name of the message sender.boolean
hasClassName
(String className) Checks if the message has the given class name.boolean
hasThemeName
(String themeName) Checks if the message has the given theme name.void
removeClassNames
(String... classNames) Removes one or more class names from this item.void
removeThemeNames
(String... themeNames) Removes one or more theme names from this message.void
Sets the text content of the message.void
Sets the time of sending the message.void
setUserAbbreviation
(String userAbbreviation) Sets the abbreviation of the message sender.void
setUserColorIndex
(Integer userColorIndex) Sets the color index of the message sender.void
setUserImage
(String userImage) Sets the URL to the message sender's image.void
setUserImageResource
(AbstractStreamResource resource) Sets the image for the message sender's avatar.void
setUserName
(String userName) Sets the user name of the message sender.
-
Constructor Details
-
MessageListItem
public MessageListItem()Creates an empty message list item. Use the setter methods to configure what will be displayed in the message. -
MessageListItem
Creates a message list item with the provided text, which will be displayed as plain text in the message body.- Parameters:
text
- the text content of the message- See Also:
-
MessageListItem
Creates a message list item with the provided text content, time and user name.The text will be rendered as plain text in the message body. The time and user name will also be displayed in the message component. The user name is also used in the message's avatar.
- Parameters:
text
- the text content of the messagetime
- the time of sending the messageuserName
- the user name of the message sender- See Also:
-
MessageListItem
Creates a message list item with the provided text content, time and user name.The text will be rendered as plain text in the message body. The time and user name will also be displayed in the message component. The user image will be displayed in an avatar in the message.
- Parameters:
text
- the text content of the messagetime
- the time of sending the messageuserName
- the user name of the message senderuserImage
- the URL of the message sender's image- See Also:
-
-
Method Details
-
getText
Gets the text content of the message.- Returns:
- the message's text content, or
null
if none is set
-
setText
Sets the text content of the message. It will be rendered as plain text in the message body.- Parameters:
text
- the message's text content to set, ornull
to remove the content
-
getTime
Gets the time of sending the message.- Returns:
- the time of the message, or
null
if none is set
-
setTime
Sets the time of sending the message. It will be displayed in the message component.- Parameters:
time
- the time of the message to set, ornull
to remove the time
-
getUserName
Gets the user name of the message sender.- Returns:
- the message sender's user name, or
null
if none is set
-
setUserName
Sets the user name of the message sender. It will be displayed in the message component and used in the message's avatar.In the avatar, the user name is presented in a tooltip on hover. It will be also used to generate an abbreviation that is displayed as the avatar content, when no
setUserImage(String)
image} orsetUserAbbreviation(String)
abbreviation} is explicitly defined.- Parameters:
userName
- the message sender's user name, ornull
to remove the user name
-
getUserAbbreviation
Gets the abbreviation of the message sender.- Returns:
- the message sender's abbreviation, or
null
if none is set
-
setUserAbbreviation
Sets the abbreviation of the message sender. It will be used in the message's avatar, when nosetUserImage(String)
image} is defined.- Parameters:
userAbbreviation
- the message sender's abbreviation, ornull
to remove the abbreviation
-
getUserImage
Gets the URL to the message sender's image.If the image is set as a stream resource with
setUserImageResource(AbstractStreamResource)
, this method will return a URL that is generated for that resource.- Returns:
- the URL to the message sender's image, or
null
if none is set
-
setUserImage
Sets the URL to the message sender's image. The image be displayed in an avatar in the message component.Setting the image with this method resets the image resource provided with
setUserImageResource(AbstractStreamResource)
- Parameters:
userImage
- the URL to the message sender's image, ornull
to remove the image- See Also:
-
getUserColorIndex
Gets the color index of the message sender.- Returns:
- the color index, or
null
if none is set
-
setUserColorIndex
Sets the color index of the message sender. It's used in the avatar that is displayed in the message component.The color index defines which color will be used for the border of the avatar. Color index N applies CSS variable
--vaadin-user-color-N
to the border.- Parameters:
userColorIndex
- the color index to set, ornull
to remove it
-
addThemeNames
Adds one or more theme names to this message. Multiple theme names can be specified by using multiple parameters.- Parameters:
themeNames
- the theme name or theme names to be added to the message
-
removeThemeNames
Removes one or more theme names from this message. Multiple theme names can be specified by using multiple parameters.- Parameters:
themeNames
- the theme name or theme names to be removed from the message
-
hasThemeName
Checks if the message has the given theme name.- Parameters:
themeName
- the theme name to check for- Returns:
true
if the message has the given theme name,false
otherwise
-
addClassNames
Adds one or more class names to this item. Multiple class names can be specified by using multiple parameters.- Parameters:
classNames
- the class name or class names to be added to the item
-
removeClassNames
Removes one or more class names from this item. Multiple class names can be specified by using multiple parameters.- Parameters:
classNames
- the class name or class names to be removed from the item
-
hasClassName
Checks if the message has the given class name.- Parameters:
className
- the class name to check for- Returns:
true
if the message has the given class name,false
otherwise
-
getUserImageResource
Gets the image resource of the message sender's avatar.- Returns:
- the image resource value, or
null
if the image has not been set, or if the image is set with a URL by usingsetUserImage(String)
-
setUserImageResource
Sets the image for the message sender's avatar.Setting the image as a resource with this method overrides the image URL set with
setUserImage(String)
.- Parameters:
resource
- the image resource, ornull
to remove the resource- See Also:
-