Bug con com.vaadin.ui.Calendar

Hello, Im creating a widget for an app that use the calendar, but the com.vaadin.ui.Calendar is behaving weird, doesn’t show the current time, and I dont think is problem of the timezone or the locale. The bug is that the calendar is displacing the events at diferents times that goes from 90 minutes to 2 hours. ex:

event 1 start at 12:30 is displaced at 13:30 (1 hour aprox)
event 2 start at 18:30 is displaced at 20:30 (2 hour aprox)

Also this happens with the range select, I selected a event to start at 10:30 am and show it start at 11 am.

This happens on all the webbrowser I tested, I really dont know what is wrong.
My current version of vaadin is 7.6.8 however I try to update to the latest (7.7.3) to see if the bug was fixed but nothing happened.

This is my code:

I have a combo with diferents calendar, so when a calendar is selected I reload the calendar and event provider.

public void reloadCalendarWidget(){
Date today = getToday();
Date start = resolveFirstDateOfWeek(today, getCurrentDate());
Date end = resolveLastDateOfWeek(today, getCurrentDate());
this.dataSource = new OklexEventProvider(okCalendar.getCalendar_id()); //update events 
this.verticalLayout.removeAllComponents();
this.vaadinCalendar = null;
this.vaadinCalendar = new Calendar(dataSource);
//this.vaadinCalendar.setLocale(Locale.US);  
//this.vaadinCalendar.setTimeZone(TimeZone.get("America/Mexico_City"));
this.vaadinCalendar.setStartDate(start);
this.vaadinCalendar.setEndDate(end);
this.vaadinCalendar.setTimeFormat(Calendar.TimeFormat.Format24H);
this.vaadinCalendar.setWidth("100%");
this.vaadinCalendar.setHeight("90%");
this.vaadinCalendar.setVisible(true);
this.vaadinCalendar.setWeeklyCaptionFormat("dd MMM");
this.vaadinCalendar.setFirstVisibleHourOfDay(okCalendar.getCalendar_startTime());
this.vaadinCalendar.setLastVisibleHourOfDay(okCalendar.getCalendar_endTime());
this.verticalLayout.addComponent(vaadinCalendar);
//this.verticalLayout.setComponentAlignment(vaadinCalendar, Alignment.TOP_CENTER);
SimpleDateFormat sdf = new SimpleDateFormat(Constants.dateTimeFormat);
System.out.println( "current date: " + sdf.format( getCurrentDate().getTime()));  //this display the correct date and time.
System.out.println( "calendar inner date: " + sdf.format(vaadinCalendar.getInternalCalendar().getTime()));  //this display the correct date and time.
System.out.println( "calendar inner time zone : " + vaadinCalendar.getTimeZone() ); //this display the correct timezone.
setVaadinCalendarPrivileges(); //this only set which users can add events on the calendars.
this.markAsDirtyRecursive();
}

I need help with this, I dont know what is wrong. Im thinking that something is messing with the calendar inner functionality of how to print the events on the screen.

[s]
After many many test I haven’t been able to find what is wrong but my suspects are on a style that is overriding something on the calendar, I discover this because I have a set of buttons that were wrapped on a
CssLayout ValoTheme.LAYOUT_COMPONENT_GROUP, but the style is not being recognized by the container layout. However I have been checking my css up and down and haven been able to find anything wrong.

UPDATE 3

I created an empty proyect and the calendar worked just fine, so I returned to my project and removed all the styles and a external library javascript Im using just in case, and removed all the custom layouts, still didnt work, however I created an emty csslayout and copy/pasted the Calendar test from the Vaalo Demo (https://github.com/vaadin/valo-demo/blob/master/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java) and still have the same error, but I found out that if a refresh the page, the error is fixed, how ever I cant make this work with the markAsDirty, only with the Page.refresh()

UPDATE 4

Now I know that the problem is with the Vaalo style, is not beeing pass correctly when I enter to my dashboard, this is making the calendar looks weird, the time column is shrunken and the events are displaced, but is fixed until I refresh the browser, but I dont know why, Im dont know if Im doing wrong with the styles. I did this to fix it, but I dont like it very much:

private void enterDashboard(){
setContent(new Dashboard_2());
if(VaadinSession.getCurrent().getSession().getAttribute(“refreshOnLogin”)== null){
VaadinSession.getCurrent().getSession().setAttribute(“refreshOnLogin”,“false”);
Page.getCurrent().reload();
}
}
[/s]

UPDATE 5

scratch that only workied after I removed all the styles and used the calendar example of the vaalo theme app.

28503.jpg

Maybe some issue with timezone handling in your event provider (OklexEventProvider)?
Can you post some code?

Hello, I already tryed that, is in the code I posted, besides, if it was a timezone, all events have to be displaced the same amount of time , but thats not the case is some kind of random, besides the Event Provider can’t be set to a specific timezone.

this.vaadinCalendar = new Calendar(dataSource); //this.vaadinCalendar.setLocale(Locale.US); //this.vaadinCalendar.setTimeZone(TimeZone.get("America/Mexico_City")); this.vaadinCalendar.setStartDate(start); UPDATE

Sorry, I re read your comment, you asked for code for the OklexEventProvider, well is not that complex, just get the events from the database:

class OklexEventProvider implements CalendarEventProvider {
    @Getter
    @Setter
    private String idCalendar = "";
    private HashMap<Long, OKCalendarEvent> eventsDisplayed = new HashMap<>();

    public OklexEventProvider(String idCalendar){
        setIdCalendar(idCalendar);
    }

    @Override
    public List<CalendarEvent> getEvents(Date date, Date date1) {
        List<CalendarEvent> events = new ArrayList<CalendarEvent>();
        ArrayList<OKCalendarEvent> res = new ArrayList<>();
        try {
            res.addAll(OKCalendarEventData.listAllEventsByCalendarAndStatusBetween(getIdCalendar(),
                    new Timestamp(date.getTime()),
                    new Timestamp(date1.getTime()),
                    OKCalendarEventStatus.RESERVED ,
                    CurrentUser.getCurrentToken().getDataSource()));

        } catch (OklexDataException ex) {
            log.error("no events returned from database" , ex);
            return null;
        }


        for(OKCalendarEvent event: res) {
            eventsDisplayed.put(event.getIdreg(), event);
            events.add( OklexBasicEvent.getBasicEvent(event) );
        }


        return events;
    }

    public OKCalendarEvent getOKCalendarEvent(long idEvent){
        return eventsDisplayed.get(idEvent);
    }

However, when I print the date time of the inner java.util.Calendar of the com.vaadin.ui.Calendar, the right date time and timezone is returned.

//this.verticalLayout.setComponentAlignment(vaadinCalendar, Alignment.TOP_CENTER);
SimpleDateFormat sdf = new SimpleDateFormat(Constants.dateTimeFormat);
System.out.println( "current date: " + sdf.format( getCurrentDate().getTime())); //this display the correct date and time.
System.out.println( "calendar inner date: " + sdf.format(vaadinCalendar.getInternalCalendar().getTime())); //this display the correct date and time.
System.out.println( "calendar inner time zone : " + vaadinCalendar.getTimeZone() ); //this display the correct timezone.