String eventName = params.get(Constants.PARTIAL_BEHAVIOR_EVENT_PARAM);
String clientId = this.getClientId(context);
if(isSelfRequest(context)) {
AjaxBehaviorEvent behaviorEvent = (AjaxBehaviorEvent) event;
FacesEvent wrapperEvent = null;
if(eventName.equals("dateSelect")) {
Date selectedDate = new Date(Long.valueOf(params.get(clientId + "_selectedDate")));
DateSelectEvent dateSelectEvent = new DateSelectEvent(this, behaviorEvent.getBehavior(), selectedDate);
dateSelectEvent.setPhaseId(behaviorEvent.getPhaseId());
wrapperEvent = dateSelectEvent;
}
else if(eventName.equals("eventSelect")) {
String selectedEventId = params.get(clientId + "_selectedEventId");
ScheduleEvent selectedEvent = this.getValue().getEvent(selectedEventId);
wrapperEvent = new ScheduleEntrySelectEvent(this, behaviorEvent.getBehavior(), selectedEvent);
}
else if(eventName.equals("eventMove")) {
String movedEventId = params.get(clientId + "_movedEventId");
ScheduleEvent movedEvent = this.getValue().getEvent(movedEventId);
int dayDelta = Integer.valueOf(params.get(clientId + "_dayDelta"));
int minuteDelta = Integer.valueOf(params.get(clientId + "_minuteDelta"));
Calendar calendar = Calendar.getInstance();
calendar.setTime(movedEvent.getStartDate());
calendar.roll(Calendar.DATE, dayDelta);
movedEvent.getStartDate().setTime(calendar.getTimeInMillis());
calendar = Calendar.getInstance();
calendar.setTime(movedEvent.getEndDate());
calendar.roll(Calendar.DATE, dayDelta);
movedEvent.getEndDate().setTime(calendar.getTimeInMillis());
wrapperEvent = new ScheduleEntryMoveEvent(this, behaviorEvent.getBehavior(), movedEvent, dayDelta, minuteDelta);
}
else if(eventName.equals("eventResize")) {
String resizedEventId = params.get(clientId + "_resizedEventId");
ScheduleEvent resizedEvent = this.getValue().getEvent(resizedEventId);
int dayDelta = Integer.valueOf(params.get(clientId + "_dayDelta"));
int minuteDelta = Integer.valueOf(params.get(clientId + "_minuteDelta"));
Calendar calendar = Calendar.getInstance();
calendar.setTime(resizedEvent.getEndDate());
calendar.roll(Calendar.DATE, dayDelta);
resizedEvent.getEndDate().setTime(calendar.getTimeInMillis());
wrapperEvent = new ScheduleEntryResizeEvent(this, behaviorEvent.getBehavior(), resizedEvent, dayDelta, minuteDelta);
}
wrapperEvent.setPhaseId(behaviorEvent.getPhaseId());
super.queueEvent(wrapperEvent);
}
else {
super.queueEvent(event);