public class CollaborationAvatarGroup extends Composite<AvatarGroup> implements HasSize, HasStyle, HasTheme
AvatarGroup
component which integrates with the
CollaborationEngine
. It updates the avatars in real time based on the
other attached avatar groups connected to the same topic.Modifier and Type | Class and Description |
---|---|
static interface |
CollaborationAvatarGroup.ImageProvider
Callback for creating a stream resource with the image for a specific
user.
|
Constructor and Description |
---|
CollaborationAvatarGroup(UserInfo localUser,
String topicId)
Creates a new collaboration avatar group component with the provided
local user and topic id.
|
Modifier and Type | Method and Description |
---|---|
void |
addThemeVariants(AvatarGroupVariant... variants)
Adds theme variants to the avatar group component.
|
AvatarGroup.AvatarGroupI18n |
getI18n()
Gets the internationalization object previously set for this component.
|
CollaborationAvatarGroup.ImageProvider |
getImageProvider()
Gets the currently used image provider callback.
|
Integer |
getMaxItemsVisible()
Gets the maximum number of avatars to display, or
null if no max
has been set. |
boolean |
isOwnAvatarVisible()
Gets whether the user's own avatar is displayed in the avatar group or
not.
|
void |
removeThemeVariants(AvatarGroupVariant... variants)
Removes theme variants from the avatar group component.
|
void |
setI18n(AvatarGroup.AvatarGroupI18n i18n)
Sets the internationalization properties for this component.
|
void |
setImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider)
Sets an image provider callback for dynamically loading avatar images for
a given user.
|
void |
setMaxItemsVisible(Integer max)
Sets the the maximum number of avatars to display.
|
void |
setOwnAvatarVisible(boolean ownAvatarVisible)
Sets whether to display user's own avatar in the avatar group or not.
|
void |
setTopic(String topicId)
Sets the topic to use with this component.
|
getChildren, getContent, getElement, initContent
addListener, fireEvent, from, get, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
getElement
addAttachListener
addDetachListener
public CollaborationAvatarGroup(UserInfo localUser, String topicId)
The provided user information is used in the local user's avatar which is displayed to the other users.
Whenever another collaboration avatar group with the same topic id is attached to another user's UI, this avatar group is updated to include an avatar with that user's information.
If a null
topic id is provided, the component won't display any
avatars, until connecting to a non-null topic with
setTopic(String)
.
localUser
- the information of the local usertopicId
- the id of the topic to connect to, or null
to not
connect the component to any topicpublic void setTopic(String topicId)
If the topic id is null
, no avatars will be displayed.
topicId
- the topic id to use, or null
to not use any topicpublic Integer getMaxItemsVisible()
null
if no max
has been set.AvatarGroup.getMaxItemsVisible()
public void setMaxItemsVisible(Integer max)
By default, all the avatars are displayed. When max is set, the overflowing avatars are grouped into one avatar.
max
- the max number of avatars, or null
to remove the maxAvatarGroup.setMaxItemsVisible(Integer)
public void addThemeVariants(AvatarGroupVariant... variants)
variants
- theme variants to addAvatarGroup.addThemeVariants(AvatarGroupVariant...)
public void removeThemeVariants(AvatarGroupVariant... variants)
variants
- theme variants to removeAvatarGroup.removeThemeVariants(AvatarGroupVariant...)
public AvatarGroup.AvatarGroupI18n getI18n()
Note: updating the object content that is gotten from this method will
not update the lang on the component if not set back using
CollaborationAvatarGroup#setI18n(AvatarGroupI18n)
null
, if the i18n
properties haven't been set.public void setI18n(AvatarGroup.AvatarGroupI18n i18n)
i18n
- the internationalized properties, not null
public void setImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider)
If no image callback is defined, then the image URL defined by
UserInfo.getImage()
is directly passed to the browser. This means
that avatar images need to be available as static files or served
dynamically from a custom servlet. This is the default.
Usage example:
collaborationAvatarGroup.setImageProvider(userInfo -> { StreamResource streamResource = new StreamResource( "avatar_" + userInfo.getId(), () -> { User userEntity = userRepository .findById(userInfo.getId()); byte[] profilePicture = userEntity.getProfilePicture(); return new ByteArrayInputStream(profilePicture); }); streamResource.setContentType("image/png"); return streamResource; });
imageProvider
- the image provider to use, or null
to use image
URLs directly from the user info objectpublic CollaborationAvatarGroup.ImageProvider getImageProvider()
null
if no
callback is setsetImageProvider(ImageProvider)
public boolean isOwnAvatarVisible()
true
if the user's own avatar is included in the group,
false
if notsetOwnAvatarVisible(boolean)
public void setOwnAvatarVisible(boolean ownAvatarVisible)
true
.
To display user's own avatar separately from other users, you can set
this to false
, create a separate Avatar
component and
place it anywhere you like in your view.
ownAvatarVisible
- true
to include user's own avatar, false
to
not include itCopyright © 2022. All rights reserved.