use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class WeeklyCalendarController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == calendarEl) {
if (event instanceof CalendarGUIEditEvent) {
CalendarGUIEditEvent guiEvent = (CalendarGUIEditEvent) event;
KalendarEvent kalendarEvent = guiEvent.getKalendarEvent();
if (kalendarEvent == null) {
// event already deleted
getWindowControl().setError(translate("cal.error.eventDeleted"));
return;
}
String recurrence = kalendarEvent.getRecurrenceRule();
boolean isImported = false;
KalendarRenderWrapper kalendarRenderWrapper = guiEvent.getKalendarRenderWrapper();
if (kalendarRenderWrapper != null) {
isImported = kalendarRenderWrapper.isImported();
}
if (!isImported && recurrence != null && !recurrence.equals("")) {
List<String> btnLabels = new ArrayList<>(3);
btnLabels.add(translate("cal.edit.dialog.sequence"));
btnLabels.add(translate("cal.edit.dialog.delete.single"));
btnLabels.add(translate("cal.edit.dialog.delete.sequence"));
if (dbcSequence != null) {
dbcSequence.dispose();
}
dbcSequence = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("cal.edit.dialog.title"), translate("cal.edit.dialog.text"), btnLabels);
dbcSequence.addControllerListener(this);
dbcSequence.setUserObject(guiEvent);
dbcSequence.activate();
return;
}
KalendarRenderWrapper kalendarWrapper = guiEvent.getKalendarRenderWrapper();
pushEditEventController(ureq, kalendarEvent, kalendarWrapper);
} else if (event instanceof CalendarGUIAddEvent) {
pushAddEventController((CalendarGUIAddEvent) event, ureq);
} else if (event instanceof CalendarGUISelectEvent) {
CalendarGUISelectEvent selectEvent = (CalendarGUISelectEvent) event;
if (selectEvent.getKalendarEvent() != null) {
doOpenEventCallout(ureq, selectEvent.getKalendarEvent(), selectEvent.getKalendarRenderWrapper(), selectEvent.getTargetDomId());
}
} else if (event instanceof CalendarGUIMoveEvent) {
CalendarGUIMoveEvent moveEvent = (CalendarGUIMoveEvent) event;
doMove(ureq, moveEvent.getKalendarEvent(), moveEvent.getDayDelta(), moveEvent.getMinuteDelta(), moveEvent.getAllDay());
} else if (event instanceof CalendarGUIResizeEvent) {
CalendarGUIResizeEvent resizeEvent = (CalendarGUIResizeEvent) event;
doResize(ureq, resizeEvent.getKalendarEvent(), resizeEvent.getMinuteDelta(), resizeEvent.getAllDay());
} else if (event instanceof CalendarGUIFormEvent) {
String cmd = event.getCommand();
if (CalendarGUIFormEvent.CONFIGURE.equals(cmd)) {
doConfigure(ureq);
} else if (CalendarGUIFormEvent.AGGREGATED_FEED.equals(cmd)) {
CalendarGUIFormEvent guiEvent = (CalendarGUIFormEvent) event;
doOpenAggregatedFeedUrl(ureq, guiEvent.getTargetDomId());
}
} else if (event instanceof CalendarGUIPrintEvent) {
CalendarGUIPrintEvent printEvent = (CalendarGUIPrintEvent) event;
if (printEvent.getFrom() != null && printEvent.getTo() != null) {
doPrint(printEvent.getFrom(), printEvent.getTo());
} else if (printEvent.getTargetDomId() != null) {
doPrintEventCallout(ureq, printEvent.getTargetDomId());
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class WeeklyCalendarController method event.
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (event == ComponentUtil.VALIDATE_EVENT && dirty) {
dirty = false;
fireEvent(ureq, new CalendarGUIModifiedEvent());
} else if (event == ComponentUtil.VALIDATE_EVENT && calendarEl.getComponent().isDirty() && modifiedCalenderDirty) {
KalendarRenderWrapper kalendarRenderWrapper = calendarEl.getCalendar(modifiedCalendarId);
kalendarRenderWrapper.reloadKalendar();
}
super.event(ureq, source, event);
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper 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);
}
}
}
}
}
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);
}
}
Aggregations