Search in sources :

Example 1 with CalendarGUIUpdateEvent

use of org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent in project OpenOLAT by OpenOLAT.

the class WeeklyCalendarController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    Kalendar affectedCal = null;
    if (dirty) {
        dirty = false;
        fireEvent(ureq, new CalendarGUIModifiedEvent());
    }
    if (source == editController) {
        affectedCal = editController.getKalendarEvent().getCalendar();
        cmc.deactivate();
        calendarEl.getComponent().setDirty(true);
        // do logging if affectedCal not null
        if (affectedCal != null) {
            ThreadLocalUserActivityLogger.log(getCalLoggingAction(), getClass(), LoggingResourceable.wrap(ureq.getIdentity()), LoggingResourceable.wrap(affectedCal));
        }
        cleanUp();
    } else if (source == eventDetailsCtr) {
        if (event instanceof CalendarGUIEditEvent) {
            eventCalloutCtr.deactivate();
            cleanUp();
            CalendarGUIEditEvent editEvent = (CalendarGUIEditEvent) event;
            pushEditEventController(ureq, editEvent.getKalendarEvent(), editEvent.getKalendarRenderWrapper());
        } else if (event == Event.DONE_EVENT) {
            eventCalloutCtr.deactivate();
            cleanUp();
        }
    } else if (source == updateCtr) {
        if (event instanceof CalendarGUIUpdateEvent) {
            doUpdate((CalendarGUIUpdateEvent) event, updateCtr.getKalendarEvent(), updateCtr.getDayDelta(), updateCtr.getMinuteDelta(), updateCtr.getAllDay(), updateCtr.getChangeBegin());
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == printCtrl) {
        if (event instanceof CalendarGUIPrintEvent) {
            CalendarGUIPrintEvent printEvent = (CalendarGUIPrintEvent) event;
            if (printEvent.getFrom() != null && printEvent.getTo() != null) {
                doPrint(printEvent.getFrom(), printEvent.getTo());
            }
        }
        eventCalloutCtr.deactivate();
        cleanUp();
    } else if (source == cmc) {
        calendarEl.getComponent().setDirty(true);
        cleanUp();
    } else if (source == dbcSequence) {
        if (event != Event.CANCELLED_EVENT) {
            int pos = DialogBoxUIFactory.getButtonPos(event);
            CalendarGUIEditEvent guiEvent = (CalendarGUIEditEvent) dbcSequence.getUserObject();
            KalendarRenderWrapper kalendarWrapper = guiEvent.getKalendarRenderWrapper();
            KalendarEvent kalendarEvent = guiEvent.getKalendarEvent();
            if (pos == 0) {
                // edit the sequence
                // load the parent event of this sequence
                KalendarEvent parentEvent = kalendarWrapper.getKalendar().getEvent(kalendarEvent.getID(), kalendarEvent.getRecurrenceID());
                pushEditEventController(ureq, parentEvent, kalendarWrapper);
            } else if (pos == 1) {
                // delete a single event of the sequence
                deleteSingleYesNoController = activateYesNoDialog(ureq, null, translate("cal.delete.dialogtext"), deleteSingleYesNoController);
                deleteSingleYesNoController.setUserObject(kalendarEvent);
            } else if (pos == 2) {
                // delete the whole sequence
                deleteSequenceYesNoController = activateYesNoDialog(ureq, null, translate("cal.delete.dialogtext.sequence"), deleteSequenceYesNoController);
                deleteSequenceYesNoController.setUserObject(kalendarEvent);
            }
        }
        dbcSequence.dispose();
    } else if (source == deleteSingleYesNoController) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            KalendarEvent kalendarEvent = (KalendarEvent) deleteSingleYesNoController.getUserObject();
            affectedCal = kalendarEvent.getCalendar();
            KalendarEvent kEvent = affectedCal.getEvent(kalendarEvent.getID(), kalendarEvent.getRecurrenceID());
            kEvent.addRecurrenceExc(kalendarEvent.getBegin());
            calendarManager.updateEventFrom(affectedCal, kEvent);
            deleteSingleYesNoController.dispose();
            calendarEl.getComponent().setDirty(true);
        }
    } else if (source == deleteSequenceYesNoController) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            KalendarEvent kalendarEvent = (KalendarEvent) deleteSequenceYesNoController.getUserObject();
            affectedCal = kalendarEvent.getCalendar();
            calendarManager.removeEventFrom(affectedCal, kalendarEvent);
            deleteSequenceYesNoController.dispose();
            calendarEl.getComponent().setDirty(true);
        }
    } else if (configurationCtrl == source) {
        if (event instanceof CalendarGUIImportEvent) {
            CalendarGUIImportEvent importEvent = (CalendarGUIImportEvent) event;
            calendarWrappers.add(importEvent.getCalendar());
            calendarEl.setCalendars(calendarWrappers);
        } else if (event instanceof CalendarGUIRemoveEvent) {
            CalendarGUIRemoveEvent removeEvent = (CalendarGUIRemoveEvent) event;
            calendarWrappers.remove(removeEvent.getCalendar());
            calendarEl.setCalendars(calendarWrappers);
        } else if (event instanceof CalendarGUISettingEvent) {
            calendarEl.setCalendars(calendarWrappers);
        }
    } else if (eventCalloutCtr == source) {
        cleanUp();
    } else if (eventDetailsCtr == source) {
    }
    if (calendarEl.getComponent().isDirty()) {
        if (subsContext != null) {
            // group or course calendar -> prepared subscription context is the right one
            NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
        } else if (caller.equals(CALLER_HOME) && affectedCal != null) {
            // one can add/edit/remove dates of group and course calendars from the home calendar view -> choose right subscription context
            for (KalendarRenderWrapper calWrapper : calendarWrappers) {
                if (affectedCal == calWrapper.getKalendar()) {
                    SubscriptionContext tmpSubsContext = calendarNotificationsManager.getSubscriptionContext(calWrapper);
                    NotificationsManager.getInstance().markPublisherNews(tmpSubsContext, ureq.getIdentity(), true);
                }
            }
        }
    }
}
Also used : CalendarGUIEditEvent(org.olat.commons.calendar.ui.events.CalendarGUIEditEvent) Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarGUIPrintEvent(org.olat.commons.calendar.ui.events.CalendarGUIPrintEvent) CalendarGUISettingEvent(org.olat.commons.calendar.ui.events.CalendarGUISettingEvent) CalendarGUIUpdateEvent(org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent) CalendarGUIImportEvent(org.olat.commons.calendar.ui.events.CalendarGUIImportEvent) CalendarGUIRemoveEvent(org.olat.commons.calendar.ui.events.CalendarGUIRemoveEvent) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) CalendarGUIModifiedEvent(org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)

