use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class WeeklyCalendarController method pushEditEventController.
/**
* @param ureq
* @param kalendarEvent
* @param kalendarWrapper
*/
private void pushEditEventController(UserRequest ureq, KalendarEvent kalendarEvent, KalendarRenderWrapper kalendarWrapper) {
if (editController != null)
return;
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(editController);
boolean canEdit = false;
for (Iterator<KalendarRenderWrapper> iter = calendarWrappers.iterator(); iter.hasNext(); ) {
KalendarRenderWrapper wrapper = iter.next();
if (wrapper.getAccess() == KalendarRenderWrapper.ACCESS_READ_WRITE && kalendarWrapper.getKalendar().getCalendarID().equals(wrapper.getKalendar().getCalendarID())) {
canEdit = true;
}
}
if (canEdit) {
editController = new CalendarEntryDetailsController(ureq, kalendarEvent, kalendarWrapper, calendarWrappers, false, caller, getWindowControl());
listenTo(editController);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), editController.getInitialComponent());
listenTo(cmc);
cmc.activate();
// set logging action
setCalLoggingAction(CalendarLoggingAction.CALENDAR_ENTRY_MODIFIED);
} else {
showError("cal.error.readonly");
}
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class WeeklyCalendarController method pushAddEventController.
private void pushAddEventController(CalendarGUIAddEvent addEvent, UserRequest ureq) {
if (editController != null || ureq.getUserSession().getRoles().isGuestOnly()) {
return;
}
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(editController);
KalendarRenderWrapper calendarWrapper = calendarEl.getCalendar(addEvent.getCalendarID());
List<KalendarRenderWrapper> copyCalendarWrappers = new ArrayList<>(calendarWrappers);
boolean isReadOnly = calendarWrapper == null ? true : calendarWrapper.getAccess() == KalendarRenderWrapper.ACCESS_READ_ONLY;
for (KalendarRenderWrapper copyCalendarWrapper : copyCalendarWrappers) {
isReadOnly &= copyCalendarWrapper.getAccess() == KalendarRenderWrapper.ACCESS_READ_ONLY;
}
if (!isReadOnly) {
// create new KalendarEvent
KalendarEvent newEvent;
Date begin = addEvent.getStartDate();
String eventId = CodeHelper.getGlobalForeverUniqueID();
if (addEvent.getEndDate() == null) {
newEvent = new KalendarEvent(eventId, "", begin, (1000 * 60 * 60 * 1));
} else {
newEvent = new KalendarEvent(eventId, null, "", begin, addEvent.getEndDate());
}
if (calendarWrapper != null && (calendarWrapper.getKalendar().getType().equals(CalendarManager.TYPE_COURSE) || calendarWrapper.getKalendar().getType().equals(CalendarManager.TYPE_GROUP))) {
newEvent.setClassification(KalendarEvent.CLASS_PUBLIC);
}
newEvent.setAllDayEvent(addEvent.isAllDayEvent());
String lastName = ureq.getIdentity().getUser().getProperty(UserConstants.LASTNAME, getLocale());
String firstName = ureq.getIdentity().getUser().getProperty(UserConstants.FIRSTNAME, getLocale());
newEvent.setCreatedBy(firstName + " " + lastName);
newEvent.setCreated(new Date().getTime());
editController = new CalendarEntryDetailsController(ureq, newEvent, calendarWrapper, copyCalendarWrappers, true, caller, getWindowControl());
listenTo(editController);
cmc = new CloseableModalController(getWindowControl(), translate("close"), editController.getInitialComponent());
listenTo(cmc);
cmc.activate();
// set logging action
setCalLoggingAction(CalendarLoggingAction.CALENDAR_ENTRY_CREATED);
}
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class ICalFileCalendarManager method getCalendarForDeletion.
@Override
public KalendarRenderWrapper getCalendarForDeletion(OLATResourceable resource) {
String type;
if ("CourseModule".equals(resource.getResourceableTypeName())) {
type = CalendarManager.TYPE_COURSE;
} else {
type = CalendarManager.TYPE_GROUP;
}
Kalendar cal = getCalendar(type, resource.getResourceableId().toString());
KalendarRenderWrapper calendarWrapper = new KalendarRenderWrapper(cal, "To delete");
calendarWrapper.setCssClass(KalendarRenderWrapper.CALENDAR_COLOR_GREEN);
calendarWrapper.setVisible(true);
return calendarWrapper;
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class ICalFileCalendarManager method getImportedCalendar.
@Override
public KalendarRenderWrapper getImportedCalendar(Identity identity, String calendarId) {
Kalendar cal = getCalendar(CalendarManager.TYPE_USER, calendarId);
KalendarRenderWrapper calendarWrapper = new KalendarRenderWrapper(cal, calendarId);
calendarWrapper.setCssClass(KalendarRenderWrapper.CALENDAR_COLOR_BLUE);
calendarWrapper.setVisible(true);
calendarWrapper.setImported(true);
return calendarWrapper;
}
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, String url) throws IOException {
File tmpFile = new File(WebappHelper.getTmpDir(), UUID.randomUUID() + ".ics");
try (InputStream in = new URL(url).openStream()) {
Files.copy(in, tmpFile.toPath());
} catch (IOException e) {
throw e;
}
KalendarRenderWrapper calendarWrapper = null;
Calendar calendar = calendarManager.readCalendar(tmpFile);
if (calendar != null) {
String calendarID = getImportedCalendarID(identity, calendarName);
File calendarFile = calendarManager.getCalendarFile(type, calendarID);
if (!tmpFile.renameTo(calendarFile)) {
Files.copy(tmpFile.toPath(), calendarFile.toPath());
}
importedCalendarDao.createImportedCalendar(identity, calendarName, calendarID, type, url, new Date());
calendarWrapper = calendarManager.getImportedCalendar(identity, calendarID);
calendarWrapper.setDisplayName(calendarName);
calendarWrapper.setPrivateEventsVisible(true);
}
return calendarWrapper;
}
Aggregations