Search in sources :

Example 6 with FormLinkImpl

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

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

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

the class NoteController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // At beginning, the forms shows the note as a disabled field and an edit button. When the user
    // clicks the edit button, the rich text field turns to the enabled state and the edit button
    // is set to visible false and the submit button to visible true.
    setFormTitle("note", new String[] { StringHelper.escapeHtml(n.getNoteTitle()) });
    // set custom css style to override default read-only view of rich text element
    setFormStyle("o_notes");
    // we don't use FormUIFactory.addFormSubmitButton(...) here since that would cause the following custom CSS setting to get ignored.
    editButton = new FormLinkImpl("edit", "edit", "edit", Link.BUTTON_SMALL);
    editButton.setCustomEnabledLinkCSS("pull-right btn btn-default");
    editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
    formLayout.add(editButton);
    noteField = uifactory.addRichTextElementForStringData("noteField", null, n.getNoteText(), 20, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl());
    noteField.setEnabled(false);
    noteField.setMaxLength(4000);
    submitButton = uifactory.addFormSubmitButton("submit", formLayout);
    submitButton.setVisible(false);
}
Also used : FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)

Example 8 with FormLinkImpl

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

the class ENEditGroupAreaFormController method validateGroupFields.

private boolean validateGroupFields() {
    boolean retVal = true;
    List<Long> activeGroupSelection = null;
    List<Long> activeAreaSelection = null;
    easyAreaList.clearError();
    easyGroupList.clearError();
    if (!isEmpty(easyGroupList)) {
        // check whether groups exist
        activeGroupSelection = getKeys(easyGroupList);
        Set<Long> missingGroups = new HashSet<Long>();
        List<BusinessGroupShort> existingGroups = businessGroupService.loadShortBusinessGroups(activeGroupSelection);
        a_a: for (Long activeGroupKey : activeGroupSelection) {
            for (BusinessGroupShort group : existingGroups) {
                if (group.getKey().equals(activeGroupKey)) {
                    continue a_a;
                }
            }
            missingGroups.add(activeGroupKey);
        }
        if (missingGroups.size() > 0) {
            retVal = false;
            String labelKey = missingGroups.size() == 1 ? "error.notfound.name" : "error.notfound.names";
            String csvMissGrps = toString(missingGroups);
            String[] params = new String[] { "-", csvMissGrps };
            // create error with link to fix it
            String vc_errorPage = velocity_root + "/erroritem.html";
            FormLayoutContainer errorGroupItemLayout = FormLayoutContainer.createCustomFormLayout("errorgroupitem", getTranslator(), vc_errorPage);
            easyGroupList.setErrorComponent(errorGroupItemLayout, this.flc);
            // FIXING LINK ONLY IF A DEFAULTCONTEXT EXISTS
            fixGroupError = new FormLinkImpl("error.fix", "create");
            // link
            fixGroupError.setCustomEnabledLinkCSS("btn btn-default");
            errorGroupItemLayout.add(fixGroupError);
            fixGroupError.setErrorKey(labelKey, params);
            fixGroupError.showError(true);
            fixGroupError.showLabel(false);
            // String[].lenght > 1 -> show bulkmode creation group
            if (missingGroups.size() > 1) {
                fixGroupError.setUserObject(new String[] { csvMissGrps, "dummy" });
            } else {
                fixGroupError.setUserObject(new String[] { csvMissGrps });
            }
            easyGroupList.showError(true);
        }
    }
    if (!isEmpty(easyAreaList)) {
        // check whether areas exist
        activeAreaSelection = getKeys(easyAreaList);
        List<Long> missingAreas = new ArrayList<Long>();
        List<BGArea> cnt = areaManager.loadAreas(activeAreaSelection);
        a_a: for (Long activeAreaKey : activeAreaSelection) {
            for (BGArea element : cnt) {
                if (element.getKey().equals(activeAreaKey)) {
                    continue a_a;
                }
            }
            missingAreas.add(activeAreaKey);
        }
        if (missingAreas.size() > 0) {
            retVal = false;
            String labelKey = missingAreas.size() == 1 ? "error.notfound.name" : "error.notfound.names";
            String csvMissAreas = toString(missingAreas);
            String[] params = new String[] { "-", csvMissAreas };
            // create error with link to fix it
            String vc_errorPage = velocity_root + "/erroritem.html";
            FormLayoutContainer errorAreaItemLayout = FormLayoutContainer.createCustomFormLayout("errorareaitem", getTranslator(), vc_errorPage);
            easyAreaList.setErrorComponent(errorAreaItemLayout, this.flc);
            // FXINGIN LINK ONLY IF DEFAULT CONTEXT EXISTS
            // erstellen
            fixAreaError = new FormLinkImpl("error.fix", "create");
            // link
            fixAreaError.setCustomEnabledLinkCSS("btn btn-default");
            errorAreaItemLayout.add(fixAreaError);
            fixAreaError.setErrorKey(labelKey, params);
            fixAreaError.showError(true);
            fixAreaError.showLabel(false);
            // String[].lenght > 1 -> show bulkmode creation group
            if (missingAreas.size() > 1) {
                fixAreaError.setUserObject(new String[] { csvMissAreas, "dummy" });
            } else {
                fixAreaError.setUserObject(new String[] { csvMissAreas });
            }
            easyAreaList.showError(true);
        }
    }
    boolean easyGroupOK = activeGroupSelection != null && activeGroupSelection.size() > 0;
    boolean easyAreaOK = activeAreaSelection != null && activeAreaSelection.size() > 0;
    if (!easyGroupOK && !easyAreaOK) {
        // error concerns both fields -> set it as switch error
        easyGroupList.setErrorKey("form.noGroupsOrAreas", null);
        retVal = false;
    }
    // raise error if someone removed all groups and areas from form
    if (!retVal && !easyGroupOK && !easyAreaOK) {
        easyGroupList.setErrorKey("form.noGroupsOrAreas", null);
    }
    return retVal;
}
Also used : ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl) BGArea(org.olat.group.area.BGArea) BusinessGroupShort(org.olat.group.BusinessGroupShort) HashSet(java.util.HashSet)

