<commit_before>package org.vaadin.chatbox.demo;

import org.vaadin.chatbox.SharedChat;
import org.vaadin.chatbox.ChatBox;
import org.vaadin.chatbox.client.ChatLine;
import org.vaadin.chatbox.client.ChatUser;

import com.vaadin.annotations.Push;
import com.vaadin.annotations.Title;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button.ClickEvent;

@Title("ChatBox Add-on Demo")
@SuppressWarnings("serial")
@Push
public class DemoUI extends UI {
	
	private static SharedChat chat = new SharedChat();
	static {
		chat.addLine("Welcome to chat!");
		chat.addLine("This ChatBox addon is available at http://vaadin.com/addon/chatbox");
		chat.addListener(new SentNotifier(chat, 60*1000));
	}

	@Override
	protected void init(VaadinRequest request) {
		
		
		final ChatBox chatbox = new ChatBox(chat);
		chatbox.setShowSendButton(false);
		chatbox.setSizeFull();
		
		final VerticalLayout layout = new VerticalLayout();
		
		HorizontalLayout hola = new HorizontalLayout();
		final TextField tf = new TextField("Nick:");
		Button b = new Button("Join chat");
		b.addClickListener(new ClickListener() {
			@Override
			public void buttonClick(ClickEvent event) {
				ChatUser user = ChatUser.newUser(tf.getValue());
				chatbox.setUser(user);
				chat.addLine(new ChatLine(user+" joined."));
				chatbox.focusToInputField();
			}
		});
		hola.addComponent(tf);
		hola.addComponent(b);
		hola.setComponentAlignment(b, Alignment.BOTTOM_LEFT);
		hola.setMargin(true);
		layout.addComponent(hola);
		
		layout.setSizeFull();<commit_msg>Fixed demo.<commit_after>package org.vaadin.chatbox.demo;

import org.vaadin.chatbox.SharedChat;
import org.vaadin.chatbox.ChatBox;
import org.vaadin.chatbox.client.ChatLine;
import org.vaadin.chatbox.client.ChatUser;

import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.annotations.Push;
import com.vaadin.annotations.Title;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button.ClickEvent;

@Title("ChatBox Add-on Demo")
@SuppressWarnings("serial")
@Push
@PreserveOnRefresh
public class DemoUI extends UI {
	
	// A static instance so that everybody gets the same instance of SharedChat.
	private static SharedChat chat = new SharedChat();
	static {
		chat.addLine("Welcome to chat!");
		chat.addLine("This ChatBox addon is available at http://vaadin.com/addon/chatbox");
		chat.addListener(new SentNotifier(chat, 60*1000));
	}

	@Override
	protected void init(VaadinRequest request) {
		
		final ChatBox chatbox = new ChatBox(chat);
		chatbox.setShowSendButton(false);
		chatbox.setSizeFull();
		
		final VerticalLayout layout = new VerticalLayout();
		
		HorizontalLayout hola = new HorizontalLayout();
		final TextField tf = new TextField("Nick:");
		Button b = new Button("Join chat");
		b.addClickListener(new ClickListener() {
			@Override
			public void buttonClick(ClickEvent event) {
				ChatUser user = ChatUser.newUser(tf.getValue());
				chatbox.setUser(user);
				chat.addLine(new ChatLine(user.getName()+" joined."));
				chatbox.focusToInputField();
			}
		});
		hola.addComponent(tf);
		hola.addComponent(b);
		hola.setComponentAlignment(b, Alignment.BOTTOM_LEFT);
		hola.setMargin(true);
		layout.addComponent(hola);
		
		layout.setSizeFull();
{'fraction_non_alphanumeric': 0.12152308938698353, 'fraction_numerical': 0.0032406157169862274, 'mean_word_length': 5.072131147540984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1563349', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1182, 'n_words': 245}