Search in sources :

Example 11 with CalendarGUIModifiedEvent

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

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

the class WeeklyCalendarController method event.

@Override
public void event(Event event) {
    if (event instanceof CalendarGUIModifiedEvent) {
        CalendarGUIModifiedEvent kalendarModifiedEvent = (CalendarGUIModifiedEvent) event;
        if (kalendarModifiedEvent.getType() != null && kalendarModifiedEvent.getCalendarId() != null && calendarEl.getCalendar(kalendarModifiedEvent.getCalendarId()) != null && kalendarModifiedEvent.getType().equals(calendarEl.getCalendar(kalendarModifiedEvent.getCalendarId()).getKalendar().getType()) && kalendarModifiedEvent.getCalendarId().equals(calendarEl.getCalendar(kalendarModifiedEvent.getCalendarId()).getKalendar().getCalendarID())) {
            // the event is for my calendar => reload it
            // keeping a reference to the dirty calendar as reloading here raises an nested do in sync error. Using the component validation event to reload
            modifiedCalendarId = kalendarModifiedEvent.getCalendarId();
            modifiedCalenderDirty = true;
            calendarEl.getComponent().setDirty(true);
        }
    }
}
Also used : CalendarGUIModifiedEvent(org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)

Example 13 with CalendarGUIModifiedEvent

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

the class ICalFileCalendarManager method removeOccurenceOfEvent.

@Override
public boolean removeOccurenceOfEvent(final Kalendar cal, final KalendarRecurEvent kalendarEvent) {
    OLATResourceable calOres = getOresHelperFor(cal);
    Boolean removeSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {

        @Override
        public Boolean execute() {
            String uid = kalendarEvent.getID();
            Date occurenceDate = kalendarEvent.getBegin();
            Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
            KalendarEvent rootEvent = loadedCal.getEvent(kalendarEvent.getID(), null);
            rootEvent.addRecurrenceExc(kalendarEvent.getBegin());
            for (KalendarEvent kEvent : loadedCal.getEvents()) {
                if (uid.equals(kEvent.getID()) && kEvent.getOccurenceDate() != null && occurenceDate.equals(kEvent.getOccurenceDate())) {
                    loadedCal.removeEvent(kEvent);
                }
            }
            boolean successfullyPersist = persistCalendar(loadedCal);
            return new Boolean(successfullyPersist);
        }
    });
    // inform all controller about calendar change for reload
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
    return removeSuccessful.booleanValue();
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) Kalendar(org.olat.commons.calendar.model.Kalendar) OLATResourceable(org.olat.core.id.OLATResourceable) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) Date(java.util.Date) ExDate(net.fortuna.ical4j.model.property.ExDate) CalendarGUIModifiedEvent(org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)

Example 14 with CalendarGUIModifiedEvent

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

the class ICalFileCalendarManager method addEventTo.

@Override
public boolean addEventTo(final Kalendar cal, final List<KalendarEvent> kalendarEvents) {
    OLATResourceable calOres = getOresHelperFor(cal);
    Boolean persistSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {

        @Override
        public Boolean execute() {
            Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
            for (KalendarEvent kalendarEvent : kalendarEvents) {
                loadedCal.addEvent(kalendarEvent);
                kalendarEvent.resetImmutableDates();
            }
            boolean successfullyPersist = persistCalendar(loadedCal);
            return new Boolean(successfullyPersist);
        }
    });
    // inform all controller about calendar change for reload
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
    return persistSuccessful.booleanValue();
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) Kalendar(org.olat.commons.calendar.model.Kalendar) OLATResourceable(org.olat.core.id.OLATResourceable) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) CalendarGUIModifiedEvent(org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)

Example 15 with CalendarGUIModifiedEvent

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

