Search in sources :

Example 1 with ScheduleEvent

use of org.primefaces.model.ScheduleEvent in project ctsms by phoenixctms.

the class ScheduleDutyRosterTurnBean method onEventSelect.

public void onEventSelect(ScheduleEntrySelectEvent selectEvent) {
    ScheduleEvent event = selectEvent.getScheduleEvent();
    this.out = null;
    if (event instanceof DutyRosterTurnEvent) {
        dutyRosterTurnEvent = (DutyRosterTurnEvent) event;
        statusEntryEvent = null;
        holidayEvent = null;
        staffNaCountEvent = null;
        visitScheduleItemEvent = null;
        courseInventoryBookingEvent = null;
        courseEvent = null;
        probandStatusEvent = null;
        timelineEvent = null;
        this.in = (DutyRosterTurnInVO) dutyRosterTurnEvent.getData();
        this.out = dutyRosterTurnEvent.getOut();
        initSets();
    } else if (event instanceof StaffStatusEvent) {
        dutyRosterTurnEvent = null;
        statusEntryEvent = (StaffStatusEvent) event;
        holidayEvent = null;
        staffNaCountEvent = null;
        visitScheduleItemEvent = null;
        courseInventoryBookingEvent = null;
        courseEvent = null;
        probandStatusEvent = null;
        timelineEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof HolidayEvent) {
        dutyRosterTurnEvent = null;
        statusEntryEvent = null;
        holidayEvent = (HolidayEvent) event;
        staffNaCountEvent = null;
        visitScheduleItemEvent = null;
        courseInventoryBookingEvent = null;
        courseEvent = null;
        probandStatusEvent = null;
        timelineEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof StaffNaCountEvent) {
        dutyRosterTurnEvent = null;
        statusEntryEvent = null;
        holidayEvent = null;
        staffNaCountEvent = (StaffNaCountEvent) event;
        visitScheduleItemEvent = null;
        courseInventoryBookingEvent = null;
        courseEvent = null;
        probandStatusEvent = null;
        timelineEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof VisitScheduleItemEvent) {
        dutyRosterTurnEvent = null;
        statusEntryEvent = null;
        holidayEvent = null;
        staffNaCountEvent = null;
        visitScheduleItemEvent = (VisitScheduleItemEvent) event;
        courseInventoryBookingEvent = null;
        courseEvent = null;
        probandStatusEvent = null;
        timelineEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof CourseInventoryBookingEvent) {
        dutyRosterTurnEvent = null;
        statusEntryEvent = null;
        holidayEvent = null;
        staffNaCountEvent = null;
        visitScheduleItemEvent = null;
        courseInventoryBookingEvent = (CourseInventoryBookingEvent) event;
        courseEvent = null;
        probandStatusEvent = null;
        timelineEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof CourseEvent) {
        dutyRosterTurnEvent = null;
        statusEntryEvent = null;
        holidayEvent = null;
        staffNaCountEvent = null;
        visitScheduleItemEvent = null;
        courseInventoryBookingEvent = null;
        courseEvent = (CourseEvent) event;
        probandStatusEvent = null;
        timelineEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof ProbandStatusEvent) {
        dutyRosterTurnEvent = null;
        statusEntryEvent = null;
        holidayEvent = null;
        staffNaCountEvent = null;
        visitScheduleItemEvent = null;
        courseInventoryBookingEvent = null;
        courseEvent = null;
        probandStatusEvent = (ProbandStatusEvent) event;
        timelineEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof TimelineEvent) {
        dutyRosterTurnEvent = null;
        statusEntryEvent = null;
        holidayEvent = null;
        staffNaCountEvent = null;
        visitScheduleItemEvent = null;
        courseInventoryBookingEvent = null;
        courseEvent = null;
        probandStatusEvent = null;
        timelineEvent = (TimelineEvent) event;
        initIn();
        initSets();
        abortScheduleEvent();
    } else {
        dutyRosterTurnEvent = null;
        statusEntryEvent = null;
        holidayEvent = null;
        staffNaCountEvent = null;
        visitScheduleItemEvent = null;
        courseInventoryBookingEvent = null;
        courseEvent = null;
        probandStatusEvent = null;
        timelineEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    }
}
Also used : ScheduleEvent(org.primefaces.model.ScheduleEvent) StaffNaCountEvent(org.phoenixctms.ctsms.web.model.shared.StaffNaCountEvent) CourseEvent(org.phoenixctms.ctsms.web.model.shared.CourseEvent) ProbandStatusEvent(org.phoenixctms.ctsms.web.model.shared.ProbandStatusEvent) HolidayEvent(org.phoenixctms.ctsms.web.model.shared.HolidayEvent)

Example 2 with ScheduleEvent

