Search in sources :

Example 56 with SingleSelection

use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.

the class LLEditForm method addNewFormLink.

/**
 * Add a new form link line to the list of link elements.
 *
 * @param link the link model object
 */
private void addNewFormLink(int index, final LLModel link) {
    // add link target
    TextElement lTarget = uifactory.addTextElement("target" + counter, null, -1, link.getTarget(), flc);
    lTarget.setPlaceholderKey("target.example", null);
    lTarget.clearError();
    lTarget.setEnabled(!link.isIntern());
    lTarget.setDisplaySize(40);
    lTarget.setMandatory(true);
    lTarget.setNotEmptyCheck("ll.table.target.error");
    lTarget.setItemValidatorProvider(new ItemValidatorProvider() {

        public boolean isValidValue(String value, ValidationError validationError, Locale locale) {
            try {
                if (!value.contains("://")) {
                    value = "http://".concat(value);
                }
                new URL(value);
            } catch (MalformedURLException e) {
                validationError.setErrorKey("ll.table.target.error.format");
                return false;
            }
            return true;
        }
    });
    lTarget.addActionListener(FormEvent.ONCHANGE);
    lTarget.setUserObject(link);
    lTargetInputList.add(index, lTarget);
    // add html target
    SingleSelection htmlTargetSelection = uifactory.addDropdownSingleselect("html_target" + counter, flc, new String[] { BLANK_KEY, SELF_KEY }, new String[] { translate("ll.table.html_target"), translate("ll.table.html_target.self") }, null);
    htmlTargetSelection.setUserObject(link);
    htmlTargetSelection.select((SELF_KEY.equals(link.getHtmlTarget()) ? SELF_KEY : BLANK_KEY), true);
    lHtmlTargetInputList.add(index, htmlTargetSelection);
    // add link description
    TextElement lDescription = uifactory.addTextElement("description" + counter, null, -1, link.getDescription(), flc);
    lDescription.clearError();
    lDescription.setDisplaySize(20);
    lDescription.setNotEmptyCheck("ll.table.description.error");
    lDescription.setMandatory(true);
    lDescription.setPlaceholderKey("ll.table.description", null);
    lDescription.setUserObject(link);
    lDescriptionInputList.add(index, lDescription);
    // add link comment
    TextElement lComment = uifactory.addTextAreaElement("comment" + counter, null, -1, 2, 50, true, link.getComment(), flc);
    lComment.setPlaceholderKey("ll.table.comment", null);
    lComment.setDisplaySize(20);
    lComment.setUserObject(link);
    lCommentInputList.add(index, lComment);
    // add link add action button
    FormLink addButton = new FormLinkImpl("add" + counter, "add" + counter, "", Link.BUTTON_SMALL + Link.NONTRANSLATED);
    addButton.setUserObject(link);
    addButton.setDomReplacementWrapperRequired(false);
    addButton.setIconLeftCSS("o_icon o_icon-lg o_icon-fw o_icon_add");
    flc.add(addButton);
    lAddButtonList.add(index, addButton);
    // add link deletion action button
    FormLink delButton = new FormLinkImpl("delete" + counter, "delete" + counter, "", Link.BUTTON_SMALL + Link.NONTRANSLATED);
    delButton.setUserObject(link);
    delButton.setDomReplacementWrapperRequired(false);
    delButton.setIconLeftCSS("o_icon o_icon-lg o_icon-fw o_icon_delete_item");
    flc.add(delButton);
    lDelButtonList.add(index, delButton);
    // custom media action button
    FormLink mediaButton = new FormLinkImpl("media" + counter, "media" + counter, "  ", Link.NONTRANSLATED);
    mediaButton.setIconLeftCSS("o_icon o_icon_browse o_icon-lg");
    mediaButton.setDomReplacementWrapperRequired(false);
    mediaButton.setUserObject(link);
    flc.add(mediaButton);
    lCustomMediaButtonList.add(index, mediaButton);
    // increase the counter to enable unique component names
    counter++;
}
Also used : Locale(java.util.Locale) MalformedURLException(java.net.MalformedURLException) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ItemValidatorProvider(org.olat.core.gui.components.form.flexible.impl.elements.ItemValidatorProvider) FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl) ValidationError(org.olat.core.gui.components.form.ValidationError) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) URL(java.net.URL)

Example 57 with SingleSelection

use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.

the class ChecklistEditCheckpointsController method addNewFormCheckpoint.

