Search in sources :

Example 1 with CalendarGUIDeleteEvent

use of org.olat.commons.calendar.ui.events.CalendarGUIDeleteEvent 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 2 with CalendarGUIDeleteEvent

use of org.olat.commons.calendar.ui.events.CalendarGUIDeleteEvent 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)2 KalendarEventLink (org.olat.commons.calendar.model.KalendarEventLink)2 CalendarGUIDeleteEvent (org.olat.commons.calendar.ui.events.CalendarGUIDeleteEvent)2 CalendarGUIUpdateEvent (org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent)2 URLChoosenEvent (org.olat.core.commons.controllers.linkchooser.URLChoosenEvent)2