Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.squadd.chat; import com.squadd.javaBeans.UserInfoBean; import com.vaadin.event.MouseEvents; import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.ui.FormLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; /** * * @author Glebao */ public class UserInfoFace { private UserInfoBean user; private DialogController control; private HorizontalLayout footer; public UserInfoFace(UserInfoBean user, DialogController control, HorizontalLayout footer) { this.user = user; this.control = control; this.footer = footer; } public void setUserTo(UserInfoBean user) { this.user = user; } private ClickListener del = new ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { control.clearChat(); } }; private ClickListener upd = new ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { control.clearChat(); control.setUserTo(user); if (!footer.isVisible()) { footer.setVisible(true); } control.updateChatLog(11); } }; public HorizontalLayout getUserLook(UserInfoBean user) { HorizontalLayout contactLine = new HorizontalLayout(); Label nameLabel = new Label(user.getName()); contactLine.addComponent(nameLabel); return contactLine; } public Panel getUserPanel() { Panel contactPanel = new Panel(); FormLayout contactLine = new FormLayout(); contactPanel.addClickListener(upd); Label nameLabel = new Label(user.getName()); nameLabel.setStyleName("userPanel"); contactLine.addComponent(nameLabel); contactPanel.setContent(contactLine); contactPanel.setId(user.getId().toString()); return contactPanel; //contactsContent.addComponent(look); //contactsPanel.setContent(contactsContent); } public Panel getUserPanel(Integer userId) { Panel contactPanel = new Panel(); FormLayout contactLine = new FormLayout(); user = new UserInfoBean(); user.setId(userId); user.setName("id" + userId); contactPanel.addClickListener(upd); Label nameLabel = new Label(user.getName()); nameLabel.setStyleName("userPanel"); contactLine.addComponent(nameLabel); contactPanel.setContent(contactLine); contactPanel.setId(userId.toString()); return contactPanel; //contactsContent.addComponent(look); //contactsPanel.setContent(contactsContent); } }