private void addNewFormCheckpoint(int index, Checkpoint checkpoint) {
    // add checkpoint title
    String pointTitle = checkpoint.getTitle() == null ? "" : checkpoint.getTitle();
    TextElement title = uifactory.addTextElement("title" + counter, null, -1, pointTitle, titleContainer);
    // TODO:SK:2009-11-20:PB:should be default -> check layout in velocity.
    title.showError(false);
    title.setDisplaySize(20);
    title.setMandatory(true);
    // TODO:Stefan Köber: please verify that the default not empty check does the same as you ItemValidatorProvider
    title.setNotEmptyCheck("cl.table.title.error");
    title.setUserObject(checkpoint);
    titleInputList.add(index, title);
    // add checkpoint description
    TextElement description = uifactory.addTextElement("description" + counter, null, -1, checkpoint.getDescription(), titleContainer);
    description.setDisplaySize(35);
    description.setMandatory(false);
    description.setUserObject(checkpoint);
    descriptionInputList.add(index, description);
    // add link comment
    String[] keys = CheckpointMode.getModes();
    String[] values = new String[keys.length];
    for (int i = 0; i < keys.length; i++) {
        values[i] = translate(keys[i]);
    }
    SingleSelection mode = uifactory.addDropdownSingleselect("modus" + counter, "form.enableCancelEnroll", titleContainer, keys, values, null);
    mode.select(checkpoint.getMode(), checkpoint.getMode() != null);
    mode.setUserObject(checkpoint);
    modeInputList.add(index, mode);
    // add link deletion action button
    FormLink delButton = new FormLinkImpl("delete" + counter, "delete" + counter, "cl.table.delete", Link.BUTTON_SMALL);
    delButton.setUserObject(checkpoint);
    titleContainer.add(delButton);
    delButtonList.add(index, delButton);
    // increase the counter to enable unique component names
    counter++;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 58 with SingleSelection

use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.

the class LandingPagesAdminController method initRuleWrapper.

private RuleWrapper initRuleWrapper(int pos, Rule rule, FormItemContainer formLayout) {
    int i = counter.incrementAndGet();
    RuleWrapper wrapper = new RuleWrapper(rule);
    wrapper.setPosition(pos);
    SingleSelection roleEl = uifactory.addDropdownSingleselect("role-" + i, null, formLayout, roleKeys, roleValues, null);
    String role = rule.getRole();
    for (int j = roleKeys.length; j-- > 0; ) {
        if (roleKeys[j].equals(role)) {
            roleEl.select(roleKeys[j], true);
        }
    }
    wrapper.setRoleEl(roleEl);
    SingleSelection attrNameEl = uifactory.addDropdownSingleselect("attr-key-" + i, null, formLayout, attrKeys, attrValues, null);
    String userAttributeKey = rule.getUserAttributeKey();
    for (int j = attrKeys.length; j-- > 0; ) {
        if (attrKeys[j].equals(userAttributeKey)) {
            attrNameEl.select(attrKeys[j], true);
        }
    }
    wrapper.setAttrNameEl(attrNameEl);
    TextElement valEl = uifactory.addTextElement("attr-val-" + i, null, 256, "", formLayout);
    valEl.setValue(rule.getUserAttributeValue());
    wrapper.setAttrValueEl(valEl);
    TextElement landingPageEl = uifactory.addTextElement("l-page-" + i, null, 256, "", formLayout);
    landingPageEl.setValue(rule.getLandingPath());
    wrapper.setLandingPageEl(landingPageEl);
    formLayout.add(landingPageEl);
    FormLink chooser = uifactory.addFormLink("chooser-" + i, "chooser", RCols.landingPageChooser.i18nKey(), null, formLayout, Link.BUTTON);
    chooser.setIconRightCSS("o_icon o_icon_caret");
    chooser.setUserObject(wrapper);
    wrapper.setLandingPageChooser(chooser);
    return wrapper;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 59 with SingleSelection

use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.

the class FormUIFactory method addRadiosVertical.

/**
 * Add vertical aligned radio buttons<br>
 *
 * @param name
 * @param i18nLabel
 * @param formLayout
 * @param theKeys
 * @param theValues
 * @return
 */
public SingleSelection addRadiosVertical(final String name, final String i18nLabel, FormItemContainer formLayout, final String[] theKeys, final String[] theValues) {
    SingleSelection ss = new SingleSelectionImpl(name, name, SingleSelection.Layout.vertical);
    ss.setKeysAndValues(theKeys, theValues, null);
    setLabelIfNotNull(i18nLabel, ss);
    formLayout.add(ss);
    return ss;
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) SingleSelectionImpl(org.olat.core.gui.components.form.flexible.impl.elements.SingleSelectionImpl)

Example 60 with SingleSelection

use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.

the class FormUIFactory method addRadiosHorizontal.

/**
 * Add horizontal aligned radio buttons. <br>
 *
 * @param name
 * @param i18nLabel
 * @param formLayout
 * @param theKeys
 * @param theValues
 * @return
 */
public SingleSelection addRadiosHorizontal(final String name, final String i18nLabel, FormItemContainer formLayout, final String[] theKeys, final String[] theValues) {
    SingleSelection ss = new SingleSelectionImpl(name, name, SingleSelection.Layout.horizontal);
    ss.setKeysAndValues(theKeys, theValues, null);
    setLabelIfNotNull(i18nLabel, ss);
    formLayout.add(ss);
    return ss;
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) SingleSelectionImpl(org.olat.core.gui.components.form.flexible.impl.elements.SingleSelectionImpl)

Aggregations

SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)88 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)34 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)26 FormItem (org.olat.core.gui.components.form.flexible.FormItem)18 ArrayList (java.util.ArrayList)14 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)12 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)12 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)12 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)10 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)8 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)8 File (java.io.File)6 Map (java.util.Map)6 FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 SliderWrapper (org.olat.modules.forms.ui.model.SliderWrapper)6 UserManager (org.olat.user.UserManager)6 HashMap (java.util.HashMap)4 List (java.util.List)4 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)4