use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class ImportCalendarManager method importCalendar.
public KalendarRenderWrapper importCalendar(Identity identity, String calendarName, String type, File file) throws IOException {
KalendarRenderWrapper calendarWrapper = null;
Calendar calendar = calendarManager.readCalendar(file);
if (calendar != null) {
String calendarID = getImportedCalendarID(identity, calendarName);
File calendarFile = calendarManager.getCalendarFile(type, calendarID);
if (!file.renameTo(calendarFile)) {
Files.copy(file.toPath(), calendarFile.toPath());
}
importedCalendarDao.createImportedCalendar(identity, calendarName, calendarID, type, null, new Date());
calendarWrapper = calendarManager.getImportedCalendar(identity, calendarID);
calendarWrapper.setDisplayName(calendarName);
calendarWrapper.setPrivateEventsVisible(true);
}
return calendarWrapper;
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class ImportCalendarManager method getImportedCalendarsForIdentity.
/**
* Get imported calendars for a user.
* @param ureq
* @return
*/
public List<KalendarRenderWrapper> getImportedCalendarsForIdentity(Identity identity, boolean reload) {
// initialize the calendars list
List<KalendarRenderWrapper> calendars = new ArrayList<KalendarRenderWrapper>();
if (calendarModule.isEnabled() && calendarModule.isEnablePersonalCalendar()) {
long timestamp = System.currentTimeMillis();
List<ImportedCalendar> importedCalendars = importedCalendarDao.getImportedCalendars(identity);
KalendarEventFilter filter = new KalendarEventFilter(identity, importedCalendars);
for (ImportedCalendar importedCalendar : importedCalendars) {
try {
if (reload) {
reloadImportCalendar(importedCalendar, timestamp, filter);
}
String calendarId = importedCalendar.getCalendarId();
KalendarRenderWrapper calendarWrapper = calendarManager.getImportedCalendar(identity, calendarId);
calendarWrapper.setDisplayName(importedCalendar.getDisplayName());
calendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
calendarWrapper.setImported(true);
CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(calendarWrapper.getKalendar(), identity);
if (config != null) {
calendarWrapper.setConfiguration(config);
}
calendars.add(calendarWrapper);
} catch (Exception e) {
log.error("Cannot read an imported file", e);
}
}
Collections.sort(calendars, KalendarComparator.getInstance());
}
return calendars;
}
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);
}
}
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);
}
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));
}
Aggregations