Example 2 with CalendarGUIUpdateEvent

use of org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent in project openolat by klemens.

the class WeeklyCalendarController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    Kalendar affectedCal = null;
    if (dirty) {
        dirty = false;
        fireEvent(ureq, new CalendarGUIModifiedEvent());
    }
    if (source == editController) {
        affectedCal = editController.getKalendarEvent().getCalendar();
        cmc.deactivate();
        calendarEl.getComponent().setDirty(true);
        // do logging if affectedCal not null
        if (affectedCal != null) {
            ThreadLocalUserActivityLogger.log(getCalLoggingAction(), getClass(), LoggingResourceable.wrap(ureq.getIdentity()), LoggingResourceable.wrap(affectedCal));
        }
        cleanUp();
    } else if (source == eventDetailsCtr) {
        if (event instanceof CalendarGUIEditEvent) {
            eventCalloutCtr.deactivate();
            cleanUp();
            CalendarGUIEditEvent editEvent = (CalendarGUIEditEvent) event;
            pushEditEventController(ureq, editEvent.getKalendarEvent(), editEvent.getKalendarRenderWrapper());
        } else if (event == Event.DONE_EVENT) {
            eventCalloutCtr.deactivate();
            cleanUp();
        }
    } else if (source == updateCtr) {
        if (event instanceof CalendarGUIUpdateEvent) {
            doUpdate((CalendarGUIUpdateEvent) event, updateCtr.getKalendarEvent(), updateCtr.getDayDelta(), updateCtr.getMinuteDelta(), updateCtr.getAllDay(), updateCtr.getChangeBegin());
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == printCtrl) {
        if (event instanceof CalendarGUIPrintEvent) {
            CalendarGUIPrintEvent printEvent = (CalendarGUIPrintEvent) event;
            if (printEvent.getFrom() != null && printEvent.getTo() != null) {
                doPrint(printEvent.getFrom(), printEvent.getTo());
            }
        }
        eventCalloutCtr.deactivate();
        cleanUp();
    } else if (source == cmc) {
        calendarEl.getComponent().setDirty(true);
        cleanUp();
    } else if (source == dbcSequence) {
        if (event != Event.CANCELLED_EVENT) {
            int pos = DialogBoxUIFactory.getButtonPos(event);
            CalendarGUIEditEvent guiEvent = (CalendarGUIEditEvent) dbcSequence.getUserObject();
            KalendarRenderWrapper kalendarWrapper = guiEvent.getKalendarRenderWrapper();
            KalendarEvent kalendarEvent = guiEvent.getKalendarEvent();
            if (pos == 0) {
                // edit the sequence
                // load the parent event of this sequence
                KalendarEvent parentEvent = kalendarWrapper.getKalendar().getEvent(kalendarEvent.getID(), kalendarEvent.getRecurrenceID());
                pushEditEventController(ureq, parentEvent, kalendarWrapper);
            } else if (pos == 1) {
                // delete a single event of the sequence
                deleteSingleYesNoController = activateYesNoDialog(ureq, null, translate("cal.delete.dialogtext"), deleteSingleYesNoController);
                deleteSingleYesNoController.setUserObject(kalendarEvent);
            } else if (pos == 2) {
                // delete the whole sequence
                deleteSequenceYesNoController = activateYesNoDialog(ureq, null, translate("cal.delete.dialogtext.sequence"), deleteSequenceYesNoController);
                deleteSequenceYesNoController.setUserObject(kalendarEvent);
            }
        }
        dbcSequence.dispose();
    } else if (source == deleteSingleYesNoController) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            KalendarEvent kalendarEvent = (KalendarEvent) deleteSingleYesNoController.getUserObject();
            affectedCal = kalendarEvent.getCalendar();
            KalendarEvent kEvent = affectedCal.getEvent(kalendarEvent.getID(), kalendarEvent.getRecurrenceID());
            kEvent.addRecurrenceExc(kalendarEvent.getBegin());
            calendarManager.updateEventFrom(affectedCal, kEvent);
            deleteSingleYesNoController.dispose();
            calendarEl.getComponent().setDirty(true);
        }
    } else if (source == deleteSequenceYesNoController) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            KalendarEvent kalendarEvent = (KalendarEvent) deleteSequenceYesNoController.getUserObject();
            affectedCal = kalendarEvent.getCalendar();
            calendarManager.removeEventFrom(affectedCal, kalendarEvent);
            deleteSequenceYesNoController.dispose();
            calendarEl.getComponent().setDirty(true);
        }
    } else if (configurationCtrl == source) {
        if (event instanceof CalendarGUIImportEvent) {
            CalendarGUIImportEvent importEvent = (CalendarGUIImportEvent) event;
            calendarWrappers.add(importEvent.getCalendar());
            calendarEl.setCalendars(calendarWrappers);
        } else if (event instanceof CalendarGUIRemoveEvent) {
            CalendarGUIRemoveEvent removeEvent = (CalendarGUIRemoveEvent) event;
            calendarWrappers.remove(removeEvent.getCalendar());
            calendarEl.setCalendars(calendarWrappers);
        } else if (event instanceof CalendarGUISettingEvent) {
            calendarEl.setCalendars(calendarWrappers);
        }
    } else if (eventCalloutCtr == source) {
        cleanUp();
    } else if (eventDetailsCtr == source) {
    }
    if (calendarEl.getComponent().isDirty()) {
        if (subsContext != null) {
            // group or course calendar -> prepared subscription context is the right one
            NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
        } else if (caller.equals(CALLER_HOME) && affectedCal != null) {
            // one can add/edit/remove dates of group and course calendars from the home calendar view -> choose right subscription context
            for (KalendarRenderWrapper calWrapper : calendarWrappers) {
                if (affectedCal == calWrapper.getKalendar()) {
                    SubscriptionContext tmpSubsContext = calendarNotificationsManager.getSubscriptionContext(calWrapper);
                    NotificationsManager.getInstance().markPublisherNews(tmpSubsContext, ureq.getIdentity(), true);
                }
            }
        }
    }
}
Also used : CalendarGUIEditEvent(org.olat.commons.calendar.ui.events.CalendarGUIEditEvent) Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarGUIPrintEvent(org.olat.commons.calendar.ui.events.CalendarGUIPrintEvent) CalendarGUISettingEvent(org.olat.commons.calendar.ui.events.CalendarGUISettingEvent) CalendarGUIUpdateEvent(org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent) CalendarGUIImportEvent(org.olat.commons.calendar.ui.events.CalendarGUIImportEvent) CalendarGUIRemoveEvent(org.olat.commons.calendar.ui.events.CalendarGUIRemoveEvent) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) CalendarGUIModifiedEvent(org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)

