use of org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent in project OpenOLAT by OpenOLAT.
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.events.CalendarGUIModifiedEvent in project OpenOLAT by OpenOLAT.
the class WeeklyCalendarController method event.
@Override
public void event(Event event) {
if (event instanceof CalendarGUIModifiedEvent) {
CalendarGUIModifiedEvent kalendarModifiedEvent = (CalendarGUIModifiedEvent) event;
if (kalendarModifiedEvent.getType() != null && kalendarModifiedEvent.getCalendarId() != null && calendarEl.getCalendar(kalendarModifiedEvent.getCalendarId()) != null && kalendarModifiedEvent.getType().equals(calendarEl.getCalendar(kalendarModifiedEvent.getCalendarId()).getKalendar().getType()) && kalendarModifiedEvent.getCalendarId().equals(calendarEl.getCalendar(kalendarModifiedEvent.getCalendarId()).getKalendar().getCalendarID())) {
// the event is for my calendar => reload it
// keeping a reference to the dirty calendar as reloading here raises an nested do in sync error. Using the component validation event to reload
modifiedCalendarId = kalendarModifiedEvent.getCalendarId();
modifiedCalenderDirty = true;
calendarEl.getComponent().setDirty(true);
}
}
}
use of org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent in project OpenOLAT by OpenOLAT.
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.events.CalendarGUIModifiedEvent in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManager method removeFutureOfEvent.
@Override
public boolean removeFutureOfEvent(Kalendar cal, KalendarRecurEvent kalendarEvent) {
OLATResourceable calOres = getOresHelperFor(cal);
Boolean removeSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {
@Override
public Boolean execute() {
boolean successfullyPersist = false;
try {
String uid = kalendarEvent.getID();
Date occurenceDate = kalendarEvent.getOccurenceDate();
Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
KalendarEvent rootEvent = loadedCal.getEvent(kalendarEvent.getID(), null);
String rRule = rootEvent.getRecurrenceRule();
Recur recur = new Recur(rRule);
recur.setUntil(CalendarUtils.createDate(occurenceDate));
RRule rrule = new RRule(recur);
rootEvent.setRecurrenceRule(rrule.getValue());
for (KalendarEvent kEvent : loadedCal.getEvents()) {
if (uid.equals(kEvent.getID()) && StringHelper.containsNonWhitespace(kEvent.getRecurrenceID()) && occurenceDate.before(kEvent.getBegin())) {
loadedCal.removeEvent(kEvent);
}
}
successfullyPersist = persistCalendar(loadedCal);
} catch (ParseException e) {
log.error("", e);
}
return new Boolean(successfullyPersist);
}
});
// inform all controller about calendar change for reload
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
return removeSuccessful.booleanValue();
}
use of org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManager method removeEventFrom.
/**
* @see org.olat.commons.calendar.CalendarManager#removeEventFrom(org.olat.commons.calendar.model.Kalendar, org.olat.commons.calendar.model.KalendarEvent)
*/
@Override
public boolean removeEventFrom(final Kalendar cal, final KalendarEvent kalendarEvent) {
OLATResourceable calOres = getOresHelperFor(cal);
Boolean removeSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {
@Override
public Boolean execute() {
String uid = kalendarEvent.getID();
String recurrenceId = kalendarEvent.getRecurrenceID();
Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
if (StringHelper.containsNonWhitespace(recurrenceId)) {
loadedCal.removeEvent(kalendarEvent);
KalendarEvent rootEvent = loadedCal.getEvent(kalendarEvent.getID(), null);
if (rootEvent != null && kalendarEvent instanceof KalendarRecurEvent) {
Date recurrenceDate = ((KalendarRecurEvent) kalendarEvent).getOccurenceDate();
rootEvent.addRecurrenceExc(recurrenceDate);
}
} else {
for (KalendarEvent kEvent : loadedCal.getEvents()) {
if (uid.equals(kEvent.getID())) {
loadedCal.removeEvent(kEvent);
}
}
}
boolean successfullyPersist = persistCalendar(loadedCal);
return new Boolean(successfullyPersist);
}
});
// inform all controller about calendar change for reload
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
return removeSuccessful.booleanValue();
}
Aggregations