Search in sources :

Example 41 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.

the class CopyEventToCalendarController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("cal.copy.title");
    copyEls = new ArrayList<>(calendars.size());
    for (KalendarRenderWrapper calendarWrapper : calendars) {
        String calId = calendarWrapper.getKalendar().getCalendarID();
        String value = calendarWrapper.getDisplayName();
        MultipleSelectionElement copyEl = uifactory.addCheckboxesHorizontal("cal_" + calId, null, formLayout, copy, new String[] { value });
        copyEl.setUserObject(calendarWrapper);
        if (calendarWrapper.getKalendar().getCalendarID().equals(kalendarEvent.getCalendar().getCalendarID())) {
            // this is the calendar, the event comes from
            copyEl.select(copy[0], true);
            copyEl.setEnabled(false);
        } else {
            copyEl.setEnabled(calendarWrapper.getAccess() == KalendarRenderWrapper.ACCESS_READ_WRITE);
        }
    }
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 42 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class ModifyCourseEvent method clearCalenderSubscriptions.

/**
 * Checks all learning group calendars and the course calendar for publishers (of subscriptions)
 * and sets their state to "1" which indicates that the ressource is deleted.
 */
private static void clearCalenderSubscriptions(OLATResourceable res, ICourse course) {
    // set Publisher state to 1 (= ressource is deleted) for all calendars of the course
    CalendarManager calMan = CoreSpringFactory.getImpl(CalendarManager.class);
    CalendarNotificationManager notificationManager = CoreSpringFactory.getImpl(CalendarNotificationManager.class);
    NotificationsManager nfm = NotificationsManager.getInstance();
    if (course != null) {
        CourseGroupManager courseGroupManager = course.getCourseEnvironment().getCourseGroupManager();
        List<BusinessGroup> learningGroups = courseGroupManager.getAllBusinessGroups();
        // all learning and right group calendars
        for (BusinessGroup bg : learningGroups) {
            KalendarRenderWrapper calRenderWrapper = calMan.getGroupCalendar(bg);
            SubscriptionContext subsContext = notificationManager.getSubscriptionContext(calRenderWrapper);
            Publisher pub = nfm.getPublisher(subsContext);
            if (pub != null) {
                // int 0 is OK -> all other is not OK
                pub.setState(1);
            }
        }
    }
    // the course calendar
    try {
        /**
         * TODO:gs 2010-01-26
         * OLAT-4947: if we do not have an repo entry we get an exception here.
         * This is normal in the case of courseimport and click canceling.
         */
        KalendarRenderWrapper courseCalendar = calMan.getCalendarForDeletion(res);
        if (courseCalendar != null) {
            SubscriptionContext subContext = notificationManager.getSubscriptionContext(courseCalendar, res);
            OLATResourceable oresToDelete = OresHelper.createOLATResourceableInstance(subContext.getResName(), subContext.getResId());
            nfm.deletePublishersOf(oresToDelete);
        }
    } catch (AssertException e) {
    // if we have a broken course (e.g. canceled import or no repo entry somehow) skip calendar deletion...
    }
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) PersistingCourseGroupManager(org.olat.course.groupsandrights.PersistingCourseGroupManager) ImportToCalendarManager(org.olat.commons.calendar.manager.ImportToCalendarManager) CalendarManager(org.olat.commons.calendar.CalendarManager) CalendarNotificationManager(org.olat.commons.calendar.CalendarNotificationManager) AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) OLATResourceable(org.olat.core.id.OLATResourceable) NotificationsManager(org.olat.core.commons.services.notifications.NotificationsManager) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Publisher(org.olat.core.commons.services.notifications.Publisher) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 43 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CalendarPersonalConfigurationController method doToogleVisibility.

