Search in sources :

Example 21 with FormLinkImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.

the class TranslationToolStartCrumbController method initMissingItemsElements.

private void initMissingItemsElements(FormUIFactory formFactory, FormItemContainer formLayout, String[] bundlesKeys, String[] bundlesValues) {
    // Add missing bundles selector
    missingBundlesSelection = formFactory.addDropdownSingleselect("missingBundlesSelection", this.flc, bundlesKeys, bundlesValues, null);
    missingBundlesSelection.addActionListener(FormEvent.ONCHANGE);
    missingBundlesSelection.select(ALL_BUNDLES_IDENTIFYER, true);
    // Add missing bundles children switch
    String[] missingBundles = new String[] { translate("generic.limit.bundles.includeChildren") };
    missingBundlesIncludeBundlesChildrenSwitch = formFactory.addCheckboxesHorizontal("missingBundlesIncludeBundlesChildrenSwitch", null, flc, new String[] { KEYS_ENABLED }, // disabled label by setting i18nLabel to null
    missingBundles);
    missingBundlesIncludeBundlesChildrenSwitch.select(KEYS_ENABLED, true);
    missingBundlesIncludeBundlesChildrenSwitch.addActionListener(FormEvent.ONCLICK);
    formLayout.add(missingBundlesIncludeBundlesChildrenSwitch);
    missingBundlesIncludeBundlesChildrenSwitch.setEnabled(false);
    // Add priority sort switch
    String[] missingBundlesPrio = new String[] { translate("generic.sort.by.priority") };
    missingBundlesPrioritySortSwitch = formFactory.addCheckboxesHorizontal("missingBundlesPrioritySortSwitch", null, this.flc, new String[] { KEYS_ENABLED }, // disabled label by setting i18nLabel to null
    missingBundlesPrio);
    missingBundlesPrioritySortSwitch.select(KEYS_ENABLED, true);
    missingBundlesPrioritySortSwitch.addActionListener(FormEvent.ONCLICK);
    formLayout.add(missingBundlesPrioritySortSwitch);
    // Add button to trigger missing keys search
    missingListButton = new FormLinkImpl("missingListButton", "missingListButton", "generic.listButton", Link.BUTTON);
    formLayout.add(missingListButton);
    missingTranslateButton = new FormLinkImpl("missingTranslateButton", "missingTranslateButton", "generic.translateButton", Link.BUTTON);
    formLayout.add(missingTranslateButton);
}
Also used : FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)

Example 22 with FormLinkImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.

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 23 with FormLinkImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.

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 24 with FormLinkImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.

the class VCEditForm method addRow.

private void addRow(int index, final MeetingDate date) {
    // title
    TextElement vcTitle = uifactory.addTextElement("title" + counter, null, -1, date.getTitle(), editVC);
    vcTitle.setDisplaySize(30);
    vcTitle.setMandatory(true);
    vcTitle.setNotEmptyCheck("vc.table.title.empty");
    vcTitleInputList.add(index, vcTitle);
    // description
    TextElement vcDescription = uifactory.addTextElement("description" + counter, null, -1, date.getDescription(), editVC);
    vcDescription.setDisplaySize(20);
    vcDescription.setNotEmptyCheck("vc.table.description.empty");
    vcDescription.setMandatory(true);
    vcDescriptionInputList.add(index, vcDescription);
    // begin
    DateChooser vcScheduleDate = uifactory.addDateChooser("begin" + counter, "vc.table.begin", null, editVC);
    vcScheduleDate.setNotEmptyCheck("vc.table.begin.empty");
    vcScheduleDate.setValidDateCheck("vc.table.begin.error");
    vcScheduleDate.setMandatory(true);
    vcScheduleDate.setDisplaySize(20);
    vcScheduleDate.setDateChooserTimeEnabled(true);
    vcScheduleDate.setDate(date.getBegin());
    vcCalenderbeginInputList.add(index, vcScheduleDate);
    // add date duration
    SimpleDateFormat sdDuration = new SimpleDateFormat("HH:mm");
    TimeZone tz = TimeZone.getTimeZone("Etc/GMT+0");
    sdDuration.setTimeZone(tz);
    TextElement vcDuration = uifactory.addTextElement("duration" + counter, "vc.table.duration", 5, String.valueOf(0), editVC);
    vcDuration.setDisplaySize(5);
    vcDuration.setValue(sdDuration.format(new Date(date.getEnd().getTime() - date.getBegin().getTime())));
    vcDuration.setRegexMatchCheck("\\d{1,2}:\\d\\d", "form.error.format");
    vcDuration.setExampleKey("vc.table.duration.example", null);
    vcDuration.setNotEmptyCheck("vc.table.duration.empty");
    vcDuration.setErrorKey("vc.table.duration.error", null);
    vcDuration.setMandatory(true);
    vcDuration.showExample(true);
    vcDuration.showError(false);
    this.vcDurationInputList.add(index, vcDuration);
    // add row button
    FormLink addButton = new FormLinkImpl("add" + counter, "add" + counter, "vc.table.add", Link.BUTTON_SMALL);
    editVC.add(addButton);
    vcAddButtonList.add(index, addButton);
    // remove row button
    FormLink delButton = new FormLinkImpl("delete" + counter, "delete" + counter, "vc.table.delete", Link.BUTTON_SMALL);
    editVC.add(delButton);
    vcDelButtonList.add(index, delButton);
    // increase the counter to enable unique component names
    counter++;
}
Also used : TimeZone(java.util.TimeZone) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl) DateChooser(org.olat.core.gui.components.form.flexible.elements.DateChooser) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 25 with FormLinkImpl

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

the class SmsPhoneElement method setRootForm.

@Override
public void setRootForm(Form rootForm) {
    String dispatchId = component.getDispatchID();
    editLink = new FormLinkImpl(dispatchId + "_editSmsButton", "editSms", "edit", Link.BUTTON);
    editLink.setDomReplacementWrapperRequired(false);
    editLink.setTranslator(getTranslator());
    editLink.setIconLeftCSS("o_icon o_icon_edit");
    removeLink = new FormLinkImpl(dispatchId + "_removeSmsButton", "removeSms", "remove", Link.BUTTON);
    removeLink.setDomReplacementWrapperRequired(false);
    removeLink.setTranslator(getTranslator());
    removeLink.setIconLeftCSS("o_icon o_icon_delete");
    super.setRootForm(rootForm);
}
Also used : FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)

Aggregations

FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)52 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)8 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 FormItem (org.olat.core.gui.components.form.flexible.FormItem)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 BusinessGroupShort (org.olat.group.BusinessGroupShort)4 BGArea (org.olat.group.area.BGArea)4 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 Locale (java.util.Locale)2 TimeZone (java.util.TimeZone)2 ValidationError (org.olat.core.gui.components.form.ValidationError)2 DateChooser (org.olat.core.gui.components.form.flexible.elements.DateChooser)2 AutoCompleterImpl (org.olat.core.gui.components.form.flexible.impl.elements.AutoCompleterImpl)2 ItemValidatorProvider (org.olat.core.gui.components.form.flexible.impl.elements.ItemValidatorProvider)2