Example 3 with CalendarGUIUpdateEvent

use of org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent in project openolat by klemens.

the class CalendarEntryDetailsController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == deleteCtr) {
        if (event instanceof CalendarGUIDeleteEvent) {
            doDelete((CalendarGUIDeleteEvent) event);
            cmc.deactivate();
            cleanUp();
            fireEvent(ureq, Event.DONE_EVENT);
        } else {
            cmc.deactivate();
            cleanUp();
        }
    } else if (source == activeLinkProvider) {
        if (kalendarEvent.getCalendar() != null) {
            fireEvent(ureq, Event.DONE_EVENT);
        }
    } else if (source == eventForm) {
        if (event == Event.DONE_EVENT) {
            doSave(ureq);
        } else if ("delete".equals(event.getCommand())) {
            doConfirmDelete(ureq);
        } else if (event == Event.CANCELLED_EVENT) {
            eventForm.setEntry(kalendarEvent);
            // user canceled, finish workflow
            fireEvent(ureq, Event.DONE_EVENT);
        }
    } else if (source == updateCtr) {
        if (event instanceof CalendarGUIUpdateEvent) {
            doUpdate((CalendarGUIUpdateEvent) event);
            cmc.deactivate();
            cleanUp();
            fireEvent(ureq, Event.DONE_EVENT);
        } else {
            cmc.deactivate();
            cleanUp();
        }
    } else if (source == customMediaChooserCtr) {
        boolean doneSuccessfully = true;
        if (event instanceof URLChoosenEvent) {
            URLChoosenEvent urlEvent = (URLChoosenEvent) event;
            String url = urlEvent.getURL();
            List<KalendarEventLink> links = kalendarEvent.getKalendarEventLinks();
            String provider = customMediaChooserCtr.getClass().getSimpleName();
            String id = url;
            String displayName = StringHelper.containsNonWhitespace(urlEvent.getDisplayName()) ? urlEvent.getDisplayName() : url;
            String uri = url.contains("://") ? url : (Settings.getServerContextPathURI() + url);
            String iconCssClass = urlEvent.getIconCssClass();
            if (!StringHelper.containsNonWhitespace(iconCssClass)) {
                iconCssClass = CSSHelper.createFiletypeIconCssClassFor(url);
            }
            links.add(new KalendarEventLink(provider, id, displayName, uri, iconCssClass));
            Kalendar cal = kalendarEvent.getCalendar();
            doneSuccessfully = calendarManager.updateEventFrom(cal, kalendarEvent);
        }
        if (doneSuccessfully) {
            fireEvent(ureq, event);
        } else {
            showError("cal.error.save");
            fireEvent(ureq, Event.FAILED_EVENT);
        }
    } else if (source == externalLinksController || source == mediaLinksController) {
        // save externals links
        Kalendar cal = kalendarEvent.getCalendar();
        if (kalendarEvent.getCalendar() != null) {
            boolean doneSuccessfully = calendarManager.updateEventFrom(cal, kalendarEvent);
            if (doneSuccessfully) {
                fireEvent(ureq, Event.DONE_EVENT);
            } else {
                showError("cal.error.save");
                fireEvent(ureq, Event.FAILED_EVENT);
            }
        }
    } else if (cmc == source) {
        cleanUp();
    }
}
Also used : CalendarGUIDeleteEvent(org.olat.commons.calendar.ui.events.CalendarGUIDeleteEvent) Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarGUIUpdateEvent(org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent) URLChoosenEvent(org.olat.core.commons.controllers.linkchooser.URLChoosenEvent) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink)

