protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("title.prefs");
setFormContextHelp(this.getClass().getPackage().getName(), "home-prefs.html", "help.hover.prefs");
// load preferences
Preferences prefs = tobeChangedIdentity.getUser().getPreferences();
// Username
StaticTextElement username = uifactory.addStaticTextElement("form.username", tobeChangedIdentity.getName(), formLayout);
username.setEnabled(false);
// Language
Map<String, String> languages = I18nManager.getInstance().getEnabledLanguagesTranslated();
String[] langKeys = StringHelper.getMapKeysAsStringArray(languages);
String[] langValues = StringHelper.getMapValuesAsStringArray(languages);
ArrayHelper.sort(langKeys, langValues, false, true, false);
language = uifactory.addDropdownSingleselect("form.language", formLayout, langKeys, langValues, null);
String langKey = prefs.getLanguage();
// Preselect the users language if available. Maye not anymore enabled on
// this server
if (prefs.getLanguage() != null && I18nModule.getEnabledLanguageKeys().contains(langKey)) {
language.select(prefs.getLanguage(), true);
} else {
language.select(I18nModule.getDefaultLocale().toString(), true);
}
// Font size
String[] cssFontsizeValues = new String[] { translate("form.fontsize.xsmall"), translate("form.fontsize.small"),
translate("form.fontsize.normal"), translate("form.fontsize.large"), translate("form.fontsize.xlarge"),
translate("form.fontsize.presentation") };
fontsize = uifactory.addDropdownSingleselect("form.fontsize", formLayout, cssFontsizeKeys, cssFontsizeValues, null);
fontsize.select(prefs.getFontsize(), true);
// Email notification interval
NotificationsManager nMgr = NotificationsManager.getInstance();
List<String> intervals = nMgr.getNotificationIntervals();
if (intervals.size() > 0) {
String[] intervalKeys = new String[intervals.size()];
intervals.toArray(intervalKeys);
String[] intervalValues = new String[intervalKeys.length];
String i18nPrefix = "interval.";
for (int i = 0; i < intervalKeys.length; i++) {
intervalValues[i] = translate(i18nPrefix + intervalKeys[i]);
}
notificationInterval = uifactory.addDropdownSingleselect("form.notification", formLayout, intervalKeys, intervalValues, null);
notificationInterval.select(prefs.getNotificationInterval(), true);
}
// Text encoding
Map<String, Charset> charsets = Charset.availableCharsets();
String currentCharset = UserManager.getInstance().getUserCharset(tobeChangedIdentity);