for (int i = 0; i < writeableCalendars.size(); i++) {
KalendarRenderWrapper cw = (KalendarRenderWrapper)writeableCalendars.get(i);
calendarKeys[i] = cw.getKalendar().getCalendarID();
calendarValues[i] = cw.getKalendarConfig().getDisplayName();
}
chooseCalendar = new StaticSingleSelectionElement("cal.form.chooseCalendar", calendarKeys, calendarValues);
// preselect calendar if available
chooseCalendar.select(choosenWrapper.getKalendar().getCalendarID(), true);
addFormElement("cal.form.chooseCalendar", chooseCalendar);
} else {
// display calendar name
calendarName = new StaticTextElement("cal.form.calendarname", choosenWrapper.getKalendarConfig().getDisplayName());
addFormElement("cal.form.calendarname", calendarName);
}
// subject (hide if in readonly mode and only free/busy flag)
subject = new TextAreaElement("cal.form.subject", 3, 40);
subject.setMandatory(true);
if (readOnly && event.getClassification() == KalendarEvent.CLASS_X_FREEBUSY) {
subject.setValue(getTranslator().translate("cal.form.subject.hidden"));
} else {
subject.setValue(event.getSubject());
}
addFormElement("cal.form.subject", subject);
// location (hide if in readonly mode and only free/busy flag)
location = new TextAreaElement("cal.form.location", 3, 40);
location.setMandatory(false);
if (readOnly && event.getClassification() == KalendarEvent.CLASS_X_FREEBUSY) {
location.setValue(getTranslator().translate("cal.form.location.hidden"));
} else {
location.setValue(event.getLocation());
}
addFormElement("cal.form.location", location);
// start
begin = new DateElement("cal.form.begin", event.getBegin(), "dd.MM.yyyy HH:mm");
begin.setMandatory(true);
begin.setDateChooserTimeEnabled(true);
begin.setDateChooserDateFormat("%d.%m.%Y %H:%M");
begin.setExample(begin.getExample());
addFormElement("cal.form.begin", begin);
// end
end = new DateElement("cal.form.end", event.getEnd(), "dd.MM.yyyy HH:mm");
end.setMandatory(true);
end.setDateChooserTimeEnabled(true);
end.setDateChooserDateFormat("%d.%m.%Y %H:%M");
begin.setExample(end.getExample());
addFormElement("cal.form.end", end);
allDayEvent = new CheckBoxElement("cal.form.allday", event.isAllDayEvent());
addFormElement("cal.form.allday", allDayEvent);
spacer = new SpacerElement(true, false);
addFormElement("spacer1", spacer);
// recurrence
String currentRecur = CalendarUtils.getRecurrence(event.getRecurrenceRule());
VisibilityDependsOnSelectionRule rule;
String[] keysRecurrence = new String[] {
RECURRENCE_NONE,
KalendarEvent.DAILY,
KalendarEvent.WORKDAILY,
KalendarEvent.WEEKLY,
KalendarEvent.BIWEEKLY,
KalendarEvent.MONTHLY,
KalendarEvent.YEARLY
};
String[] valuesRecurrence = new String[] {
translate("cal.form.recurrence.none"),
translate("cal.form.recurrence.daily"),
translate("cal.form.recurrence.workdaily"),
translate("cal.form.recurrence.weekly"),
translate("cal.form.recurrence.biweekly"),
translate("cal.form.recurrence.monthly"),
translate("cal.form.recurrence.yearly")
};
chooseRecurrence = new StaticSingleSelectionElement("cal.form.recurrence", keysRecurrence, valuesRecurrence);
if(currentRecur != null && !currentRecur.equals("")) {
chooseRecurrence.select(currentRecur, true);
} else {
chooseRecurrence.select(RECURRENCE_NONE, true);
}
addFormElement("cal.form.recurrence", chooseRecurrence);
// recurrence end date
recurrenceEnd = new DateElement("cal.form.recurrence.end", null, "dd.MM.yyyy");
recurrenceEnd.setDateChooserDateFormat("%d.%m.%Y");
recurrenceEnd.setExample(translate("cal.form.recurrence.end.example"));
Date recurEnd = CalendarUtils.getRecurrenceEndDate(event.getRecurrenceRule());
if(recurEnd != null) recurrenceEnd.setDate(recurEnd);
addFormElement("cal.form.recurrence.end", recurrenceEnd);
rule = new VisibilityDependsOnSelectionRule(chooseRecurrence, recurrenceEnd, RECURRENCE_NONE, false, "", true);
addVisibilityDependsOnSelectionRule(rule);
addFormElement("spacer2", spacer);
// classification
String[] keys = new String[] {"0", "1", "2"};
String[] values = new String[] {
getTranslator().translate("cal.form.class.private"),
getTranslator().translate("cal.form.class.freebusy"),
getTranslator().translate("cal.form.class.public")
};
classification = new StaticSingleSelectionElement("cal.form.class", keys, values);
switch (event.getClassification()) {
case KalendarEvent.CLASS_PRIVATE: classification.select("0", true); break;
case KalendarEvent.CLASS_X_FREEBUSY: classification.select("1", true); break;
case KalendarEvent.CLASS_PUBLIC: classification.select("2", true); break;
default: classification.select("0", true);