Package Bean

Source Code of Bean.EditClientTimelineController

/*
* 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 Bean;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.extensions.model.timeline.TimelineEvent;
import org.primefaces.extensions.model.timeline.TimelineModel;

@ManagedBean 
@ViewScoped 
public class EditClientTimelineController implements Serializable
 
    private TimelineModel model; 
 
    private TimeZone timeZone = TimeZone.getTimeZone("Europe/Berlin")
 
    @PostConstruct 
    protected void initialize() { 
        model = new TimelineModel()
 
        String contextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()
 
        // Server-side dates should be in UTC. They will be converted to a local dates in UI according to provided TimeZone. 
        // Submitted local dates in UI are converted back to UTC, so that server receives all dates in UTC again. 
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"))
        cal.set(2014, Calendar.JUNE, 22, 17, 30, 0)
        model.add(new TimelineEvent("<div>RMP aberta</div><img src='" + contextPath + "/img/add.png' style='width:16px;height:16px;'>", cal.getTime()))
 
        cal.set(2014, Calendar.JUNE, 23, 23, 0, 0)
        model.add(new TimelineEvent("<div>Encaminhado p/ RD</div><img src='" + contextPath 
                                    + "/img/user_go.png' style='width:16px;height:16px;'>"
                                    cal.getTime()))
 
        // read-only event 
        cal.set(2014, Calendar.JUNE, 24, 21, 45, 0)
        model.add(new TimelineEvent("<div>Encaminhado Setor Destino</div><img src='" + contextPath 
                                    + "/img/arrow_right.png' style='width:16px;height:16px;'>", cal.getTime()
                                    false, null, "readonly"))
 
        cal.set(2014, Calendar.JUNE, 26, 0, 0, 0)
        Date startWork = cal.getTime()
        cal.set(2014, Calendar.JUNE, 2, 0, 0, 0)
        Date endWork = cal.getTime()
        model.add
            new TimelineEvent
                "<img src='" + contextPath 
                + "/resources/images/timeline/homework.png' style='width:31px;height:29px;'><span style='padding:8px'>Homework</span>"
                startWork, endWork))
 
        cal.set(2014, Calendar.JUNE, 28, 0, 0, 0)
        model.add(new TimelineEvent("<div>Plano de ação cadastrado</div><img src='" + contextPath 
                                    + "/img/script_add.png' style='width:16px;height:16px;'>", cal.getTime()))
 
        // read-only event 
        cal.set(2014, Calendar.JUNE, 31, 0, 0, 0)
        Date startReport = cal.getTime()
        cal.set(2014, Calendar.JUNE, 3, 0, 0, 0)
        Date endReport = cal.getTime()
        model.add
            new TimelineEvent
                "<img src='" + contextPath 
                + "/resources/images/timeline/report.png' style='width:32px;height:31px;'><span style='padding:8px'>Report</span>"
                startReport, endReport, false, null, "readonly"))
   
 
    public TimelineModel getModel() { 
        return model; 
   
 
    public TimeZone getTimeZone() { 
        return timeZone; 
   
 
    public void updateData(List<TimelineEvent> events) { 
        // update model 
        model.setEvents(events)
 
        FacesMessage msg = 
            new FacesMessage(FacesMessage.SEVERITY_INFO, "Timeline model has been updated"
                             events != null ? events.size() + " events available" : "0 events available")
        FacesContext.getCurrentInstance().addMessage(null, msg)
   
 
TOP

Related Classes of Bean.EditClientTimelineController

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.