aboutsummaryrefslogtreecommitdiffstats
path: root/compatibility-client
diff options
context:
space:
mode:
authorAnna Miroshnik <anna.miroshnik@arcadia.spb.ru>2014-10-24 20:56:35 +0400
committerDenis Anisimov <denis@vaadin.com>2016-10-31 13:36:16 +0000
commitee47a94e17aadae18fbee6ad804e35ab12446df5 (patch)
tree653890dff553be630a6232cd0479cf79a146af60 /compatibility-client
parent25013128a7e2eb80b565d28abcc0af26219098db (diff)
downloadvaadin-framework-ee47a94e17aadae18fbee6ad804e35ab12446df5.tar.gz
vaadin-framework-ee47a94e17aadae18fbee6ad804e35ab12446df5.zip
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
Diffstat (limited to 'compatibility-client')
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/CalendarEvent.java9
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCell.java26
2 files changed, 23 insertions, 12 deletions
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<DateCellSlot> slots = new ArrayList<DateCell.DateCellSlot>();
+ private final List<DateCellSlot> 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<HandlerRegistration>();
+ handlers = new LinkedList<>();
// 2 slots / hour
firstHour = weekgrid.getFirstHour();
@@ -278,11 +278,11 @@ public class DateCell extends FocusableComplexPanel implements MouseDownHandler,
}
public void recalculateEventWidths() {
- List<DateCellGroup> groups = new ArrayList<DateCellGroup>();
+ List<DateCellGroup> groups = new ArrayList<>();
int count = getWidgetCount();
- List<Integer> handled = new ArrayList<Integer>();
+ List<Integer> 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<Integer> order = new ArrayList<Integer>();
- Map<Integer, Integer> columns = new HashMap<Integer, Integer>();
+ List<Integer> order = new ArrayList<>();
+ Map<Integer, Integer> 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<CalendarEvent> events = new ArrayList<CalendarEvent>();
+ List<CalendarEvent> 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);
}