the class ChoiceOfToolsForm method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup);
    if (source == cots && event.getCommand().equals("ONCHANGE")) {
        Collection<String> set = cots.getSelected();
        for (int i = 0; i < availableTools.length; i++) {
            // usually one should check which one changed but here
            // it is okay to set all of them because ctsm has a cache
            // and writes only when really necessary.
            collabTools.setToolEnabled(availableTools[i], set.contains("" + i));
        }
        // reload tools after a change
        collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup);
        fireEvent(ureq, Event.CHANGED_EVENT);
        // update news form: only show when enabled
        if (collabTools.isToolEnabled(CollaborationTools.TOOL_NEWS)) {
            addNewsTool(ureq);
        } else {
            vc_collabtools.contextPut("newsToolEnabled", Boolean.FALSE);
        }
        // update calendar form: only show when enabled
        boolean newCalendarEnabledState = collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR);
        if (newCalendarEnabledState != lastCalendarEnabledState) {
            if (newCalendarEnabledState) {
                vc_collabtools.contextPut("calendarToolEnabled", Boolean.TRUE);
                int iCalendarAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
                Long lCalendarAccess = collabTools.lookupCalendarAccess();
                if (lCalendarAccess != null)
                    iCalendarAccess = lCalendarAccess.intValue();
                if (calendarForm != null) {
                    this.removeAsListenerAndDispose(calendarForm);
                }
                calendarForm = new CalendarToolSettingsController(ureq, getWindowControl(), iCalendarAccess);
                calendarForm.setEnabled(!managed);
                listenTo(calendarForm);
                vc_collabtools.put("calendarform", calendarForm.getInitialComponent());
            } else {
                vc_collabtools.contextPut("calendarToolEnabled", Boolean.FALSE);
                // notify calendar components to refresh their calendars
                CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(), OresHelper.lookupType(CalendarManager.class));
            }
            lastCalendarEnabledState = newCalendarEnabledState;
        }
        // update quota form: only show when enabled
        if (collabTools.isToolEnabled(CollaborationTools.TOOL_FOLDER)) {
            vc_collabtools.contextPut("folderToolEnabled", Boolean.TRUE);
            if (folderForm != null) {
                removeAsListenerAndDispose(folderForm);
            }
            Long lFolderAccess = collabTools.lookupFolderAccess();
            int access = lFolderAccess == null ? CollaborationTools.FOLDER_ACCESS_ALL : lFolderAccess.intValue();
            folderForm = new FolderToolSettingsController(ureq, getWindowControl(), access);
            folderForm.setEnabled(!managed);
            listenTo(folderForm);
            vc_collabtools.put("folderform", folderForm.getInitialComponent());
            if (ureq.getUserSession().getRoles().isOLATAdmin()) {
                vc_collabtools.put("quota", quotaCtr.getInitialComponent());
            }
        } else {
            vc_collabtools.contextPut("folderToolEnabled", Boolean.FALSE);
        }
    } else if (source == newsController) {
        if (event.equals(Event.DONE_EVENT)) {
            String access = newsController.getAccessPropertyValue();
            collabTools.saveNewsAccessProperty(access);
        }
    } else if (source == calendarForm) {
        collabTools.saveCalendarAccess(new Long(calendarForm.getCalendarAccess()));
        // notify calendar components to refresh their calendars
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(), OresHelper.lookupType(CalendarManager.class));
    } else if (source == folderForm) {
        collabTools.saveFolderAccess(new Long(folderForm.getFolderAccess()));
    }
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) CalendarGUIModifiedEvent(org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)

Aggregations

CalendarGUIModifiedEvent (org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)26 Kalendar (org.olat.commons.calendar.model.Kalendar)18 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)18 OLATResourceable (org.olat.core.id.OLATResourceable)18 CalendarManager (org.olat.commons.calendar.CalendarManager)14 Date (java.util.Date)8 ExDate (net.fortuna.ical4j.model.property.ExDate)8 ParseException (java.text.ParseException)6 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)4 BufferedReader (java.io.BufferedReader)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStreamReader (java.io.InputStreamReader)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CalendarBuilder (net.fortuna.ical4j.data.CalendarBuilder)2 Calendar (net.fortuna.ical4j.model.Calendar)2 Recur (net.fortuna.ical4j.model.Recur)2