From ee47a94e17aadae18fbee6ad804e35ab12446df5 Mon Sep 17 00:00:00 2001 From: Anna Miroshnik Date: Fri, 24 Oct 2014 20:56:35 +0400 Subject: M-day calendar event is hidden if firstVisibleHourOfDay is set (#14737) Calendar week and day views should be correct when using setFirstVisibleHourOfDay() and the end event time is 00:00 of the following day. Fix + Tests. Change-Id: If9f42de5e9c476cb48a2f169f150b42a9c0ab6c2 --- .../client/ui/calendar/schedule/CalendarEvent.java | 9 ++++---- .../v7/client/ui/calendar/schedule/DateCell.java | 26 ++++++++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) (limited to 'compatibility-client') diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/CalendarEvent.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/CalendarEvent.java index abb657c4b4..24f9f60b5a 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/CalendarEvent.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/CalendarEvent.java @@ -309,11 +309,10 @@ public class CalendarEvent { if (getEndTime().getTime() - getStartTime().getTime() > DateConstants.DAYINMILLIS) { isSeveralDays = true; - } else { // if difference <= day -> there can be different cases - if (getStart().compareTo(getEnd()) != 0 - && getEndTime().compareTo(getEnd()) != 0) { - isSeveralDays = true; - } + } else { // if difference <= day -> + isSeveralDays = (getStart().compareTo(getEnd()) != 0) + && !((getEndTime().getHours() == 0 + && getEndTime().getMinutes() == 0)); } return isSeveralDays; } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCell.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCell.java index 92e6f20345..31f443cd77 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCell.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCell.java @@ -56,7 +56,7 @@ public class DateCell extends FocusableComplexPanel implements MouseDownHandler, private boolean disabled = false; private int height; private final Element[] slotElements; - private final List slots = new ArrayList(); + private final List slots = new ArrayList<>(); private int[] slotElementHeights; private int startingSlotHeight; private Date today; @@ -104,7 +104,7 @@ public class DateCell extends FocusableComplexPanel implements MouseDownHandler, addStyleName("v-calendar-day-times"); - handlers = new LinkedList(); + handlers = new LinkedList<>(); // 2 slots / hour firstHour = weekgrid.getFirstHour(); @@ -278,11 +278,11 @@ public class DateCell extends FocusableComplexPanel implements MouseDownHandler, } public void recalculateEventWidths() { - List groups = new ArrayList(); + List groups = new ArrayList<>(); int count = getWidgetCount(); - List handled = new ArrayList(); + List handled = new ArrayList<>(); // Iterate through all events and group them. Events that overlaps // with each other, are added to the same group. @@ -345,8 +345,8 @@ public class DateCell extends FocusableComplexPanel implements MouseDownHandler, for (DateCellGroup g : groups) { int col = 0; int colCount = 0; - List order = new ArrayList(); - Map columns = new HashMap(); + List order = new ArrayList<>(); + Map columns = new HashMap<>(); for (Integer eventIndex : g.getItems()) { DateCellDayEvent d = (DateCellDayEvent) getWidget(eventIndex); d.setMoveWidth(width); @@ -534,7 +534,7 @@ public class DateCell extends FocusableComplexPanel implements MouseDownHandler, public void addEvent(DateCellDayEvent dayEvent) { Element main = getElement(); int index = 0; - List events = new ArrayList(); + List events = new ArrayList<>(); // events are the only widgets in this panel // slots are just elements @@ -583,6 +583,18 @@ public class DateCell extends FocusableComplexPanel implements MouseDownHandler, int eventStartHours = eventStart.getHours(); int eventEndHours = eventEnd.getHours(); + /* + * Special case (#14737): if event end time is 00:00 of the + * following day then isTimeOnDifferentDays() returns false + * (according to logic of this method), so this case should be + * handled here + */ + if (!event.getStart().equals(event.getEnd()) + && (event.getEndTime().getHours() == 0 + && event.getEndTime().getMinutes() == 0)) { + eventEndHours = 23; + } + display = !(eventEndHours < firstHour || eventStartHours > lastHour); } -- cgit v1.2.3