//no need to override onDayClick
@Override
public void onSelect(AjaxRequestTarget target, CalendarView view, Date start, Date end, boolean allDay) {
target.appendJavaScript("setDatepickerDate('datepicker','" + formatDateJava.format(start) + "');");
Appointment a = getDefault();
if (CalendarView.month == view && start.equals(end)) {
java.util.Calendar now = WebSession.getCalendar();
now.setTime(start);
java.util.Calendar cal = WebSession.getCalendar();
cal.set(java.util.Calendar.YEAR, now.get(java.util.Calendar.YEAR));
cal.set(java.util.Calendar.MONTH, now.get(java.util.Calendar.MONTH));
cal.set(java.util.Calendar.DATE, now.get(java.util.Calendar.DATE));
cal.set(java.util.Calendar.SECOND, 0);
cal.set(java.util.Calendar.MILLISECOND, 0);
a.setStart(cal.getTime());
cal.add(java.util.Calendar.HOUR_OF_DAY, 1);
a.setEnd(cal.getTime());
} else {
a.setStart(start);
a.setEnd(end);
}
dialog.setModelObjectWithAjaxTarget(a, target);
dialog.open(target);
}
@Override
public void onEventClick(AjaxRequestTarget target, CalendarView view, int eventId) {
Appointment a = getDao().get((long)eventId);
dialog.setModelObjectWithAjaxTarget(a, target);
dialog.open(target);
}
@Override
public void onEventDrop(AjaxRequestTarget target, int eventId, long delta, boolean allDay) {
AppointmentDao dao = getDao();
Appointment a = dao.get((long)eventId);
java.util.Calendar cal = WebSession.getCalendar();
cal.setTime(a.getStart());
cal.add(java.util.Calendar.MILLISECOND, (int)delta); //FIXME?
a.setStart(cal.getTime());
cal.setTime(a.getEnd());
cal.add(java.util.Calendar.MILLISECOND, (int)delta); //FIXME?
a.setEnd(cal.getTime());
dao.update(a, getBaseUrl(), getUserId());
//FIXME add feedback info
}
@Override
public void onEventResize(AjaxRequestTarget target, int eventId, long delta) {
AppointmentDao dao = getDao();
Appointment a = dao.get((long)eventId);
java.util.Calendar cal = WebSession.getCalendar();
cal.setTime(a.getEnd());
cal.add(java.util.Calendar.MILLISECOND, (int)delta); //FIXME?
a.setEnd(cal.getTime());
dao.update(a, getBaseUrl(), getUserId());
//FIXME add feedback info
}
};