use of org.primefaces.model.ScheduleEvent 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);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) FacesContext(javax.faces.context.FacesContext) ScheduleRangeEvent(org.primefaces.event.schedule.ScheduleRangeEvent) ZoneId(java.time.ZoneId) ScheduleEntryMoveEvent(org.primefaces.event.schedule.ScheduleEntryMoveEvent) AjaxBehaviorEvent(javax.faces.event.AjaxBehaviorEvent) FacesEvent(javax.faces.event.FacesEvent) SelectEvent(org.primefaces.event.SelectEvent) FacesException(javax.faces.FacesException) ScheduleEvent(org.primefaces.model.ScheduleEvent) ScheduleEntryResizeEvent(org.primefaces.event.schedule.ScheduleEntryResizeEvent)

Example 3 with ScheduleEvent

use of org.primefaces.model.ScheduleEvent in project primefaces by primefaces.

the class Schedule001Test method testEventDisplayRecognizingClientTimeZone.

@Test
@Order(5)
@DisplayName("Schedule: event display - recognizing (server)timeZone and clientTimeZone")
public void testEventDisplayRecognizingClientTimeZone(Page page) {
    // Arrange
    Schedule schedule = page.schedule;
    page.buttonGerman.click();
    // Assert
    List<WebElement> todaysEvents = schedule.findElements(By.cssSelector(".fc-day-today .fc-daygrid-event"));
    Assertions.assertEquals(1, todaysEvents.size());
    String eventTime = todaysEvents.get(0).findElement(By.className("fc-event-time")).getText();
    String eventTitle = todaysEvents.get(0).findElement(By.className("fc-event-title")).getText();
    int eventid = LocalDateTime.now().getDayOfMonth() > 1 ? 1 : 0;
    ScheduleEvent referenceEvent = schedule001.getEventModel().getEvents().get(eventid);
    Assertions.assertEquals(referenceEvent.getTitle(), eventTitle);
    Assertions.assertEquals(referenceEvent.getStartDate().getHour() + " Uhr", eventTime);
    // check with different clientTimeZone and (server)timeZone - settings ------------------------
    // Arrange
    setDifferingServerAndClientTimezone(page);
    // Assert
    eventTime = "";
    // DonĀ“t use .fc-day-today because this may already point to the day before or the next day in some time of day constellations
    todaysEvents = schedule.findElements(By.cssSelector(".fc-daygrid-event"));
    for (WebElement eventElt : todaysEvents) {
        if (eventElt.findElement(By.className("fc-event-title")).getText().equals(referenceEvent.getTitle())) {
            eventTime = eventElt.findElement(By.className("fc-event-time")).getText();
        }
    }
    Assertions.assertEquals((referenceEvent.getStartDate().getHour() + calcOffsetInHoursBetweenClientAndServerAndTimezone(ZonedDateTime.now())) + " Uhr", eventTime);
    assertNoJavascriptErrors();
}
Also used : ScheduleEvent(org.primefaces.model.ScheduleEvent) WebElement(org.openqa.selenium.WebElement) AbstractPrimePageTest(org.primefaces.selenium.AbstractPrimePageTest)

Example 4 with ScheduleEvent

use of org.primefaces.model.ScheduleEvent in project ctsms by phoenixctms.

the class ScheduleInventoryBookingBean method moveResizeEvent.

private void moveResizeEvent(AjaxBehaviorEvent ajaxEvent) {
    ScheduleEvent event = null;
    ScheduleEntryMoveEvent moveEvent = null;
    ScheduleEntryResizeEvent resizeEvent = null;
    if (ajaxEvent instanceof ScheduleEntryMoveEvent) {
        moveEvent = (ScheduleEntryMoveEvent) ajaxEvent;
        event = moveEvent.getScheduleEvent();
    } else if (ajaxEvent instanceof ScheduleEntryResizeEvent) {
        resizeEvent = (ScheduleEntryResizeEvent) ajaxEvent;
        event = resizeEvent.getScheduleEvent();
    } else {
        abortScheduleEvent();
        return;
    }
    this.out = null;
    if (event instanceof InventoryBookingEvent) {
        bookingEvent = (InventoryBookingEvent) event;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = null;
        this.in = (InventoryBookingInVO) bookingEvent.getData();
        if (moveEvent != null) {
            this.in.setStart(DateUtil.addDayMinuteDelta(in.getStart(), moveEvent.getDayDelta(), moveEvent.getMinuteDelta()));
            this.in.setStop(DateUtil.addDayMinuteDelta(in.getStop(), moveEvent.getDayDelta(), moveEvent.getMinuteDelta()));
        }
        if (resizeEvent != null) {
            this.in.setStop(DateUtil.addDayMinuteDelta(in.getStop(), resizeEvent.getDayDelta(), resizeEvent.getMinuteDelta()));
        }
        this.update();
    } else if (event instanceof InventoryStatusEvent) {
        bookingEvent = null;
        inventoryStatusEvent = (InventoryStatusEvent) event;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof HolidayEvent) {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = (HolidayEvent) event;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof VisitScheduleItemEvent) {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = (VisitScheduleItemEvent) event;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof ProbandStatusEvent) {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = (ProbandStatusEvent) event;
        maintenanceItemEvent = null;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof MaintenanceItemEvent) {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = (MaintenanceItemEvent) event;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof CourseEvent) {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = (CourseEvent) event;
        initIn();
        initSets();
        abortScheduleEvent();
    } else {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    }
}
Also used : ScheduleEvent(org.primefaces.model.ScheduleEvent) ScheduleEntryMoveEvent(org.primefaces.event.ScheduleEntryMoveEvent) CourseEvent(org.phoenixctms.ctsms.web.model.shared.CourseEvent) VisitScheduleItemEvent(org.phoenixctms.ctsms.web.model.trial.VisitScheduleItemEvent) ProbandStatusEvent(org.phoenixctms.ctsms.web.model.shared.ProbandStatusEvent) ScheduleEntryResizeEvent(org.primefaces.event.ScheduleEntryResizeEvent) InventoryBookingEvent(org.phoenixctms.ctsms.web.model.shared.InventoryBookingEvent) HolidayEvent(org.phoenixctms.ctsms.web.model.shared.HolidayEvent)

