All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fi.evolver.ai.vaadin.component.ChatAvatarTextItem Maven / Gradle / Ivy

There is a newer version: 1.5.5
Show newest version
package fi.evolver.ai.vaadin.component;

import java.io.Serial;
import java.time.LocalDateTime;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.HasText.WhiteSpace;
import com.vaadin.flow.component.Html;
import com.vaadin.flow.component.html.Div;

import fi.evolver.ai.vaadin.util.ChatUtils;

public class ChatAvatarTextItem extends ChatAvatarItem {
	@Serial
	private static final long serialVersionUID = 1L;

	public ChatAvatarTextItem(LocalDateTime sendTime, String message, String user, boolean convertToHtml) {
		super(sendTime, user, generateMessage(message, convertToHtml));
	}

	protected static Component generateMessage(String message, boolean convertToHtml) {
		if (convertToHtml)
			return new Html(ChatUtils.convertToHtml(message));

		Div div = new Div(message);
		div.setWhiteSpace(WhiteSpace.PRE_WRAP);
		return div;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy