use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.
the class ResumeController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
askagainCheckbox = uifactory.addCheckboxesHorizontal("askagain", null, formLayout, askagain_keys, new String[] { translate("askagain.label") });
// Button layout
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
formLayout.add(buttonLayout);
okButton = uifactory.addFormSubmitButton("submit", "resume.button", buttonLayout);
okButton.setElementCssClass("o_sel_resume_yes");
okButton.setFocus(true);
landingButton = uifactory.addFormLink("landing", "resume.button.landing", null, buttonLayout, Link.BUTTON);
landingButton.setElementCssClass("o_sel_resume_landing");
landingButton.setVisible(StringHelper.containsNonWhitespace(redirect.getLandingPage()));
noButton = uifactory.addFormLink("cancel", "resume.button.cancel", null, buttonLayout, Link.BUTTON);
noButton.setElementCssClass("o_sel_resume_cancel");
noButton.setVisible(!StringHelper.containsNonWhitespace(redirect.getLandingPage()));
}
use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.
the class CourseSiteAdminController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("admin.menu.title");
enableToolbar = uifactory.addCheckboxesHorizontal("site.enable.toolbar", "site.enable.toolbar", formLayout, new String[] { "x" }, new String[] { "" });
enableToolbar.addActionListener(FormEvent.ONCHANGE);
if (siteConfiguration.isToolbar()) {
enableToolbar.select("x", true);
}
String cssClass = siteConfiguration.getNavIconCssClass();
iconCssClassEl = uifactory.addTextElement("site.iconCssClass", "site.icon", 32, cssClass, formLayout);
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.defLanguage.i18nKey(), CSCols.defLanguage.ordinal()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.language.i18nKey(), CSCols.language.ordinal()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.title.i18nKey(), CSCols.title.ordinal()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, CSCols.courseId.i18nKey(), CSCols.courseId.ordinal(), false, null));
FlexiCellRenderer renderer = new StaticFlexiCellRenderer("openre", new TextFlexiCellRenderer());
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.courseTitle.i18nKey(), CSCols.courseTitle.ordinal(), "openre", renderer));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("remove", translate("remove"), "remove"));
String page = velocity_root + "/lang_options.html";
tableLayout = FormLayoutContainer.createCustomFormLayout("site.options.lang", getTranslator(), page);
tableLayout.setRootForm(mainForm);
tableLayout.setLabel("site.courses", null);
formLayout.add(tableLayout);
model = new CourseSiteDataModel(columnsModel);
List<LanguageConfigurationRow> configs = new ArrayList<LanguageConfigurationRow>();
Map<String, LanguageConfiguration> langToConfigMap = new HashMap<String, LanguageConfiguration>();
if (siteConfiguration.getConfigurations() != null) {
for (LanguageConfiguration langConfig : siteConfiguration.getConfigurations()) {
langToConfigMap.put(langConfig.getLanguage(), langConfig);
}
}
for (String langKey : i18nModule.getEnabledLanguageKeys()) {
if (langToConfigMap.containsKey(langKey)) {
LanguageConfiguration langConfig = langToConfigMap.get(langKey);
RepositoryEntry re = repositoryManager.lookupRepositoryEntryBySoftkey(langConfig.getRepoSoftKey(), false);
configs.add(new LanguageConfigurationRow(langConfig, re, tableLayout));
} else {
configs.add(new LanguageConfigurationRow(new LanguageConfiguration(langKey), null, tableLayout));
}
}
model.setObjects(configs);
tableEl = uifactory.addTableElement(getWindowControl(), "languageTable", model, getTranslator(), tableLayout);
tableEl.setRendererType(FlexiTableRendererType.classic);
tableEl.setCustomizeColumns(true);
tableEl.setAndLoadPersistedPreferences(ureq, "course-site-admin");
FormLayoutContainer buttonsLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsLayout);
okButton = uifactory.addFormLink("save", "save", null, buttonsLayout, Link.BUTTON);
okButton.setCustomEnabledLinkCSS("btn btn-primary");
// uifactory.addFormSubmitButton("save", "save", formLayout);
}
use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.
the class InitialAttemptsRuleEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String page = Util.getPackageVelocityRoot(this.getClass()) + "/initial_attempts.html";
String id = Long.toString(CodeHelper.getRAMUniqueID());
Translator trans = formLayout.getTranslator();
FormLayoutContainer ruleCont = FormLayoutContainer.createCustomFormLayout("attempts.".concat(id), formLayout.getTranslator(), page);
ruleCont.setRootForm(formLayout.getRootForm());
formLayout.add(ruleCont);
ruleCont.getFormItemComponent().contextPut("id", id);
ICourse course = CourseFactory.loadCourse(entry);
String currentValue = null;
String currentUnit = null;
String currentCourseNode = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
currentUnit = r.getRightUnit();
currentValue = r.getRightOperand();
currentCourseNode = r.getLeftOperand();
}
List<CourseNode> attemptableNodes = new ArrayList<>();
searchAttemptableNodes(course.getRunStructure().getRootNode(), attemptableNodes);
String[] nodeKeys = new String[attemptableNodes.size()];
String[] nodeValues = new String[attemptableNodes.size()];
for (int i = 0; i < attemptableNodes.size(); i++) {
CourseNode attemptableNode = attemptableNodes.get(i);
nodeKeys[i] = attemptableNode.getIdent();
nodeValues[i] = attemptableNode.getShortTitle() + " ( " + attemptableNode.getIdent() + " )";
}
courseNodeEl = uifactory.addDropdownSingleselect("coursenodes.".concat(id), null, ruleCont, nodeKeys, nodeValues, null);
courseNodeEl.setDomReplacementWrapperRequired(false);
boolean nodeSelected = false;
if (currentCourseNode != null) {
for (String nodeKey : nodeKeys) {
if (currentCourseNode.equals(nodeKey)) {
courseNodeEl.select(nodeKey, true);
nodeSelected = true;
}
}
}
if (!nodeSelected && nodeKeys.length > 0) {
courseNodeEl.select(nodeKeys[0], true);
}
if (StringHelper.containsNonWhitespace(currentCourseNode) && !nodeSelected) {
courseNodeEl.setErrorKey("error.course.node.found", null);
}
valueEl = uifactory.addTextElement("attemptvalue.".concat(id), null, 128, currentValue, ruleCont);
valueEl.setDomReplacementWrapperRequired(false);
valueEl.setDisplaySize(3);
String[] unitValues = new String[] { trans.translate(LaunchUnit.day.name()), trans.translate(LaunchUnit.week.name()), trans.translate(LaunchUnit.month.name()), trans.translate(LaunchUnit.year.name()) };
unitEl = uifactory.addDropdownSingleselect("attemptunit.".concat(id), null, ruleCont, unitKeys, unitValues, null);
unitEl.setDomReplacementWrapperRequired(false);
boolean selected = false;
if (currentUnit != null) {
for (String unitKey : unitKeys) {
if (currentUnit.equals(unitKey)) {
unitEl.select(unitKey, true);
selected = true;
}
}
}
if (!selected) {
unitEl.select(unitKeys[1], true);
}
return ruleCont;
}
use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.
the class TaskFormController method initForm.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// add the "optional message for users" rich text input element
optionalText = uifactory.addRichTextElementForStringDataMinimalistic("form.task.text", "form.task.text", (String) config.get(TACourseNode.CONF_TASK_TEXT), 10, -1, formLayout, getWindowControl());
// add the task type radio buttons
String taskType = (String) this.config.get(TACourseNode.CONF_TASK_TYPE);
String[] typeKeys = new String[] { TaskController.TYPE_MANUAL, TaskController.TYPE_AUTO };
String[] typeValues = new String[] { translate("form.task.type.manual"), translate("form.task.type.auto") };
this.type = uifactory.addRadiosVertical("form.task.type", formLayout, typeKeys, typeValues);
if (taskType != null) {
this.type.select(taskType, true);
} else {
this.type.select(TaskController.TYPE_MANUAL, true);
}
this.type.addActionListener(FormEvent.ONCLICK);
// add the preview radio buttons
// per default no preview
Boolean taskPreview = Boolean.valueOf(false);
Object taskPreviewObj = this.config.get(TACourseNode.CONF_TASK_PREVIEW);
if (taskPreviewObj != null) {
taskPreview = this.config.getBooleanEntry(TACourseNode.CONF_TASK_PREVIEW);
}
String[] previewKeys = new String[] { TaskController.WITH_PREVIEW, TaskController.WITHOUT_PREVIEW };
String[] previewValues = new String[] { translate("form.task.with.preview"), translate("form.task.without.preview") };
this.preview = uifactory.addRadiosVertical("form.task.preview", formLayout, previewKeys, previewValues);
if (taskPreview.booleanValue()) {
this.preview.select(TaskController.WITH_PREVIEW, true);
} else {
this.preview.select(TaskController.WITHOUT_PREVIEW, true);
}
this.preview.addActionListener(FormEvent.ONCLICK);
// add the deselect radio buttons
// per default no deselect possible
Boolean taskDeselect = Boolean.valueOf(false);
Object taskDeselectObj = this.config.get(TACourseNode.CONF_TASK_DESELECT);
if (taskDeselectObj != null) {
taskDeselect = this.config.getBooleanEntry(TACourseNode.CONF_TASK_DESELECT);
}
String[] deselectKeys = new String[] { TaskController.WITH_DESELECT, TaskController.WITHOUT_DESELECT };
String[] deselectValues = new String[] { translate("form.task.with.deselect"), translate("form.task.without.deselect") };
this.deselect = uifactory.addRadiosVertical("form.task.deselect", formLayout, deselectKeys, deselectValues);
if (taskDeselect.booleanValue()) {
this.deselect.select(TaskController.WITH_DESELECT, true);
} else {
this.deselect.select(TaskController.WITHOUT_DESELECT, true);
}
// add the sampling type radio buttons
Boolean samplingWithReplacement = (Boolean) this.config.get(TACourseNode.CONF_TASK_SAMPLING_WITH_REPLACEMENT);
if (samplingWithReplacement == null)
samplingWithReplacement = Boolean.valueOf(true);
String[] samplingKeys = new String[] { "swith", "swithout" };
String[] samplingValues = new String[] { translate("form.task.sampling.with"), translate("form.task.sampling.without") };
this.sampling = uifactory.addRadiosVertical("form.task.sampling", formLayout, samplingKeys, samplingValues);
if (samplingWithReplacement.booleanValue()) {
this.sampling.select("swith", true);
} else {
this.sampling.select("swithout", true);
}
// Create submit button
final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("submit", buttonLayout);
update();
}
use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.
the class TextInputController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("wizard.import.input.description");
setFormContextHelp("Data Management#qb_import");
FormLayoutContainer textContainer = FormLayoutContainer.createCustomFormLayout("index", getTranslator(), velocity_root + "/example.html");
formLayout.add(textContainer);
String mapperURI = registerMapper(ureq, new ExampleMapper());
textContainer.contextPut("mapperURI", mapperURI);
inputElement = uifactory.addTextAreaElement("importform", "form.importdata", -1, 10, 100, false, "", formLayout);
inputElement.setMandatory(true);
inputElement.setNotEmptyCheck("form.legende.mandatory");
}
Aggregations