use of org.olat.core.gui.components.AbstractComponent in project openolat by klemens.
the class ReminderAdminController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("reminder.admin.title");
String[] enableValues = new String[] { translate("on") };
enableEl = uifactory.addCheckboxesHorizontal("enable.reminders", formLayout, enableKeys, enableValues);
enableEl.addActionListener(FormEvent.ONCHANGE);
enableEl.select(enableKeys[0], reminderModule.isEnabled());
String interval = reminderModule.getInterval();
intervalEl = uifactory.addDropdownSingleselect("interval", formLayout, intervalKeys, intervalValues, null);
boolean found = false;
if (StringHelper.containsNonWhitespace(interval)) {
for (String intervalKey : intervalKeys) {
if (intervalKey.equals(interval)) {
intervalEl.select(intervalKey, true);
found = true;
}
}
}
if (!found) {
intervalEl.select(intervalKeys[0], true);
}
int hour = 9;
int minute = 0;
SendTime parsedTime = SendTime.parse(reminderModule.getDefaultSendTime());
if (parsedTime.isValid()) {
hour = parsedTime.getHour();
minute = parsedTime.getMinute();
}
String timePage = velocity_root + "/time.html";
timeLayout = FormLayoutContainer.createCustomFormLayout("send.time", getTranslator(), timePage);
timeLayout.setRootForm(mainForm);
formLayout.add(timeLayout);
timeLayout.setLabel("default.send.time", null);
String hourStr = (hour < 10 ? "0" : "") + hour;
hoursEl = uifactory.addTextElement("hours", null, 2, hourStr, timeLayout);
hoursEl.setDisplaySize(2);
hoursEl.setDomReplacementWrapperRequired(false);
String minuteStr = (minute < 10 ? "0" : "") + minute;
minutesEl = uifactory.addTextElement("minutes", null, 2, minuteStr, timeLayout);
minutesEl.setDisplaySize(2);
minutesEl.setDomReplacementWrapperRequired(false);
String[] timezoneKeys = TimeZone.getAvailableIDs();
String[] timezoneValues = new String[timezoneKeys.length];
for (int i = timezoneKeys.length; i-- > 0; ) {
timezoneValues[i] = timezoneKeys[i] + " (" + TimeZone.getTimeZone(timezoneKeys[i]).getDisplayName(true, TimeZone.LONG, getLocale()) + ")";
}
timezoneEl = uifactory.addDropdownSingleselect("timezone", timeLayout, timezoneKeys, timezoneValues, null);
timezoneEl.setEnabled(false);
((AbstractComponent) timezoneEl.getComponent()).setDomReplacementWrapperRequired(false);
TimeZone defaultTimeZone = reminderModule.getDefaultSendTimeZone();
for (int i = timezoneKeys.length; i-- > 0; ) {
if (defaultTimeZone.getID().equals(timezoneKeys[i])) {
timezoneEl.select(defaultTimeZone.getID(), true);
}
}
timeLayout.setVisible(reminderModule.isEnabled());
/*
enableSmsEl = uifactory.addCheckboxesHorizontal("enable.sms.reminders", formLayout, enableKeys, enableValues);
enableSmsEl.addActionListener(FormEvent.ONCHANGE);
enableSmsEl.select(enableKeys[0], reminderModule.isSmsEnabled());
enableSmsEl.setVisible(reminderModule.isEnabled());
*/
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add(buttonsCont);
uifactory.addFormSubmitButton("save", buttonsCont);
}
Aggregations