public void event(UserRequest ureq, Component source, Event event) {
if (event == ComponentUtil.VALIDATE_EVENT && dirty) {
dirty = false;
fireEvent(ureq, new KalendarModifiedEvent());
} else if (event == ComponentUtil.VALIDATE_EVENT && weeklyCalendar.isDirty() && modifiedCalenderDirty ) {
KalendarRenderWrapper kalendarRenderWrapper = weeklyCalendar.getKalendarRenderWrapper(modifiedCalendarId);
kalendarRenderWrapper.reloadKalendar();
}else if (source == vcMain) {
if (event.getCommand().equals(CMD_PREVIOUS_WEEK)) {
weeklyCalendar.previousWeek();
} else if (event.getCommand().equals(CMD_NEXT_WEEK)) {
weeklyCalendar.nextWeek();
}
} else if (source == thisWeekLink){
Calendar cal = CalendarUtils.createCalendarInstance(ureq.getLocale());
weeklyCalendar.setFocus(cal.get(Calendar.YEAR), cal.get(Calendar.WEEK_OF_YEAR));
} else if (source == searchLink) {
if (searchController != null) searchController.dispose();
ArrayList allCalendarWrappers = new ArrayList(calendarWrappers);
allCalendarWrappers.addAll(importedCalendarWrappers);
searchController = new SearchAllCalendarsController(ureq, getWindowControl(), translator, allCalendarWrappers);
searchController.addControllerListener(this);
if (cmc != null) cmc.dispose();
cmc = new CloseableModalController(getWindowControl(), translator.translate("close"), searchController.getInitialComponent());
cmc.activate();
} else if (source == subscribeButton || source == unsubscribeButton) {
if (subscriptionController != null) subscriptionController.dispose();
if(calendarSubscription.isSubscribed() == (source == unsubscribeButton)) {
subscriptionController = calendarSubscription.triggerSubscribeAction();
}
if (subscriptionController != null) {
// activate subscription controller
subscriptionController.addControllerListener(this);
mainPanel.setContent(subscriptionController.getInitialComponent());
} else {
vcMain.contextPut("isSubscribed", new Boolean(calendarSubscription.isSubscribed()));
CoordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(new KalendarModifiedEvent(), OresHelper.lookupType(CalendarManager.class));
}
} else if (source == weeklyCalendar) {
if (event instanceof KalendarGUIEditEvent) {
KalendarGUIEditEvent guiEvent = (KalendarGUIEditEvent) event;
KalendarEvent kalendarEvent = guiEvent.getKalendarEvent();
if (kalendarEvent == null) {
// event already deleted
getWindowControl().setError(translator.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<String>();
btnLabels.add(translator.translate("cal.edit.dialog.sequence"));
btnLabels.add(translator.translate("cal.edit.dialog.delete.single"));
btnLabels.add(translator.translate("cal.edit.dialog.delete.sequence"));
if (dbcSequence != null) dbcSequence.dispose();
dbcSequence = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translator.translate("cal.edit.dialog.title"), translator.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 KalendarGUIAddEvent) {
pushAddEventController((KalendarGUIAddEvent)event, ureq);
}
}