Search in sources :

Example 26 with TextElement

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

the class MetadatasStepController method forgeRow.

private DueDateWrapper forgeRow(int i, FormLayoutContainer tableCont) {
    String title = data.getNodePrefix() + " " + (i + 1);
    TextElement titleEl = uifactory.addTextElement("title_" + i, null, 32, title, tableCont);
    titleEl.setDisplaySize(21);
    DateChooser dueDateEl = uifactory.addDateChooser("duedate_" + i, "config.due.date", null, tableCont);
    dueDateEl.setDateChooserTimeEnabled(true);
    DueDateWrapper wrapper = new DueDateWrapper(titleEl, dueDateEl);
    return wrapper;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) DateChooser(org.olat.core.gui.components.form.flexible.elements.DateChooser)

Example 27 with TextElement

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

the class LecturesSearchFormController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
    login.setVisible(adminProps);
    userPropertyHandlers = userManager.getUserPropertyHandlersFor(PROPS_IDENTIFIER, adminProps);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler != null) {
            FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, PROPS_IDENTIFIER, false, formLayout);
            fi.setMandatory(false);
            // DO NOT validate email field => see OLAT-3324, OO-155, OO-222
            if (userPropertyHandler instanceof EmailProperty && fi instanceof TextElement) {
                TextElement textElement = (TextElement) fi;
                textElement.setItemValidatorProvider(null);
            }
            propFormItems.put(userPropertyHandler.getName(), fi);
        }
    }
    bulkEl = uifactory.addTextAreaElement("bulk", 4, 72, "", formLayout);
    bulkEl.setHelpText(translate("bulk.hint"));
    bulkEl.setExampleKey("bulk.example", null);
    List<RepositoryEntryLifecycle> cycles = lifecycleDao.loadPublicLifecycle();
    String[] dateKeys;
    String[] dateValues;
    if (cycles.isEmpty()) {
        dateKeys = new String[] { "none", "private" };
        dateValues = new String[] { translate("dates.none"), translate("dates.private") };
    } else {
        dateKeys = new String[] { "none", "private", "public" };
        dateValues = new String[] { translate("dates.none"), translate("dates.private"), translate("dates.public") };
    }
    dateTypesEl = uifactory.addRadiosVertical("dates", formLayout, dateKeys, dateValues);
    dateTypesEl.select(dateKeys[0], true);
    dateTypesEl.addActionListener(FormEvent.ONCHANGE);
    List<RepositoryEntryLifecycle> filteredCycles = new ArrayList<>();
    for (RepositoryEntryLifecycle cycle : cycles) {
        if (cycle.getValidTo() == null) {
            filteredCycles.add(cycle);
        }
    }
    String[] publicKeys = new String[filteredCycles.size()];
    String[] publicValues = new String[filteredCycles.size()];
    int count = 0;
    for (RepositoryEntryLifecycle cycle : filteredCycles) {
        publicKeys[count] = cycle.getKey().toString();
        StringBuilder sb = new StringBuilder(32);
        boolean labelAvailable = StringHelper.containsNonWhitespace(cycle.getLabel());
        if (labelAvailable) {
            sb.append(cycle.getLabel());
        }
        if (StringHelper.containsNonWhitespace(cycle.getSoftKey())) {
            if (labelAvailable)
                sb.append(" - ");
            sb.append(cycle.getSoftKey());
        }
        publicValues[count++] = sb.toString();
    }
    publicDatesEl = uifactory.addDropdownSingleselect("public.dates", formLayout, publicKeys, publicValues, null);
    String privateDatePage = velocity_root + "/cycle_dates.html";
    privateDatesCont = FormLayoutContainer.createCustomFormLayout("private.date", getTranslator(), privateDatePage);
    privateDatesCont.setRootForm(mainForm);
    privateDatesCont.setLabel("private.dates", null);
    formLayout.add("private.date", privateDatesCont);
    startDateEl = uifactory.addDateChooser("date.start", "date.start", null, privateDatesCont);
    startDateEl.setElementCssClass("o_sel_repo_lifecycle_validfrom");
    endDateEl = uifactory.addDateChooser("date.end", "date.end", null, privateDatesCont);
    endDateEl.setElementCssClass("o_sel_repo_lifecycle_validto");
    FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonCont);
    uifactory.addFormSubmitButton("search", buttonCont);
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) EmailProperty(org.olat.user.propertyhandlers.EmailProperty) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 28 with TextElement

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

the class EPShareListController method validateFormLogic.

