Package sk.vrto.web.views

Source Code of sk.vrto.web.views.ContactView

package sk.vrto.web.views;

import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.PopupView;
import sk.vrto.domain.Contact;
import sk.vrto.web.presenters.ContactPresenter;

public class ContactView extends HorizontalLayout {

    private Contact contact;
    transient private final ContactPresenter presenter;
    private ContactViewPopup viewPopup;


    public ContactView(ContactPresenter presenter) {
        this.presenter = presenter;
        this.presenter.setView(this);
    }

    public void init() {
        addStyleName("contact");
        setWidth("120px");

        viewPopup = new ContactViewPopup(contact, presenter);
        PopupView popupView = new PopupView(intelligentName(contact.getName()), viewPopup);
        popupView.setStyleName("contact-font");
        popupView.setHideOnMouseOut(false);
        popupView.setWidth("100%");
        addComponent(popupView);
    }

    public ContactViewPopup getViewPopup() {
        return viewPopup;
    }

    private String intelligentName(String name) {
        if (15 < name.length()) {
            return name.substring(0, 15) + "...";
        }
        return name;
    }

    public Contact getContact() {
        return contact;
    }

    public void setContact(Contact contact) {
        this.contact = contact;
    }

}
TOP

Related Classes of sk.vrto.web.views.ContactView

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.