use of org.olat.core.gui.components.AbstractComponent in project OpenOLAT by OpenOLAT.
the class QuestionMetadataEditController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
typeEl = uifactory.addStaticTextElement("question.type", "", formLayout);
QItemType type = item.getType();
if (type == null || type.getType() == null) {
typeEl.setValue("");
} else {
String translation = translate("item.type." + type.getType().toLowerCase());
if (translation.length() > 128) {
translation = type.getType();
}
typeEl.setValue(translation);
}
String page = velocity_root + "/learning_time.html";
learningTimeContainer = FormLayoutContainer.createCustomFormLayout("learningTime", getTranslator(), page);
((AbstractComponent) learningTimeContainer.getComponent()).setDomReplacementWrapperRequired(false);
learningTimeContainer.setRootForm(mainForm);
learningTimeContainer.setLabel("educational.learningTime", null);
formLayout.add(learningTimeContainer);
LOMDuration duration = MetadataConverterHelper.convertDuration(item.getEducationalLearningTime());
learningTimeDayElement = uifactory.addIntegerElement("learningTime.day", "", duration.getDay(), learningTimeContainer);
((AbstractComponent) learningTimeDayElement.getComponent()).setDomReplacementWrapperRequired(false);
learningTimeDayElement.setDisplaySize(3);
learningTimeDayElement.setMandatory(true);
learningTimeHourElement = uifactory.addIntegerElement("learningTime.hour", "", duration.getHour(), learningTimeContainer);
((AbstractComponent) learningTimeHourElement.getComponent()).setDomReplacementWrapperRequired(false);
learningTimeHourElement.setDisplaySize(3);
learningTimeHourElement.setMandatory(true);
learningTimeMinuteElement = uifactory.addIntegerElement("learningTime.minute", "", duration.getMinute(), learningTimeContainer);
((AbstractComponent) learningTimeMinuteElement.getComponent()).setDomReplacementWrapperRequired(false);
learningTimeMinuteElement.setDisplaySize(3);
learningTimeMinuteElement.setMandatory(true);
learningTimeSecondElement = uifactory.addIntegerElement("learningTime.second", "", duration.getSeconds(), learningTimeContainer);
((AbstractComponent) learningTimeSecondElement.getComponent()).setDomReplacementWrapperRequired(false);
learningTimeSecondElement.setDisplaySize(3);
learningTimeSecondElement.setMandatory(true);
String difficulty = bigDToString(item.getDifficulty());
difficultyEl = uifactory.addTextElement("question.difficulty", "question.difficulty", 24, difficulty, formLayout);
difficultyEl.setExampleKey("question.difficulty.example", null);
difficultyEl.setDisplaySize(4);
String stdevDifficulty = bigDToString(item.getStdevDifficulty());
stdevDifficultyEl = uifactory.addTextElement("question.stdevDifficulty", "question.stdevDifficulty", 24, stdevDifficulty, formLayout);
stdevDifficultyEl.setExampleKey("question.stdevDifficulty.example", null);
stdevDifficultyEl.setDisplaySize(4);
String differentiation = bigDToString(item.getDifferentiation());
differentiationEl = uifactory.addTextElement("question.differentiation", "question.differentiation", 24, differentiation, formLayout);
differentiationEl.setExampleKey("question.differentiation.example", null);
differentiationEl.setDisplaySize(4);
String numAnswerAlt = item.getNumOfAnswerAlternatives() < 0 ? "" : Integer.toString(item.getNumOfAnswerAlternatives());
numAnswerAltEl = uifactory.addTextElement("question.numOfAnswerAlternatives", "question.numOfAnswerAlternatives", 24, numAnswerAlt, formLayout);
numAnswerAltEl.setDisplaySize(4);
String numUsage = item.getUsage() < 0 ? "" : Integer.toString(item.getUsage());
usageEl = uifactory.addTextElement("question.usage", "question.usage", 24, numUsage, formLayout);
usageEl.setDisplaySize(4);
buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add(buttonsCont);
uifactory.addFormSubmitButton("ok", "ok", buttonsCont);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
use of org.olat.core.gui.components.AbstractComponent in project openolat by klemens.
the class QuestionMetadataEditController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
typeEl = uifactory.addStaticTextElement("question.type", "", formLayout);
QItemType type = item.getType();
if (type == null || type.getType() == null) {
typeEl.setValue("");
} else {
String translation = translate("item.type." + type.getType().toLowerCase());
if (translation.length() > 128) {
translation = type.getType();
}
typeEl.setValue(translation);
}
String page = velocity_root + "/learning_time.html";
learningTimeContainer = FormLayoutContainer.createCustomFormLayout("learningTime", getTranslator(), page);
((AbstractComponent) learningTimeContainer.getComponent()).setDomReplacementWrapperRequired(false);
learningTimeContainer.setRootForm(mainForm);
learningTimeContainer.setLabel("educational.learningTime", null);
formLayout.add(learningTimeContainer);
LOMDuration duration = MetadataConverterHelper.convertDuration(item.getEducationalLearningTime());
learningTimeDayElement = uifactory.addIntegerElement("learningTime.day", "", duration.getDay(), learningTimeContainer);
((AbstractComponent) learningTimeDayElement.getComponent()).setDomReplacementWrapperRequired(false);
learningTimeDayElement.setDisplaySize(3);
learningTimeDayElement.setMandatory(true);
learningTimeHourElement = uifactory.addIntegerElement("learningTime.hour", "", duration.getHour(), learningTimeContainer);
((AbstractComponent) learningTimeHourElement.getComponent()).setDomReplacementWrapperRequired(false);
learningTimeHourElement.setDisplaySize(3);
learningTimeHourElement.setMandatory(true);
learningTimeMinuteElement = uifactory.addIntegerElement("learningTime.minute", "", duration.getMinute(), learningTimeContainer);
((AbstractComponent) learningTimeMinuteElement.getComponent()).setDomReplacementWrapperRequired(false);
learningTimeMinuteElement.setDisplaySize(3);
learningTimeMinuteElement.setMandatory(true);
learningTimeSecondElement = uifactory.addIntegerElement("learningTime.second", "", duration.getSeconds(), learningTimeContainer);
((AbstractComponent) learningTimeSecondElement.getComponent()).setDomReplacementWrapperRequired(false);
learningTimeSecondElement.setDisplaySize(3);
learningTimeSecondElement.setMandatory(true);
String difficulty = bigDToString(item.getDifficulty());
difficultyEl = uifactory.addTextElement("question.difficulty", "question.difficulty", 24, difficulty, formLayout);
difficultyEl.setExampleKey("question.difficulty.example", null);
difficultyEl.setDisplaySize(4);
String stdevDifficulty = bigDToString(item.getStdevDifficulty());
stdevDifficultyEl = uifactory.addTextElement("question.stdevDifficulty", "question.stdevDifficulty", 24, stdevDifficulty, formLayout);
stdevDifficultyEl.setExampleKey("question.stdevDifficulty.example", null);
stdevDifficultyEl.setDisplaySize(4);
String differentiation = bigDToString(item.getDifferentiation());
differentiationEl = uifactory.addTextElement("question.differentiation", "question.differentiation", 24, differentiation, formLayout);
differentiationEl.setExampleKey("question.differentiation.example", null);
differentiationEl.setDisplaySize(4);
String numAnswerAlt = item.getNumOfAnswerAlternatives() < 0 ? "" : Integer.toString(item.getNumOfAnswerAlternatives());
numAnswerAltEl = uifactory.addTextElement("question.numOfAnswerAlternatives", "question.numOfAnswerAlternatives", 24, numAnswerAlt, formLayout);
numAnswerAltEl.setDisplaySize(4);
String numUsage = item.getUsage() < 0 ? "" : Integer.toString(item.getUsage());
usageEl = uifactory.addTextElement("question.usage", "question.usage", 24, numUsage, formLayout);
usageEl.setDisplaySize(4);
buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add(buttonsCont);
uifactory.addFormSubmitButton("ok", "ok", buttonsCont);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
use of org.olat.core.gui.components.AbstractComponent in project openolat by klemens.
the class PreviewSettingsForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
sdate = uifactory.addDateChooser("sdate", "form.sdate", null, formLayout);
sdate.setExampleKey("form.easy.example.bdate", null);
sdate.setDateChooserTimeEnabled(true);
sdate.setMandatory(true);
sdate.setValidDateCheck("form.sdate.invalid");
// setDate must be called after the DataChooser was configured
sdate.setDate(new Date());
List<BusinessGroup> groups = courseGroupManager.getAllBusinessGroups();
String[] groupNames = new String[groups.size()];
String[] groupKeys = new String[groups.size()];
for (int i = groups.size(); i-- > 0; ) {
groupNames[i] = groups.get(i).getName();
groupKeys[i] = groups.get(i).getKey().toString();
}
groupSelector = uifactory.addCheckboxesVertical("details.groups", formLayout, groupKeys, groupNames, 1);
groupSelector.setVisible(groups.size() > 0);
List<BGArea> areas = courseGroupManager.getAllAreas();
String[] areaNames = new String[areas.size()];
String[] areaKeys = new String[areas.size()];
for (int i = areas.size(); i-- > 0; ) {
areaNames[i] = areas.get(i).getName();
areaKeys[i] = areas.get(i).getKey().toString();
}
areaSelector = uifactory.addCheckboxesVertical("details.areas", formLayout, areaKeys, areaNames, 1);
areaSelector.setVisible(areas.size() > 0);
String[] keys = { ROLE_STUDENT, ROLE_GUEST, ROLE_COURSECOACH, ROLE_COURSEADMIN, ROLE_GLOBALAUTHOR };
String[] values = new String[keys.length];
for (int i = 0; i < keys.length; i++) {
values[i] = translate(keys[i]);
}
roles = uifactory.addRadiosVertical("roles", "form.roles", formLayout, keys, values);
roles.select(ROLE_STUDENT, true);
String page = velocity_root + "/attributes.html";
FormLayoutContainer attrlayout = FormLayoutContainer.createCustomFormLayout("attributes", getTranslator(), page);
formLayout.add(attrlayout);
attrlayout.setLabel("form.attributes", null);
for (int i = 0; i < NUMATTR; i++) {
TextElement name = uifactory.addTextElement("attrname" + i, null, 255, "", attrlayout);
((AbstractComponent) name.getComponent()).setDomReplacementWrapperRequired(false);
name.setDisplaySize(12);
TextElement value = uifactory.addTextElement("attrvalue" + i, "form.equals", 255, "", attrlayout);
((AbstractComponent) value.getComponent()).setDomReplacementWrapperRequired(false);
value.setDisplaySize(12);
attrNames.add(name);
attrValues.add(value);
}
uifactory.addFormSubmitButton("submit", "command.preview", formLayout);
}
use of org.olat.core.gui.components.AbstractComponent in project OpenOLAT by OpenOLAT.
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);
}
use of org.olat.core.gui.components.AbstractComponent in project OpenOLAT by OpenOLAT.
the class PreviewSettingsForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
sdate = uifactory.addDateChooser("sdate", "form.sdate", null, formLayout);
sdate.setExampleKey("form.easy.example.bdate", null);
sdate.setDateChooserTimeEnabled(true);
sdate.setMandatory(true);
sdate.setValidDateCheck("form.sdate.invalid");
// setDate must be called after the DataChooser was configured
sdate.setDate(new Date());
List<BusinessGroup> groups = courseGroupManager.getAllBusinessGroups();
String[] groupNames = new String[groups.size()];
String[] groupKeys = new String[groups.size()];
for (int i = groups.size(); i-- > 0; ) {
groupNames[i] = groups.get(i).getName();
groupKeys[i] = groups.get(i).getKey().toString();
}
groupSelector = uifactory.addCheckboxesVertical("details.groups", formLayout, groupKeys, groupNames, 1);
groupSelector.setVisible(groups.size() > 0);
List<BGArea> areas = courseGroupManager.getAllAreas();
String[] areaNames = new String[areas.size()];
String[] areaKeys = new String[areas.size()];
for (int i = areas.size(); i-- > 0; ) {
areaNames[i] = areas.get(i).getName();
areaKeys[i] = areas.get(i).getKey().toString();
}
areaSelector = uifactory.addCheckboxesVertical("details.areas", formLayout, areaKeys, areaNames, 1);
areaSelector.setVisible(areas.size() > 0);
String[] keys = { ROLE_STUDENT, ROLE_GUEST, ROLE_COURSECOACH, ROLE_COURSEADMIN, ROLE_GLOBALAUTHOR };
String[] values = new String[keys.length];
for (int i = 0; i < keys.length; i++) {
values[i] = translate(keys[i]);
}
roles = uifactory.addRadiosVertical("roles", "form.roles", formLayout, keys, values);
roles.select(ROLE_STUDENT, true);
String page = velocity_root + "/attributes.html";
FormLayoutContainer attrlayout = FormLayoutContainer.createCustomFormLayout("attributes", getTranslator(), page);
formLayout.add(attrlayout);
attrlayout.setLabel("form.attributes", null);
for (int i = 0; i < NUMATTR; i++) {
TextElement name = uifactory.addTextElement("attrname" + i, null, 255, "", attrlayout);
((AbstractComponent) name.getComponent()).setDomReplacementWrapperRequired(false);
name.setDisplaySize(12);
TextElement value = uifactory.addTextElement("attrvalue" + i, "form.equals", 255, "", attrlayout);
((AbstractComponent) value.getComponent()).setDomReplacementWrapperRequired(false);
value.setDisplaySize(12);
attrNames.add(name);
attrValues.add(value);
}
uifactory.addFormSubmitButton("submit", "command.preview", formLayout);
}
Aggregations