use of org.primefaces.event.schedule.ScheduleRangeEvent in project primefaces by primefaces.
the class Schedule method queueEvent.
@Override
public void queueEvent(FacesEvent event) {
FacesContext context = getFacesContext();
Map<String, String> params = context.getExternalContext().getRequestParameterMap();
String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
String clientId = getClientId(context);
if (ComponentUtils.isRequestSource(this, context)) {
AjaxBehaviorEvent behaviorEvent = (AjaxBehaviorEvent) event;
FacesEvent wrapperEvent = null;
if ("dateSelect".equals(eventName) || "dateDblSelect".equals(eventName)) {
String selectedDateStr = params.get(clientId + "_selectedDate");
ZoneId zoneId = CalendarUtils.calculateZoneId(this.getTimeZone());
LocalDateTime selectedDate = CalendarUtils.toLocalDateTime(zoneId, selectedDateStr);
SelectEvent<?> selectEvent = new SelectEvent(this, behaviorEvent.getBehavior(), selectedDate);
selectEvent.setPhaseId(behaviorEvent.getPhaseId());
wrapperEvent = selectEvent;
}
if ("rangeSelect".equals(eventName)) {
String startDateStr = params.get(clientId + "_startDate");
String endDateStr = params.get(clientId + "_endDate");
ZoneId zoneId = CalendarUtils.calculateZoneId(this.getTimeZone());
LocalDateTime startDate = CalendarUtils.toLocalDateTime(zoneId, startDateStr);
LocalDateTime endDate = CalendarUtils.toLocalDateTime(zoneId, endDateStr);
ScheduleRangeEvent selectEvent = new ScheduleRangeEvent(this, behaviorEvent.getBehavior(), startDate, endDate);
selectEvent.setPhaseId(behaviorEvent.getPhaseId());
wrapperEvent = selectEvent;
} else if ("eventSelect".equals(eventName)) {
String selectedEventId = params.get(clientId + "_selectedEventId");
ScheduleEvent<?> selectedEvent = getValue().getEvent(selectedEventId);
wrapperEvent = new SelectEvent(this, behaviorEvent.getBehavior(), selectedEvent);
} else if ("eventMove".equals(eventName)) {
String movedEventId = params.get(clientId + "_movedEventId");
ScheduleEvent<?> movedEvent = getValue().getEvent(movedEventId);
int yearDelta = Double.valueOf(params.get(clientId + "_yearDelta")).intValue();
int monthDelta = Double.valueOf(params.get(clientId + "_monthDelta")).intValue();
int dayDelta = Double.valueOf(params.get(clientId + "_dayDelta")).intValue();
int minuteDelta = Double.valueOf(params.get(clientId + "_minuteDelta")).intValue();
boolean allDay = Boolean.parseBoolean(params.get(clientId + "_allDay"));
LocalDateTime startDate = movedEvent.getStartDate();
LocalDateTime endDate = movedEvent.getEndDate();
startDate = startDate.plusYears(yearDelta).plusMonths(monthDelta).plusDays(dayDelta).plusMinutes(minuteDelta);
endDate = endDate.plusYears(yearDelta).plusMonths(monthDelta).plusDays(dayDelta).plusMinutes(minuteDelta);
movedEvent.setAllDay(allDay);
movedEvent.setStartDate(startDate);
movedEvent.setEndDate(endDate);
wrapperEvent = new ScheduleEntryMoveEvent(this, behaviorEvent.getBehavior(), movedEvent, yearDelta, monthDelta, dayDelta, minuteDelta);
} else if ("eventResize".equals(eventName)) {
String resizedEventId = params.get(clientId + "_resizedEventId");
ScheduleEvent<?> resizedEvent = getValue().getEvent(resizedEventId);
int startDeltaYear = Double.valueOf(params.get(clientId + "_startDeltaYear")).intValue();
int startDeltaMonth = Double.valueOf(params.get(clientId + "_startDeltaMonth")).intValue();
int startDeltaDay = Double.valueOf(params.get(clientId + "_startDeltaDay")).intValue();
int startDeltaMinute = Double.valueOf(params.get(clientId + "_startDeltaMinute")).intValue();
LocalDateTime startDate = resizedEvent.getStartDate();
startDate = startDate.plusYears(startDeltaYear).plusMonths(startDeltaMonth).plusDays(startDeltaDay).plusMinutes(startDeltaMinute);
resizedEvent.setStartDate(startDate);
int endDeltaYear = Double.valueOf(params.get(clientId + "_endDeltaYear")).intValue();
int endDeltaMonth = Double.valueOf(params.get(clientId + "_endDeltaMonth")).intValue();
int endDeltaDay = Double.valueOf(params.get(clientId + "_endDeltaDay")).intValue();
int endDeltaMinute = Double.valueOf(params.get(clientId + "_endDeltaMinute")).intValue();
LocalDateTime endDate = resizedEvent.getEndDate();
endDate = endDate.plusYears(endDeltaYear).plusMonths(endDeltaMonth).plusDays(endDeltaDay).plusMinutes(endDeltaMinute);
resizedEvent.setEndDate(endDate);
wrapperEvent = new ScheduleEntryResizeEvent(this, behaviorEvent.getBehavior(), resizedEvent, startDeltaYear, startDeltaMonth, startDeltaDay, startDeltaMinute, endDeltaYear, endDeltaMonth, endDeltaDay, endDeltaMinute);
} else if ("viewChange".equals(eventName)) {
wrapperEvent = new SelectEvent(this, behaviorEvent.getBehavior(), getView());
}
if (wrapperEvent == null) {
throw new FacesException("Component " + this.getClass().getName() + " does not support event " + eventName + "!");
}
wrapperEvent.setPhaseId(behaviorEvent.getPhaseId());
super.queueEvent(wrapperEvent);
} else {
super.queueEvent(event);
}
}
Aggregations