Package sk.vrto.web.presenters

Source Code of sk.vrto.web.presenters.EmailPresenter

package sk.vrto.web.presenters;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import sk.vrto.domain.Email;
import sk.vrto.service.dao.EmailRepository;
import sk.vrto.web.base.Presenter;
import sk.vrto.web.events.EmailRemoved;
import sk.vrto.web.events.UiEmailEvent;
import sk.vrto.web.views.EmailView;

@Component
@Scope("prototype")
public class EmailPresenter extends Presenter<EmailView> {

    private final EmailRepository emailRepository;

    /**
     * @param emailRepository Repository for accesing emails
     */
    @Autowired
    public EmailPresenter(@Qualifier("dao.emailRepository") EmailRepository emailRepository) {
        this.emailRepository = emailRepository;
    }

    /**
     * Fires {@link UiEmailEvent.FwReAddWindowEvent}
     * @param email Email to forward
     */
    public void forward(Email email) {
        eventBus.post(new UiEmailEvent.FwReAddWindowEvent(email,
                UiEmailEvent.FwReAddWindowEvent.FwRe.FORWARD));
    }

    /**
     * Fires {@link UiEmailEvent.FwReAddWindowEvent}
     * @param email Email to reply to
     */
    public void reply(Email email) {
        eventBus.post(new UiEmailEvent.FwReAddWindowEvent(email,
                UiEmailEvent.FwReAddWindowEvent.FwRe.REPLY));
    }

    /**
     * Removes email from the repository and fires {@link EmailRemoved} event.
     * @param email Email to remove.
     */
    public void deleteMail(Email email) {
        emailRepository.delete(email);
        eventBus.post(new EmailRemoved(view));
    }
}
TOP

Related Classes of sk.vrto.web.presenters.EmailPresenter

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.