Example 4 with CalendarGUIUpdateEvent

use of org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent in project OpenOLAT by OpenOLAT.

the class CalendarEntryDetailsController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == deleteCtr) {
        if (event instanceof CalendarGUIDeleteEvent) {
            doDelete((CalendarGUIDeleteEvent) event);
            cmc.deactivate();
            cleanUp();
            fireEvent(ureq, Event.DONE_EVENT);
        } else {
            cmc.deactivate();
            cleanUp();
        }
    } else if (source == activeLinkProvider) {
        if (kalendarEvent.getCalendar() != null) {
            fireEvent(ureq, Event.DONE_EVENT);
        }
    } else if (source == eventForm) {
        if (event == Event.DONE_EVENT) {
            doSave(ureq);
        } else if ("delete".equals(event.getCommand())) {
            doConfirmDelete(ureq);
        } else if (event == Event.CANCELLED_EVENT) {
            eventForm.setEntry(kalendarEvent);
            // user canceled, finish workflow
            fireEvent(ureq, Event.DONE_EVENT);
        }
    } else if (source == updateCtr) {
        if (event instanceof CalendarGUIUpdateEvent) {
            doUpdate((CalendarGUIUpdateEvent) event);
            cmc.deactivate();
            cleanUp();
            fireEvent(ureq, Event.DONE_EVENT);
        } else {
            cmc.deactivate();
            cleanUp();
        }
    } else if (source == customMediaChooserCtr) {
        boolean doneSuccessfully = true;
        if (event instanceof URLChoosenEvent) {
            URLChoosenEvent urlEvent = (URLChoosenEvent) event;
            String url = urlEvent.getURL();
            List<KalendarEventLink> links = kalendarEvent.getKalendarEventLinks();
            String provider = customMediaChooserCtr.getClass().getSimpleName();
            String id = url;
            String displayName = StringHelper.containsNonWhitespace(urlEvent.getDisplayName()) ? urlEvent.getDisplayName() : url;
            String uri = url.contains("://") ? url : (Settings.getServerContextPathURI() + url);
            String iconCssClass = urlEvent.getIconCssClass();
            if (!StringHelper.containsNonWhitespace(iconCssClass)) {
                iconCssClass = CSSHelper.createFiletypeIconCssClassFor(url);
            }
            links.add(new KalendarEventLink(provider, id, displayName, uri, iconCssClass));
            Kalendar cal = kalendarEvent.getCalendar();
            doneSuccessfully = calendarManager.updateEventFrom(cal, kalendarEvent);
        }
        if (doneSuccessfully) {
            fireEvent(ureq, event);
        } else {
            showError("cal.error.save");
            fireEvent(ureq, Event.FAILED_EVENT);
        }
    } else if (source == externalLinksController || source == mediaLinksController) {
        // save externals links
        Kalendar cal = kalendarEvent.getCalendar();
        if (kalendarEvent.getCalendar() != null) {
            boolean doneSuccessfully = calendarManager.updateEventFrom(cal, kalendarEvent);
            if (doneSuccessfully) {
                fireEvent(ureq, Event.DONE_EVENT);
            } else {
                showError("cal.error.save");
                fireEvent(ureq, Event.FAILED_EVENT);
            }
        }
    } else if (cmc == source) {
        cleanUp();
    }
}
Also used : CalendarGUIDeleteEvent(org.olat.commons.calendar.ui.events.CalendarGUIDeleteEvent) Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarGUIUpdateEvent(org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent) URLChoosenEvent(org.olat.core.commons.controllers.linkchooser.URLChoosenEvent) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink)

Aggregations

Kalendar (org.olat.commons.calendar.model.Kalendar)4 CalendarGUIUpdateEvent (org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent)4 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)2 KalendarEventLink (org.olat.commons.calendar.model.KalendarEventLink)2 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)2 CalendarGUIDeleteEvent (org.olat.commons.calendar.ui.events.CalendarGUIDeleteEvent)2 CalendarGUIEditEvent (org.olat.commons.calendar.ui.events.CalendarGUIEditEvent)2 CalendarGUIImportEvent (org.olat.commons.calendar.ui.events.CalendarGUIImportEvent)2 CalendarGUIModifiedEvent (org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)2 CalendarGUIPrintEvent (org.olat.commons.calendar.ui.events.CalendarGUIPrintEvent)2 CalendarGUIRemoveEvent (org.olat.commons.calendar.ui.events.CalendarGUIRemoveEvent)2 CalendarGUISettingEvent (org.olat.commons.calendar.ui.events.CalendarGUISettingEvent)2 URLChoosenEvent (org.olat.core.commons.controllers.linkchooser.URLChoosenEvent)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2