.setStopTime(DateHelper.getDateTimeAsMillis(range.getEnd()));
}
if (filter.getTimesheetUserId() != null) {
timesheetDao.setUser(timesheet, filter.getTimesheetUserId());
}
final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(timesheet);
timesheetEditPage.setReturnToPage((WebPage) getPage());
setResponsePage(timesheetEditPage);
} else {
onDateRangeSelectedHook(filter.getSelectedCalendar(), range, response);
}
}
/**
* Event was moved, a new start time was chosen.
* @see net.ftlines.wicket.fullcalendar.FullCalendar#onEventDropped(net.ftlines.wicket.fullcalendar.callback.DroppedEvent,
* net.ftlines.wicket.fullcalendar.CalendarResponse)
*/
@Override
protected boolean onEventDropped(final DroppedEvent event, final CalendarResponse response)
{
// default mode is move and edit
CalendarDropMode dropMode = CalendarDropMode.MOVE_EDIT;
final StringValue parameterValue = RequestCycle.get().getRequest().getQueryParameters().getParameterValue("which");
if (parameterValue != null) {
try {
dropMode = CalendarDropMode.fromAjaxTarget(parameterValue.toString());
} catch (final Exception ex) {
log.warn("Unable to get calendar drop mode for given value, using default mode. Given mode: " + parameterValue.toString());
}
}
if (log.isDebugEnabled() == true) {
log.debug("Event drop. eventId: "
+ event.getEvent().getId()
+ " eventClass"
+ event.getEvent().getClassName()
+ " sourceId: "
+ event.getSource().getUuid()
+ " dayDelta: "
+ event.getDaysDelta()
+ " minuteDelta: "
+ event.getMinutesDelta()
+ " allDay: "
+ event.isAllDay());
log.debug("Original start time: " + event.getEvent().getStart() + ", original end time: " + event.getEvent().getEnd());
log.debug("New start time: " + event.getNewStartTime() + ", new end time: " + event.getNewEndTime());
}
modifyEvent(event.getEvent(), event.getNewStartTime(), event.getNewEndTime(), dropMode, response);
return false;
}
@Override
protected boolean onEventResized(final ResizedEvent event, final CalendarResponse response)
{
if (log.isDebugEnabled() == true) {
log.debug("Event resized. eventId: "
+ event.getEvent().getId()
+ " eventClass"
+ event.getEvent().getClassName()
+ " sourceId: "
+ event.getSource().getUuid()
+ " dayDelta: "
+ event.getDaysDelta()
+ " minuteDelta: "
+ event.getMinutesDelta());
}
modifyEvent(event.getEvent(), null, event.getNewEndTime(), CalendarDropMode.MOVE_EDIT, response);
return false;
}
@Override
protected void onEventClicked(final ClickedEvent clickedEvent, final CalendarResponse response)
{
final Event event = clickedEvent.getEvent();
final String eventId = event != null ? event.getId() : null;
final String eventClassName = event != null ? event.getClassName() : null;
if (log.isDebugEnabled() == true) {
log.debug("Event clicked. eventId: "
+ eventId
+ " eventClass"
+ event.getClassName()
+ ", sourceId: "
+ clickedEvent.getSource().getUuid());
}
if (eventId != null && eventClassName != null) {
if (TimesheetEventsProvider.EVENT_CLASS_NAME.startsWith(eventClassName) == true) {
// User clicked on a time sheet, show the time sheet:
final Integer id = NumberHelper.parseInteger(eventId);
final PageParameters parameters = new PageParameters();
parameters.add(AbstractEditPage.PARAMETER_KEY_ID, id);
final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(parameters);
timesheetEditPage.setReturnToPage((WebPage) getPage());
setResponsePage(timesheetEditPage);
return;
} else if (TimesheetEventsProvider.BREAK_EVENT_CLASS_NAME.startsWith(eventClassName) == true) {
// User clicked on a break (between time sheets), create new time sheet with times of the break:
final TimesheetDO breaksTimesheet = timesheetEventsProvider.getBreakTimesheet(eventId);
final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(breaksTimesheet);
timesheetEditPage.setReturnToPage((WebPage) getPage());
setResponsePage(timesheetEditPage);
return;
} else if (BirthdayEventsProvider.EVENT_CLASS_NAME.startsWith(eventClassName) == true) {
// User clicked on birthday, show the address:
final Integer id = NumberHelper.parseInteger(eventId);