From 76d20b178e75764f935d94dd746918b57182471b Mon Sep 17 00:00:00 2001 From: Martin Lopez Date: Tue, 17 Sep 2024 18:45:16 -0300 Subject: [PATCH] docs: add missing javadocs --- .../addons/chatassistant/ChatAssistant.java | 69 ++++++++++++------- .../addons/chatassistant/ChatMessage.java | 15 ++-- 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistant.java b/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistant.java index e27b225..639972b 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistant.java +++ b/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatAssistant.java @@ -68,10 +68,18 @@ public class ChatAssistant extends Div { private boolean minimized = false; private Registration defaultSubmitListenerRegistration; + /** + * Default constructor. Creates a ChatAssistant with no messages. + */ public ChatAssistant() { this(new ArrayList<>()); } + /** + * Creates a ChatAssistant with the given list of messages. + * + * @param messages the list of messages + */ public ChatAssistant(List messages) { this.messages = messages; content.getElement().setAttribute("slot", "content"); @@ -115,16 +123,18 @@ private void handleClick(DomEvent event) { } /** - * Sets the data provider of the internal VirtualList - * @param dataProvider + * Sets the data provider of the internal VirtualList. + * + * @param dataProvider the data provider to be used */ public void setDataProvider(DataProvider dataProvider) { content.setDataProvider(dataProvider); } /** - * Uses the provided string as the text shown over the message input to indicate that someone is typing - * @param whoIsTyping + * Uses the provided string as the text shown over the message input to indicate that someone is typing. + * + * @param whoIsTyping string to be shown as an indication of someone typing */ public void setWhoIsTyping(String whoIsTyping) { this.whoIsTyping.setText(whoIsTyping); @@ -132,7 +142,8 @@ public void setWhoIsTyping(String whoIsTyping) { } /** - * Returns the current text shown over the message input to indicate that someone is typing + * Returns the current text shown over the message input to indicate that someone is typing. + * * @return the current text or null if not configured */ public String getWhoIsTyping() { @@ -140,7 +151,7 @@ public String getWhoIsTyping() { } /** - * Clears the text shown over the message input to indicate that someone is typing + * Clears the text shown over the message input to indicate that someone is typing. */ public void clearWhoIsTyping() { this.whoIsTyping.setText(null); @@ -148,9 +159,10 @@ public void clearWhoIsTyping() { } /** - * Sets the SubmitListener that will be notified when the user submits a message on the underlying messageInput - * @param listener - * @return + * Sets the SubmitListener that will be notified when the user submits a message on the underlying messageInput. + * + * @param listener the listener that will be notified when the SubmitEvent is fired + * @return registration for removal of the listener */ public Registration setSubmitListener(ComponentEventListener listener) { defaultSubmitListenerRegistration.remove(); @@ -198,9 +210,10 @@ private void refreshContent() { } /** - * Sends a message programmatically to the component + * Sends a message programmatically to the component. Should not be used when a custom + * DataProvider is used. Instead just refresh the custom DataProvider. * - * @param message + * @param message the message to be sent programmatically */ public void sendMessage(Message message) { messages.add(message); @@ -209,15 +222,18 @@ public void sendMessage(Message message) { } /** - * Updates a message - * @param message + * Updates a previously entered message. + * + * @param message the message to be updated */ public void updateMessage(Message message) { this.content.getDataProvider().refreshItem(message); } /** - * Shows or hides chat assistant + * Shows or hides chat window. + * + * @param minimized true for hiding the chat window and false for displaying it */ public void setMinimized(boolean minimized) { if (!minimized && this.minimized) { @@ -230,16 +246,18 @@ public void setMinimized(boolean minimized) { } /** - * Returns true if the chat assistant is minimized false otherwise - * @return + * Returns the visibility of the chat window. + * + * @return true if the chat window is minimized false otherwise */ public boolean isMinimized() { return minimized; } /** - * Sets a component as a replacement for the header of the chat - * @param component + * Allows changing the header of the chat window. + * + * @param component to be used as a replacement for the header */ public void setHeaderComponent(Component component) { if (headerComponent!=null) { @@ -253,16 +271,18 @@ public void setHeaderComponent(Component component) { } /** - * Returns the current component configured as a replacement for the header of the chat - * @return + * Returns the current component configured as the header of the chat window. + * + * @return component used as the header of the chat window */ public Component getHeaderComponent() { return headerComponent; } /** - * Sets a Vaadin component as a replacement for the footer of the chat - * @param component + * Allows changing the footer of the chat window. + * + * @param component to be used as a replacement for the footer */ public void setFooterComponent(Component component) { this.footerComponent = component; @@ -272,8 +292,9 @@ public void setFooterComponent(Component component) { } /** - * Returns the current Vaadin component configured as a replacement for the footer of the chat - * @return + * Returns the current component configured as the footer of the chat window. + * + * @return component used as the footer of the chat window */ public Component getFooterComponent() { return footerComponent; diff --git a/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatMessage.java b/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatMessage.java index ad1f761..408776c 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatMessage.java +++ b/src/main/java/com/flowingcode/vaadin/addons/chatassistant/ChatMessage.java @@ -44,13 +44,19 @@ public class ChatMessage extends Component implements HasComponents { private Message message; private Div loader; + /** + * Creates a new ChatMessage based on the supplied message. + * + * @param message message used to populate the ChatMessage instance + */ public ChatMessage(Message message) { setMessage(message); } /** - * Updates the component by setting the current underlying message - * @param message + * Updates the component by setting the current underlying message. + * + * @param message message used to populate the ChatMessage instance */ public void setMessage(Message message) { this.message = message; @@ -82,8 +88,9 @@ private void updateLoadingState(Message message) { } /** - * Returns the underlying message - * @return + * Returns the underlying message. + * + * @return the message object used to populate this ChatMessage */ public Message getMessage() { return message;