Example 5 with ScheduleEvent

use of org.primefaces.model.ScheduleEvent in project ctsms by phoenixctms.

the class ScheduleInventoryBookingBean method onEventSelect.

public void onEventSelect(ScheduleEntrySelectEvent selectEvent) {
    ScheduleEvent event = selectEvent.getScheduleEvent();
    this.out = null;
    if (event instanceof InventoryBookingEvent) {
        bookingEvent = (InventoryBookingEvent) event;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = null;
        this.in = (InventoryBookingInVO) bookingEvent.getData();
        this.out = bookingEvent.getOut();
        initSets();
    } else if (event instanceof InventoryStatusEvent) {
        bookingEvent = null;
        inventoryStatusEvent = (InventoryStatusEvent) event;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof HolidayEvent) {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = (HolidayEvent) event;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof VisitScheduleItemEvent) {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = (VisitScheduleItemEvent) event;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof ProbandStatusEvent) {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = (ProbandStatusEvent) event;
        maintenanceItemEvent = null;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof MaintenanceItemEvent) {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = (MaintenanceItemEvent) event;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    } else if (event instanceof CourseEvent) {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = (CourseEvent) event;
        initIn();
        initSets();
        abortScheduleEvent();
    } else {
        bookingEvent = null;
        inventoryStatusEvent = null;
        holidayEvent = null;
        visitScheduleItemEvent = null;
        probandStatusEvent = null;
        maintenanceItemEvent = null;
        courseEvent = null;
        initIn();
        initSets();
        abortScheduleEvent();
    }
}
Also used : ScheduleEvent(org.primefaces.model.ScheduleEvent) CourseEvent(org.phoenixctms.ctsms.web.model.shared.CourseEvent) VisitScheduleItemEvent(org.phoenixctms.ctsms.web.model.trial.VisitScheduleItemEvent) ProbandStatusEvent(org.phoenixctms.ctsms.web.model.shared.ProbandStatusEvent) InventoryBookingEvent(org.phoenixctms.ctsms.web.model.shared.InventoryBookingEvent) HolidayEvent(org.phoenixctms.ctsms.web.model.shared.HolidayEvent)

Aggregations

ScheduleEvent (org.primefaces.model.ScheduleEvent)6 CourseEvent (org.phoenixctms.ctsms.web.model.shared.CourseEvent)4 HolidayEvent (org.phoenixctms.ctsms.web.model.shared.HolidayEvent)4 ProbandStatusEvent (org.phoenixctms.ctsms.web.model.shared.ProbandStatusEvent)4 InventoryBookingEvent (org.phoenixctms.ctsms.web.model.shared.InventoryBookingEvent)2 StaffNaCountEvent (org.phoenixctms.ctsms.web.model.shared.StaffNaCountEvent)2 VisitScheduleItemEvent (org.phoenixctms.ctsms.web.model.trial.VisitScheduleItemEvent)2 ScheduleEntryMoveEvent (org.primefaces.event.ScheduleEntryMoveEvent)2 ScheduleEntryResizeEvent (org.primefaces.event.ScheduleEntryResizeEvent)2 LocalDateTime (java.time.LocalDateTime)1 ZoneId (java.time.ZoneId)1 FacesException (javax.faces.FacesException)1 FacesContext (javax.faces.context.FacesContext)1 AjaxBehaviorEvent (javax.faces.event.AjaxBehaviorEvent)1 FacesEvent (javax.faces.event.FacesEvent)1 WebElement (org.openqa.selenium.WebElement)1 SelectEvent (org.primefaces.event.SelectEvent)1 ScheduleEntryMoveEvent (org.primefaces.event.schedule.ScheduleEntryMoveEvent)1 ScheduleEntryResizeEvent (org.primefaces.event.schedule.ScheduleEntryResizeEvent)1 ScheduleRangeEvent (org.primefaces.event.schedule.ScheduleRangeEvent)1