com.vaadin.collaborationengine.
Class CollaborationAvatarGroup
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.Composite<AvatarGroup>
-
- com.vaadin.collaborationengine.CollaborationAvatarGroup
-
All Implemented Interfaces:
AttachNotifier
,DetachNotifier
,HasElement
,HasSize
,HasStyle
,HasTheme
,Serializable
public class CollaborationAvatarGroup extends Composite<AvatarGroup> implements HasSize, HasStyle, HasTheme
Extension of the
AvatarGroup
component which integrates with theCollaborationEngine
. It updates the avatars in real time based on the other attached avatar groups connected to the same topic.Since:
1.0
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CollaborationAvatarGroup.ImageProvider
Callback for creating a stream resource with the image for a specific user.
-
Constructor Summary
Constructors Constructor Description CollaborationAvatarGroup(UserInfo localUser, String topicId)
Creates a new collaboration avatar group component with the provided local user and topic id.
-
Method Summary
All Methods Modifier and Type Method 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.
-
Methods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContent
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, scrollIntoView, set, setElement, setId, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Methods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
-
-
-
-
Constructor Detail
-
CollaborationAvatarGroup
public CollaborationAvatarGroup(UserInfo localUser, String topicId)
Creates a new collaboration avatar group component with the provided local user and topic id.
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 withsetTopic(String)
.Parameters:
localUser
- the information of the local usertopicId
- the id of the topic to connect to, ornull
to not connect the component to any topicSince:
1.0
-
-
Method Detail
-
setTopic
public void setTopic(String topicId)
Sets the topic to use with this component. The connection to the previous topic (if any) and existing avatars are removed. Connection to the new topic is opened and avatars of collaborating users in the new topic are populated to this component.
If the topic id is
null
, no avatars will be displayed.Parameters:
topicId
- the topic id to use, ornull
to not use any topicSince:
1.0
-
getMaxItemsVisible
public Integer getMaxItemsVisible()
Gets the maximum number of avatars to display, or
null
if no max has been set.Returns:
the max number of avatars
Since:
1.0
See Also:
-
setMaxItemsVisible
public void setMaxItemsVisible(Integer max)
Sets the the maximum number of avatars to display.
By default, all the avatars are displayed. When max is set, the overflowing avatars are grouped into one avatar.
Parameters:
max
- the max number of avatars, ornull
to remove the maxSince:
1.0
See Also:
-
addThemeVariants
public void addThemeVariants(AvatarGroupVariant... variants)
Adds theme variants to the avatar group component.
Parameters:
variants
- theme variants to addSince:
1.0
See Also:
-
removeThemeVariants
public void removeThemeVariants(AvatarGroupVariant... variants)
Removes theme variants from the avatar group component.
Parameters:
variants
- theme variants to removeSince:
1.0
See Also:
-
getI18n
public AvatarGroup.AvatarGroupI18n getI18n()
Gets the internationalization object previously set for this component.
Note: updating the object content that is gotten from this method will not update the lang on the component if not set back using
setI18n(AvatarGroupI18n)
Returns:
the i18n object. It will be
null
, if the i18n properties haven't been set.Since:
1.0
-
setI18n
public void setI18n(AvatarGroup.AvatarGroupI18n i18n)
Sets the internationalization properties for this component.
Parameters:
i18n
- the internationalized properties, notnull
Since:
1.0
-
setImageProvider
public void setImageProvider(CollaborationAvatarGroup.ImageProvider imageProvider)
Sets an image provider callback for dynamically loading avatar images for a given user. The image can be loaded on-demand from a database or using any other source of IO streams.
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; });
Parameters:
imageProvider
- the image provider to use, ornull
to use image URLs directly from the user info objectSince:
1.0
-
getImageProvider
public CollaborationAvatarGroup.ImageProvider getImageProvider()
Gets the currently used image provider callback.
Returns:
the current image provider callback, or
null
if no callback is setSince:
1.0
See Also:
-
isOwnAvatarVisible
public boolean isOwnAvatarVisible()
Gets whether the user's own avatar is displayed in the avatar group or not.
Returns:
true
if the user's own avatar is included in the group,false
if notSince:
1.0
See Also:
-
setOwnAvatarVisible
public void setOwnAvatarVisible(boolean ownAvatarVisible)
Sets whether to display user's own avatar in the avatar group or not. The default value is
true
.To display user's own avatar separately from other users, you can set this to
false
, create a separateAvatar
component and place it anywhere you like in your view.Parameters:
ownAvatarVisible
-true
to include user's own avatar,false
to not include itSince:
1.0
-
-