Example 9 with FormLinkImpl

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

the class BGCopySingleGroupStep method getStepTitle.

@Override
public FormItem getStepTitle() {
    String groupName = StringHelper.escapeHtml(groupToCopy.getName());
    String title = getTranslator().translate("copy.wizard.bgstep", new String[] { groupName });
    FormLink fl = new FormLinkImpl("copy.wizard." + groupToCopy.getKey(), null, title, Link.FLEXIBLEFORMLNK + Link.NONTRANSLATED);
    fl.setTranslator(getTranslator());
    return fl;
}
Also used : FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 10 with FormLinkImpl

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

the class NoteController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // At beginning, the forms shows the note as a disabled field and an edit button. When the user
    // clicks the edit button, the rich text field turns to the enabled state and the edit button
    // is set to visible false and the submit button to visible true.
    setFormTitle("note", new String[] { StringHelper.escapeHtml(n.getNoteTitle()) });
    // set custom css style to override default read-only view of rich text element
    setFormStyle("o_notes");
    // we don't use FormUIFactory.addFormSubmitButton(...) here since that would cause the following custom CSS setting to get ignored.
    editButton = new FormLinkImpl("edit", "edit", "edit", Link.BUTTON_SMALL);
    editButton.setCustomEnabledLinkCSS("pull-right btn btn-default");
    editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
    formLayout.add(editButton);
    noteField = uifactory.addRichTextElementForStringData("noteField", null, n.getNoteText(), 20, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl());
    noteField.setEnabled(false);
    noteField.setMaxLength(4000);
    submitButton = uifactory.addFormSubmitButton("submit", formLayout);
    submitButton.setVisible(false);
}
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