Search in sources :

Example 31 with KalendarRenderWrapper

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

the class CalendarEntryDetailsController method doSave.

private void doSave(UserRequest ureq) {
    // ok, save edited entry
    kalendarEvent = eventForm.getUpdatedKalendarEvent();
    if (isNew) {
        boolean doneSuccessfully = true;
        // this is a new event, add event to calendar
        String calendarID = eventForm.getChoosenKalendarID();
        for (Iterator<KalendarRenderWrapper> iter = availableCalendars.iterator(); iter.hasNext(); ) {
            KalendarRenderWrapper calendarWrapper = iter.next();
            if (!calendarWrapper.getKalendar().getCalendarID().equals(calendarID)) {
                continue;
            }
            Kalendar cal = calendarWrapper.getKalendar();
            boolean result = calendarManager.addEventTo(cal, kalendarEvent);
            if (result == false) {
                // if one failed => done not successfully
                doneSuccessfully = false;
            }
        }
        reportSaveStatus(ureq, doneSuccessfully);
    } else if (kalendarEvent instanceof KalendarRecurEvent && !StringHelper.containsNonWhitespace(kalendarEvent.getRecurrenceID())) {
        updateCtr = new ConfirmUpdateController(ureq, getWindowControl(), (KalendarRecurEvent) kalendarEvent);
        listenTo(updateCtr);
        String title = translate("cal.edit.update");
        cmc = new CloseableModalController(getWindowControl(), translate("close"), updateCtr.getInitialComponent(), true, title);
        listenTo(cmc);
        cmc.activate();
    } else {
        // this is an existing event, so we get the previousely assigned calendar from the event
        Kalendar cal = kalendarEvent.getCalendar();
        boolean doneSuccessfully = calendarManager.updateEventFrom(cal, kalendarEvent);
        reportSaveStatus(ureq, doneSuccessfully);
    }
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) KalendarRecurEvent(org.olat.commons.calendar.model.KalendarRecurEvent) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 32 with KalendarRenderWrapper

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

the class CalendarPersonalConfigurationController method doToogleAggregated.

private void doToogleAggregated(UserRequest ureq, CalendarPersonalConfigurationRow row) {
    KalendarRenderWrapper calendarWrapper = row.getWrapper();
    calendarWrapper.setInAggregatedFeed(!calendarWrapper.isInAggregatedFeed());
    calendarManager.saveCalendarConfigForIdentity(calendarWrapper, getIdentity());
    enableDisableIcons(row.getAggregatedLink(), calendarWrapper.isInAggregatedFeed());
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 33 with KalendarRenderWrapper

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

the class CalendarPersonalConfigurationController method doSetColor.

private void doSetColor(UserRequest ureq, CalendarPersonalConfigurationRow row, String cssColor) {
    KalendarRenderWrapper calendarWrapper = row.getWrapper();
    calendarWrapper.setCssClass(cssColor);
    calendarManager.saveCalendarConfigForIdentity(calendarWrapper, getIdentity());
    row.getColorLink().setIconLeftCSS("o_cal_config_color ".concat(row.getCssClass()));
    fireEvent(ureq, new CalendarGUISettingEvent(calendarWrapper));
}
Also used : CalendarGUISettingEvent(org.olat.commons.calendar.ui.events.CalendarGUISettingEvent) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 34 with KalendarRenderWrapper

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

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 35 with KalendarRenderWrapper

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

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