//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 cNow = java.util.Calendar.getInstance(getClientTimeZone());
java.util.Calendar cStart = java.util.Calendar.getInstance(getClientTimeZone());
cStart.setTime(start);
cStart.set(java.util.Calendar.HOUR_OF_DAY, cNow.get(java.util.Calendar.HOUR_OF_DAY));
cStart.set(java.util.Calendar.MINUTE, cNow.get(java.util.Calendar.MINUTE));
cStart.set(java.util.Calendar.SECOND, 0);
cStart.set(java.util.Calendar.MILLISECOND, 0);
a.setStart(cStart.getTime());
cStart.add(java.util.Calendar.HOUR_OF_DAY, 1);
a.setEnd(cStart.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, 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, getUserId());
//FIXME add feedback info
}
};