/** * Finds the first day of the week and returns a day representing the start * of that day. * * @param start * The actual date * @param expandToFullWeek * Should the returned date be moved to the start of the week * @return If expandToFullWeek is set then it returns the first day of the * week, else it returns a clone of the actual date with the time * set to the start of the day */ protected Date expandStartDate(Date start, boolean expandToFullWeek) { // If the duration is more than week, use monthly view and get startweek // and endweek. Example if views daterange is from tuesday to next weeks // wednesday->expand to monday to nextweeks sunday. If firstdayofweek = // monday if (expandToFullWeek) { start = getFirstDateForWeek(start); } else { start = (Date) start.clone(); } // Always expand to the start of the first day to the end of the last // day start = getStartOfDay(currentCalendar, start); return start; }
@Override public TargetDetails translateDropTargetDetails( Map<String, Object> clientVariables) { Map<String, Object> serverVariables = new HashMap<String, Object>(); if (clientVariables.containsKey("dropSlotIndex")) { int slotIndex = (Integer) clientVariables.get("dropSlotIndex"); int dayIndex = (Integer) clientVariables.get("dropDayIndex"); currentCalendar.setTime(getStartOfDay(currentCalendar, startDate)); currentCalendar.add(java.util.Calendar.DATE, dayIndex); // change this if slot length is modified currentCalendar.add(java.util.Calendar.MINUTE, slotIndex * 30); serverVariables.put("dropTime", currentCalendar.getTime()); } else { int dayIndex = (Integer) clientVariables.get("dropDayIndex"); currentCalendar.setTime(expandStartDate(startDate, true)); currentCalendar.add(java.util.Calendar.DATE, dayIndex); serverVariables.put("dropDay", currentCalendar.getTime()); } serverVariables.put("mouseEvent", clientVariables.get("mouseEvent")); CalendarTargetDetails td = new CalendarTargetDetails(serverVariables, this); td.setHasDropTime(clientVariables.containsKey("dropSlotIndex")); return td; }