private void doToogleVisibility(UserRequest ureq, CalendarPersonalConfigurationRow row) {
    KalendarRenderWrapper calendarWrapper = row.getWrapper();
    calendarWrapper.setVisible(!calendarWrapper.isVisible());
    calendarManager.saveCalendarConfigForIdentity(calendarWrapper, getIdentity());
    enableDisableIcons(row.getVisibleLink(), calendarWrapper.isVisible());
    fireEvent(ureq, new CalendarGUISettingEvent(calendarWrapper));
}
Also used : CalendarGUISettingEvent(org.olat.commons.calendar.ui.events.CalendarGUISettingEvent) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 44 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CalendarPersonalConfigurationController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (calloutCtrl == source || cmc == source) {
        cleanUp();
    } else if (source == confirmRemoveTokenDialog) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            doDeleteToken((CalendarPersonalConfigurationRow) confirmRemoveTokenDialog.getUserObject());
            showInfo("cal.icalfeed.remove.info");
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
    } else if (source == confirmDeleteCalendarDialog) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            doDeleteCalendar(ureq, (CalendarPersonalConfigurationRow) confirmDeleteCalendarDialog.getUserObject());
            showInfo("cal.import.remove.info");
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
    } else if (calendarFileUploadCtrl == source) {
        KalendarRenderWrapper calendar = calendarFileUploadCtrl.getImportedCalendar();
        cmc.deactivate();
        cleanUp();
        if (event == Event.DONE_EVENT) {
            doImportCalendar(calendar);
            fireEvent(ureq, new CalendarGUIImportEvent(calendar));
        }
    } else if (calendarUrlImportCtrl == source) {
        KalendarRenderWrapper calendar = calendarUrlImportCtrl.getImportedCalendar();
        cmc.deactivate();
        cleanUp();
        if (event == Event.DONE_EVENT) {
            doImportCalendar(calendar);
            fireEvent(ureq, new CalendarGUIImportEvent(calendar));
        }
    } else if (calendarToolsCtrl == source) {
        CalendarPersonalConfigurationRow row = calendarToolsCtrl.getRow();
        calloutCtrl.deactivate();
        cleanUp();
        if (CalendarGUIEvent.IMPORT_BY_FILE.equals(event.getCommand())) {
            doOpenInjectCalendarFile(ureq, row);
        } else if (CalendarGUIEvent.IMPORT_SYNCHRONIZED_URL.equals(event.getCommand())) {
            doOpenSynchronizedCalendarUrl(ureq, row);
        } else if (CalendarGUIEvent.DELETE_TOKEN.equals(event.getCommand())) {
            doConfirmDeleteToken(ureq, row);
        } else if (CalendarGUIEvent.DELETE_CALENDAR.equals(event.getCommand())) {
            doConfirmDeleteCalendar(ureq, row);
        }
    } else if (injectCalendarFileCtrl == source || synchronizedCalendarUrlCtrl == source) {
        cmc.deactivate();
        cleanUp();
    } else if (colorChooserCtrl == source) {
        if (event == Event.DONE_EVENT) {
            doSetColor(ureq, colorChooserCtrl.getRow(), colorChooserCtrl.getChoosenColor());
        }
        calloutCtrl.deactivate();
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : CalendarGUIImportEvent(org.olat.commons.calendar.ui.events.CalendarGUIImportEvent) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 45 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CalendarPersonalConfigurationController method doShowFeedURL.

private void doShowFeedURL(UserRequest ureq, FormLink link, CalendarPersonalConfigurationRow row) {
    removeAsListenerAndDispose(feedUrlCtrl);
    removeAsListenerAndDispose(calloutCtrl);
    KalendarRenderWrapper calendarWrapper = row.getWrapper();
    if (!StringHelper.containsNonWhitespace(row.getToken())) {
        calendarWrapper.setToken(RandomStringUtils.randomAlphanumeric(6));
        calendarManager.saveCalendarConfigForIdentity(calendarWrapper, getIdentity());
    }
    String calFeedLink = row.getFeedUrl(getIdentity());
    feedUrlCtrl = new CalendarURLController(ureq, getWindowControl(), calFeedLink);
    listenTo(feedUrlCtrl);
    calloutCtrl = new CloseableCalloutWindowController(ureq, getWindowControl(), feedUrlCtrl.getInitialComponent(), link.getFormDispatchId(), "", true, "");
    listenTo(calloutCtrl);
    calloutCtrl.activate();
}
Also used : CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Aggregations

KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)134 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)46 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)28 Identity (org.olat.core.id.Identity)26 Date (java.util.Date)24 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)24 Calendar (java.util.Calendar)22 Kalendar (org.olat.commons.calendar.model.Kalendar)22 ICourse (org.olat.course.ICourse)20 File (java.io.File)18 BusinessGroup (org.olat.group.BusinessGroup)16 URI (java.net.URI)14 HttpResponse (org.apache.http.HttpResponse)14 CalendarImportTest (org.olat.commons.calendar.CalendarImportTest)14 URL (java.net.URL)12 EventVO (org.olat.commons.calendar.restapi.EventVO)12 CalendarManager (org.olat.commons.calendar.CalendarManager)10 HttpGet (org.apache.http.client.methods.HttpGet)8 UserRequest (org.olat.core.gui.UserRequest)8