use of org.olat.core.gui.components.form.flexible.FormUIFactory in project OpenOLAT by OpenOLAT.
the class STCourseNodeDisplayConfigFormController 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) {
setFormTitle("config.fieldset.view");
setFormContextHelp("Knowledge Transfer#_struktur");
FormUIFactory formFact = FormUIFactory.getInstance();
// Display type
String[] values_displayType = new String[] { translate("form.system"), translate("form.peekview"), translate("form.self"), translate("form.delegate") };
displayTypeRadios = formFact.addRadiosVertical("selforsystemoverview", formLayout, keys_displayType, values_displayType);
displayTypeRadios.addActionListener(FormEvent.ONCLICK);
if (displayConfig.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE)) {
displayTypeRadios.select("file", true);
} else if (displayConfig.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_PEEKVIEW)) {
displayTypeRadios.select("peekview", true);
} else if (displayConfig.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_DELEGATE)) {
displayTypeRadios.select("delegate", true);
} else {
displayTypeRadios.select("system", true);
}
// peekviews to be selected
if (selectedPeekviewChildKeys.length > 0) {
SpacerElement spacerChild = formFact.addSpacerElement("spacerChild", formLayout, true);
selectedPeekviewChildren = formFact.addCheckboxesVertical("selectedPeekviewChildren", formLayout, selectedPeekviewChildKeys, selectedPeekviewChildValues, selectedPeekviewChildCssClasses, 1);
selectedPeekviewChildren.setLabel("selectedPeekviewChildren", new String[] { STCourseNodeConfiguration.MAX_PEEKVIEW_CHILD_NODES + "" });
// visibility rules for peekview children selection
RulesFactory.createHideRule(displayTypeRadios, "file", selectedPeekviewChildren, formLayout);
RulesFactory.createHideRule(displayTypeRadios, "system", selectedPeekviewChildren, formLayout);
RulesFactory.createShowRule(displayTypeRadios, "peekview", selectedPeekviewChildren, formLayout);
RulesFactory.createHideRule(displayTypeRadios, "delegate", selectedPeekviewChildren, formLayout);
RulesFactory.createHideRule(displayTypeRadios, "file", spacerChild, formLayout);
RulesFactory.createHideRule(displayTypeRadios, "system", spacerChild, formLayout);
RulesFactory.createShowRule(displayTypeRadios, "peekview", spacerChild, formLayout);
RulesFactory.createHideRule(displayTypeRadios, "delegate", spacerChild, formLayout);
// Pre-select the first MAX_PEEKVIEW_CHILD_NODES child nodes if none is
// selected to reflect meaningfull default configuration
preselectConfiguredOrMaxChildNodes();
// Add as listener for any changes
selectedPeekviewChildren.addActionListener(FormEvent.ONCLICK);
}
//
// Number of rows (only available in system or peekview type)
SpacerElement spacerCols = formFact.addSpacerElement("spacerCols", formLayout, true);
displayTwoColumns = formFact.addCheckboxesHorizontal("displayTwoColumns", formLayout, new String[] { "on" }, new String[] { "" });
displayTwoColumns.setLabel("displayTwoColumns", null);
displayTwoColumns.addActionListener(FormEvent.ONCLICK);
if (columnsConfig == 2) {
displayTwoColumns.selectAll();
}
if (displayConfig.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE) || displayConfig.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_DELEGATE)) {
displayTwoColumns.setVisible(false);
}
//
// Visibility rules for display columns switch
RulesFactory.createHideRule(displayTypeRadios, "file", displayTwoColumns, formLayout);
RulesFactory.createShowRule(displayTypeRadios, "peekview", displayTwoColumns, formLayout);
RulesFactory.createShowRule(displayTypeRadios, "system", displayTwoColumns, formLayout);
RulesFactory.createHideRule(displayTypeRadios, "delegate", displayTwoColumns, formLayout);
RulesFactory.createHideRule(displayTypeRadios, "file", spacerCols, formLayout);
RulesFactory.createShowRule(displayTypeRadios, "peekview", spacerCols, formLayout);
RulesFactory.createShowRule(displayTypeRadios, "system", spacerCols, formLayout);
RulesFactory.createHideRule(displayTypeRadios, "delegate", spacerCols, formLayout);
}
use of org.olat.core.gui.components.form.flexible.FormUIFactory in project OpenOLAT by OpenOLAT.
the class ColorLA method getFormItem.
/**
* @see org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute#getFormItem(java.lang.String, org.olat.core.gui.components.form.flexible.FormItemContainer)
* get a dropdown and an input field wrapped in a FormLayoutContainer
*/
@Override
public FormItem getFormItem(String compName, FormItemContainer formLayout) {
FormUIFactory uifact = FormUIFactory.getInstance();
FormLayoutContainer colorFLC = FormLayoutContainer.createVerticalFormLayout(compName, formLayout.getTranslator());
formLayout.add(compName, colorFLC);
FormItem dropDown = super.getFormItem(compName + "sel", formLayout);
dropDown.addActionListener(FormEvent.ONCHANGE);
colorFLC.add(dropDown);
String inputValue = "";
if (getAttributeValue() != null && !((SingleSelection) dropDown).isOneSelected()) {
inputValue = getAttributeValue();
}
TextElement inputEl = uifact.addTextElement(compName + "value", null, 7, inputValue, colorFLC);
inputEl.setDisplaySize(7);
colorFLC.setUserObject(new ColorSpecialHandler(colorFLC));
return colorFLC;
}
use of org.olat.core.gui.components.form.flexible.FormUIFactory in project openolat by klemens.
the class GuiDemoInlineEditingBasedOnFlexiForm 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) {
setFormTitle("inline.editing.flexiform");
setFormDescription("inline.editing.flexiform.rem");
FormUIFactory formUIf = FormUIFactory.getInstance();
int i = 0;
for (; i < elements.length; i++) {
elements[i] = formUIf.addInlineTextElement("inline.label.text" + i, "some", formLayout, this);
elements[i].setLabel("inline.label.text", null);
elements[i].setNotLongerThanCheck(5, "text.element.error.notlongerthan");
if (i % 2 == 0) {
elements[i].setEnabled(false);
}
}
// test for inline editable label field
// the inlineLable is used as Label for the addStaticTextElement
// Avoid translation error by setting i18nLabel key null first and then set the LabelComponent, and also you need to call showLabel(true)
inlineLabel = formUIf.addInlineTextElement("inline.label.int" + i + 1, "mytext" + i + 1, formLayout, null);
formUIf.addStaticTextElement("inline.label.text" + i, null, "my bony", formLayout);
}
use of org.olat.core.gui.components.form.flexible.FormUIFactory in project OpenOLAT by OpenOLAT.
the class GuiDemoInlineEditingBasedOnFlexiForm 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) {
setFormTitle("inline.editing.flexiform");
setFormDescription("inline.editing.flexiform.rem");
FormUIFactory formUIf = FormUIFactory.getInstance();
int i = 0;
for (; i < elements.length; i++) {
elements[i] = formUIf.addInlineTextElement("inline.label.text" + i, "some", formLayout, this);
elements[i].setLabel("inline.label.text", null);
elements[i].setNotLongerThanCheck(5, "text.element.error.notlongerthan");
if (i % 2 == 0) {
elements[i].setEnabled(false);
}
}
// test for inline editable label field
// the inlineLable is used as Label for the addStaticTextElement
// Avoid translation error by setting i18nLabel key null first and then set the LabelComponent, and also you need to call showLabel(true)
inlineLabel = formUIf.addInlineTextElement("inline.label.int" + i + 1, "mytext" + i + 1, formLayout, null);
formUIf.addStaticTextElement("inline.label.text" + i, null, "my bony", formLayout);
}
use of org.olat.core.gui.components.form.flexible.FormUIFactory in project OpenOLAT by OpenOLAT.
the class GlossaryTermAndSynonymController method createOrUpdateSynonymLayout.
private void createOrUpdateSynonymLayout(FormItemContainer formLayout, ArrayList<String> glossItemSynonymsToUse) {
FormUIFactory formUIf = FormUIFactory.getInstance();
FormItem synLay = formLayout.getFormComponent("synonymLayout");
if (synLay != null) {
formLayout.remove("synonymLayout");
}
FormLayoutContainer tmpLayout = FormLayoutContainer.createCustomFormLayout("synonymLayout", getTranslator(), velocity_root + "/editSynonym.html");
formLayout.add(tmpLayout);
tmpLayout.setLabel("glossary.term.synonym", null);
Collections.sort(glossItemSynonymsToUse);
tmpLayout.contextPut("glossItemSynonyms", glossItemSynonymsToUse);
// add input fields with existing synonyms
synonymTextElementList = new ArrayList<TextElement>(glossItemSynonymsToUse.size());
for (int synNum = 1; synNum < glossItemSynonymsToUse.size() + 1; synNum++) {
TextElement tmpSynonymTE = formUIf.addTextElement(SYNONYM_TEXT_ELEMENT + synNum, null, 100, glossItemSynonymsToUse.get(synNum - 1), tmpLayout);
synonymTextElementList.add(tmpSynonymTE);
}
// add delete-links for existing synonyms
for (int linkNum = 1; linkNum < glossItemSynonymsToUse.size() + 1; linkNum++) {
FormLink tmpRemoveButton = formUIf.addFormLink(CMD_DELETE_SYNONYM + linkNum, tmpLayout, Link.BUTTON_XSMALL);
tmpRemoveButton.setUserObject(glossItemSynonymsToUse.get(linkNum - 1));
tmpRemoveButton.setI18nKey("synonym.link.delete");
}
// add input field for new synonym
newSynonymField = formUIf.addTextElement("synonym.inputfield", "glossary.term.synonym", 100, "", tmpLayout);
newSynonymField.setVisible(true);
newSynonymField.setLabel("synonym.inputfield", null);
formUIf.addFormSubmitButton("form.submit", tmpLayout);
}
Aggregations