@Override
protected boolean validateFormLogic(UserRequest ureq) {
    boolean allOk = true;
    // process all form-input fields and update data-model
    secureListBox();
    String genericError = null;
    for (EPSharePolicyWrapper policyWrapper : policyWrappers) {
        Type type = policyWrapper.getType();
        if (type == null) {
            // tutor implicit rule
            continue;
        }
        TextElement mailEl = policyWrapper.getMailEl();
        if (mailEl != null) {
            String mail = mailEl.getValue();
            if (StringHelper.containsNonWhitespace(mail)) {
                if (MailHelper.isValidEmailAddress(mail)) {
                    SecurityGroup allUsers = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
                    List<Identity> shareWithIdentities = userManager.findIdentitiesByEmail(Collections.singletonList(mail));
                    if (isAtLeastOneInSecurityGroup(shareWithIdentities, allUsers)) {
                        mailEl.setErrorKey("error.invitation.mail.used", new String[] { mail });
                        allOk &= false;
                    }
                } else {
                    mailEl.setErrorKey("map.share.with.mail.error", null);
                    allOk &= false;
                }
            } else if (type.equals(Type.invitation)) {
                genericError = translate("map.share.error.invite");
                allOk &= false;
            }
        } else if (type.equals(Type.group)) {
            List<BusinessGroup> groups = policyWrapper.getGroups();
            if (groups.size() == 0) {
                genericError = translate("map.share.error.group");
                allOk &= false;
            }
        } else if (type.equals(Type.user)) {
            List<Identity> idents = policyWrapper.getIdentities();
            if (idents.size() == 0) {
                genericError = translate("map.share.error.user");
                allOk &= false;
            }
        }
        if ((policyWrapper.getFromChooser() != null && policyWrapper.getFromChooser().hasError()) || (policyWrapper.getToChooser() != null && policyWrapper.getToChooser().hasError())) {
            genericError = translate("map.share.date.invalid");
            allOk &= false;
        }
        if (policyWrapper.getFrom() != null && policyWrapper.getTo() != null && policyWrapper.getFrom().after(policyWrapper.getTo())) {
            // show invalid date warning
            policyWrapper.getFromChooser().setErrorKey("from.date.behind.to", null);
            policyWrapper.getFromChooser().showError(true);
            genericError = translate("from.date.behind.to");
            allOk &= false;
        }
        StaticTextElement errTextEl = policyWrapper.getErrorEl();
        if (genericError != null && errTextEl != null) {
            errTextEl.setValue(genericError);
        }
    }
    return allOk && super.validateFormLogic(ureq);
}
Also used : Type(org.olat.portfolio.manager.EPMapPolicy.Type) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) SecurityGroup(org.olat.basesecurity.SecurityGroup) Identity(org.olat.core.id.Identity)

Example 29 with TextElement

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

the class EPShareListController method secureListBox.

/**
 * loops over all EPSharePolicyWrappers and updates the datamodel according to the
 * current form-values
 */
protected void secureListBox() {
    if (isLogDebugEnabled())
        logDebug(" 'securing' ListBox -->  updating policyWrappers with field values...", null);
    for (EPSharePolicyWrapper policyWrapper : policyWrappers) {
        if (policyWrapper.getUserListBox() != null) {
            List<Identity> identities = policyWrapper.getIdentities();
            policyWrapper.setIdentities(identities);
        }
        if (policyWrapper.getGroups() != null) {
            List<BusinessGroup> selectedGroups = policyWrapper.getGroups();
            policyWrapper.setGroups(selectedGroups);
        }
        TextElement firstNameEl = policyWrapper.getFirstNameEl();
        if (firstNameEl != null) {
            policyWrapper.getInvitation().setFirstName(firstNameEl.getValue());
        }
        TextElement lastNameEl = policyWrapper.getLastNameEl();
        if (lastNameEl != null) {
            policyWrapper.getInvitation().setLastName(lastNameEl.getValue());
        }
        TextElement mailEl = policyWrapper.getMailEl();
        if (mailEl != null) {
            policyWrapper.getInvitation().setMail(mailEl.getValue());
        }
        if (policyWrapper.getFromChooser() != null) {
            policyWrapper.setFrom(policyWrapper.getFromChooser().getDate());
        }
        if (policyWrapper.getToChooser() != null) {
            policyWrapper.setTo(policyWrapper.getToChooser().getDate());
        }
    }
}
Also used : StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity)

Example 30 with TextElement

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

the class EPStructureDetailsController method setCollectRestrictions.

protected void setCollectRestrictions() {
    if (restrictionElements == null || restrictionElements.isEmpty()) {
        return;
    }
    for (int i = 0; i < restrictionElements.size(); i++) {
        final SingleSelection restrictionElement = restrictionElements.get(i);
        final SingleSelection restrictToArtefactElement = restrictToArtefactElements.get(i);
        final TextElement amountElement = amountElements.get(i);
        final CollectRestriction cr = (CollectRestriction) restrictionElement.getUserObject();
        String restriction = "";
        if (restrictionElement.isOneSelected()) {
            restriction = restrictionElement.getSelectedKey();
        }
        String artefactType = "";
        if (restrictToArtefactElement.isOneSelected()) {
            artefactType = restrictToArtefactElement.getSelectedKey();
        }
        final String amount = amountElement.getValue();
        cr.setRestriction(restriction);
        cr.setArtefactType(artefactType);
        if (StringHelper.containsNonWhitespace(amount)) {
            try {
                cr.setAmount(Integer.parseInt(amount));
            } catch (final NumberFormatException e) {
                logWarn("Wrong format for number", e);
            }
        }
    }
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

Aggregations

TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)146 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)40 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)36 FormItem (org.olat.core.gui.components.form.flexible.FormItem)34 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)30 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)26 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)24 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)18 ArrayList (java.util.ArrayList)16 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)16 Identity (org.olat.core.id.Identity)12 HashMap (java.util.HashMap)8 FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)8 EmailProperty (org.olat.user.propertyhandlers.EmailProperty)8 Date (java.util.Date)6 DateChooser (org.olat.core.gui.components.form.flexible.elements.DateChooser)6 StaticTextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.StaticTextElementImpl)6 TextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.TextElementImpl)6 RichTextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl)6 File (java.io.File)4