Search in sources :

Example 6 with StaticTextElement

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

the class BusinessGroupFormController 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) {
    // Create the business group name input text element
    if (bulkMode) {
        businessGroupName = uifactory.addTextElement("create.form.title.bgnames", "create.form.title.bgnames", 10 * BusinessGroup.MAX_GROUP_NAME_LENGTH, "", formLayout);
        businessGroupName.setExampleKey("create.form.message.example.group", null);
    } else {
        businessGroupName = uifactory.addTextElement("create.form.title.bgname", "create.form.title.bgname", BusinessGroup.MAX_GROUP_NAME_LENGTH, "", formLayout);
        businessGroupName.setNotLongerThanCheck(BusinessGroup.MAX_GROUP_NAME_LENGTH, "create.form.error.nameTooLong");
        businessGroupName.setRegexMatchCheck(BusinessGroup.VALID_GROUPNAME_REGEXP, "create.form.error.illegalName");
    }
    businessGroupName.setElementCssClass("o_sel_group_edit_title");
    businessGroupName.setMandatory(true);
    businessGroupName.setEnabled(!BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.title));
    formLayout.setElementCssClass("o_sel_group_edit_group_form");
    // Create the business group description input rich text element
    businessGroupDescription = uifactory.addRichTextElementForStringDataMinimalistic("create.form.title.description", "create.form.title.description", "", 10, -1, formLayout, getWindowControl());
    businessGroupDescription.setEnabled(!BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.description));
    if (businessGroup != null && !bulkMode) {
        // link to group direct jump in business path
        BusinessControlFactory bcf = BusinessControlFactory.getInstance();
        List<ContextEntry> entries = bcf.createCEListFromString("[BusinessGroup:" + businessGroup.getKey() + "]");
        String url = bcf.getAsURIString(entries, true);
        url = "<span class='o_copy_code o_nowrap'><input type='text' value='" + url + "' onclick='this.select()'/></span>";
        StaticTextElement urlEl = uifactory.addStaticTextElement("create.form.businesspath", url, formLayout);
        urlEl.setElementCssClass("o_sel_group_url");
        // link to group visiting card
        bcf = BusinessControlFactory.getInstance();
        entries = bcf.createCEListFromString("[GroupCard:" + businessGroup.getKey() + "]");
        url = "<span class='o_copy_code o_nowrap'><input type='text' value='" + bcf.getAsURIString(entries, true) + "' onclick='this.select()'/></span>";
        StaticTextElement cardEl = uifactory.addStaticTextElement("create.form.groupcard", url, formLayout);
        cardEl.setElementCssClass("o_sel_group_card_url");
    }
    uifactory.addSpacerElement("myspacer", formLayout, true);
    // Minimum members input
    businessGroupMinimumMembers = uifactory.addTextElement("create.form.title.min", "create.form.title.min", 5, "", formLayout);
    businessGroupMinimumMembers.setDisplaySize(6);
    // currently the minimum feature is not enabled
    businessGroupMinimumMembers.setVisible(false);
    businessGroupMinimumMembers.setElementCssClass("o_sel_group_edit_min_members");
    // Maximum members input
    businessGroupMaximumMembers = uifactory.addTextElement("create.form.title.max", "create.form.title.max", 5, "", formLayout);
    businessGroupMaximumMembers.setDisplaySize(6);
    businessGroupMaximumMembers.setElementCssClass("o_sel_group_edit_max_members");
    // Checkboxes
    enableWaitingList = uifactory.addCheckboxesHorizontal("create.form.enableWaitinglist", null, formLayout, waitingListKeys, waitingListValues);
    enableWaitingList.setElementCssClass("o_sel_group_edit_waiting_list");
    enableAutoCloseRanks = uifactory.addCheckboxesHorizontal("create.form.enableAutoCloseRanks", null, formLayout, autoCloseKeys, autoCloseValues);
    enableAutoCloseRanks.setElementCssClass("o_sel_group_edit_auto_close_ranks");
    // Enable only if specification of min and max members is possible
    // currently the minimum feature is not enabled
    businessGroupMinimumMembers.setVisible(false);
    businessGroupMaximumMembers.setVisible(true);
    enableWaitingList.setVisible(true);
    enableAutoCloseRanks.setVisible(true);
    boolean managedSettings = BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.settings);
    businessGroupMinimumMembers.setEnabled(!managedSettings);
    businessGroupMaximumMembers.setEnabled(!managedSettings);
    enableWaitingList.setEnabled(!managedSettings);
    enableAutoCloseRanks.setEnabled(!managedSettings);
    if ((businessGroup != null) && (!bulkMode)) {
        businessGroupName.setValue(businessGroup.getName());
        businessGroupDescription.setValue(businessGroup.getDescription());
        Integer minimumMembers = businessGroup.getMinParticipants();
        Integer maximumMembers = businessGroup.getMaxParticipants();
        businessGroupMinimumMembers.setValue(minimumMembers == null || minimumMembers.intValue() <= 0 ? "" : minimumMembers.toString());
        businessGroupMaximumMembers.setValue(maximumMembers == null || maximumMembers.intValue() < 0 ? "" : maximumMembers.toString());
        if (businessGroup.getWaitingListEnabled() != null) {
            enableWaitingList.select("create.form.enableWaitinglist", businessGroup.getWaitingListEnabled());
        }
        if (businessGroup.getAutoCloseRanksEnabled() != null) {
            enableAutoCloseRanks.select("create.form.enableAutoCloseRanks", businessGroup.getAutoCloseRanksEnabled());
        }
    }
    if (!embbeded) {
        // Create submit and cancel buttons
        final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
        formLayout.add(buttonLayout);
        FormSubmit submit = uifactory.addFormSubmitButton("finish", buttonLayout);
        submit.setEnabled(!BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.details));
        uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
    }
    if ((businessGroup != null) && (!bulkMode)) {
        // managed group information
        boolean managed = StringHelper.containsNonWhitespace(businessGroup.getExternalId()) || businessGroup.getManagedFlags().length > 0;
        if (managed) {
            uifactory.addSpacerElement("managedspacer", formLayout, false);
            String extId = businessGroup.getExternalId() == null ? "" : businessGroup.getExternalId();
            StaticTextElement externalIdEl = uifactory.addStaticTextElement("create.form.externalid", extId, formLayout);
            externalIdEl.setElementCssClass("o_sel_group_external_id");
            FormLayoutContainer flagsFlc = FormLayoutContainer.createHorizontalFormLayout("flc_flags", getTranslator());
            flagsFlc.setLabel("create.form.managedflags", null);
            formLayout.add(flagsFlc);
            String flags = businessGroup.getManagedFlagsString() == null ? "" : businessGroup.getManagedFlagsString().trim();
            String flagsFormatted = null;
            if (flags.length() > 0) {
                // use translator from REST admin package to import managed flags context help strings
                Translator managedTrans = Util.createPackageTranslator(RestapiAdminController.class, ureq.getLocale());
                StringBuffer flagList = new StringBuffer();
                flagList.append("<p class=\"o_important\">");
                flagList.append(translate("create.form.managedflags.intro"));
                flagList.append("</div>");
                flagList.append("<ul>");
                for (String flag : flags.split(",")) {
                    flagList.append("<li>");
                    flagList.append(managedTrans.translate("managed.flags.group." + flag));
                    flagList.append("</li>");
                }
                flagsFormatted = flagList.toString();
            } else {
                flagsFormatted = flags;
            }
            StaticTextElement flagsEl = uifactory.addStaticTextElement("create.form.managedflags", flagsFormatted, flagsFlc);
            flagsEl.showLabel(false);
            flagsEl.setElementCssClass("o_sel_group_managed_flags");
        }
    }
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) Translator(org.olat.core.gui.translator.Translator) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 7 with StaticTextElement

use of org.olat.core.gui.components.form.flexible.elements.StaticTextElement 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 8 with StaticTextElement

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

the class EPStructureDetailsController method validateFormLogic.

/**
 * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#validateFormLogic(org.olat.core.gui.UserRequest)
 */
@Override
protected boolean validateFormLogic(UserRequest ureq) {
    if (rootStructure instanceof EPStructuredMapTemplate && restrictionElements != null) {
        setCollectRestrictions();
        clearErrors();
        ArrayList<String> usedTypes = new ArrayList<String>();
        int i = 0;
        boolean hasError = false;
        for (SingleSelection restrictionElement : restrictionElements) {
            CollectRestriction restriction = (CollectRestriction) restrictionElement.getUserObject();
            if (usedTypes.contains(restriction.getArtefactType())) {
                StaticTextElement thisErrorEl = errorElements.get(i);
                thisErrorEl.setVisible(true);
                thisErrorEl.setValue(translate("collect.restriction.duplicate.type"));
                hasError = true;
            }
            usedTypes.add(restriction.getArtefactType());
            boolean hasRestriction = StringHelper.containsNonWhitespace(restriction.getRestriction());
            boolean hasArtType = StringHelper.containsNonWhitespace(restriction.getArtefactType());
            boolean hasAmount = restriction.getAmount() > 0;
            boolean isValid = restriction.isValid();
            if (!isValid && (hasRestriction || hasArtType || hasAmount)) {
                StaticTextElement thisErrorEl = errorElements.get(i);
                thisErrorEl.setVisible(true);
                thisErrorEl.setValue(translate("collect.restriction.incomplete"));
                hasError = true;
            }
            i++;
        }
        return !hasError;
    }
    return true;
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement)

Example 9 with StaticTextElement

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

the class ProjectEditDetailsFormController method initForm.

/**
 * Initialize form.
 */
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // create form elements
    projectTitle = uifactory.addTextElement("title", "detailsform.title.label", 100, project.getTitle(), formLayout);
    // account-Managers
    StringBuilder projectLeaderString = new StringBuilder();
    for (Iterator<Identity> iterator = project.getProjectLeaders().iterator(); iterator.hasNext(); ) {
        Identity identity = iterator.next();
        String last = identity.getUser().getProperty(UserConstants.LASTNAME, getLocale());
        String first = identity.getUser().getProperty(UserConstants.FIRSTNAME, getLocale());
        if (projectLeaderString.length() > 0) {
            projectLeaderString.append(",");
        }
        projectLeaderString.append(first);
        projectLeaderString.append(" ");
        projectLeaderString.append(last);
    }
    projectLeaders = uifactory.addTextElement("projectleaders", "detailsform.projectleaders.label", 100, projectLeaderString.toString(), formLayout);
    projectLeaders.setEnabled(false);
    // add the learning objectives rich text input element
    projectDescription = uifactory.addRichTextElementForStringData("description", "detailsform.description.label", project.getDescription(), 10, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl());
    projectDescription.setMaxLength(2500);
    stateLayout = FormLayoutContainer.createHorizontalFormLayout("stateLayout", getTranslator());
    stateLayout.setLabel("detailsform.state.label", null);
    formLayout.add(stateLayout);
    String stateValue = getTranslator().translate(projectBrokerManager.getStateFor(project, ureq.getIdentity(), projectBrokerModuleConfiguration));
    projectState = uifactory.addStaticTextElement("detailsform.state", stateValue + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", stateLayout);
    projectState.setLabel(null, null);
    String keyDetailsformMax = null;
    if (projectBrokerModuleConfiguration.isAcceptSelectionManually()) {
        keyDetailsformMax = "detailsform.max.candidates.label";
    } else {
        keyDetailsformMax = "detailsform.max.members.label";
    }
    selectionMaxMembers = uifactory.addCheckboxesHorizontal(keyDetailsformMax, formLayout, keys, values);
    maxMembers = uifactory.addIntegerElement("form.options.number.of.participants.per.topic_nbr", project.getMaxMembers(), formLayout);
    maxMembers.setMinValueCheck(0, null);
    maxMembers.setDisplaySize(3);
    if (project.getMaxMembers() == Project.MAX_MEMBERS_UNLIMITED) {
        maxMembers.setVisible(false);
        selectionMaxMembers.select(keys[0], false);
    } else {
        selectionMaxMembers.select(keys[0], true);
    }
    selectionMaxMembers.addActionListener(FormEvent.ONCLICK);
    String[] deselectValues = new String[] { translate("detailsform.allow.deselection.hint") };
    allowDeselection = uifactory.addCheckboxesHorizontal("detailsform.allow.deselection", formLayout, keys, deselectValues);
    allowDeselection.select(keys[0], projectGroupManager.isDeselectionAllowed(project));
    allowDeselection.addActionListener(FormEvent.ONCLICK);
    uifactory.addSpacerElement("spacer_1", formLayout, false);
    // customfields
    List<CustomField> customFields = projectBrokerModuleConfiguration.getCustomFields();
    int customFieldIndex = 0;
    for (Iterator<CustomField> iterator = customFields.iterator(); iterator.hasNext(); ) {
        CustomField customField = iterator.next();
        getLogger().debug("customField: " + customField.getName() + "=" + customField.getValue());
        StringTokenizer tok = new StringTokenizer(customField.getValue(), ProjectBrokerManager.CUSTOMFIELD_LIST_DELIMITER);
        if (customField.getValue() == null || customField.getValue().equals("") || !tok.hasMoreTokens()) {
            // no value define => Text-input
            // Add StaticTextElement as workaroung for non translated label
            // null > no label
            uifactory.addStaticTextElement("customField_label" + customFieldIndex, null, customField.getName(), formLayout);
            TextElement textElement = uifactory.addTextElement("customField_" + customFieldIndex, "", 150, project.getCustomFieldValue(customFieldIndex), formLayout);
            textElement.setDisplaySize(60);
            // textElement.setTranslator(null);
            // textElement.setLabel(customField.getName(), null);
            textElement.showLabel(false);
            customfieldElementList.add(textElement);
        } else {
            // values define => dropdown selection
            List<String> valueList = new ArrayList<String>();
            while (tok.hasMoreTokens()) {
                String value = tok.nextToken();
                valueList.add(value);
                getLogger().debug("valueList add: " + value);
            }
            String[] theValues = new String[valueList.size() + 1];
            String[] theKeys = new String[valueList.size() + 1];
            int arrayIndex = 0;
            theValues[arrayIndex] = translate(DROPDOWN_NO_SELECETION);
            theKeys[arrayIndex] = DROPDOWN_NO_SELECETION;
            arrayIndex++;
            for (Iterator<String> iterator2 = valueList.iterator(); iterator2.hasNext(); ) {
                String value = iterator2.next();
                theValues[arrayIndex] = value;
                theKeys[arrayIndex] = Integer.toString(arrayIndex);
                arrayIndex++;
            }
            // Add StaticTextElement as workaround for non translated label
            // null > no label
            uifactory.addStaticTextElement("customField_label" + customFieldIndex, null, customField.getName(), formLayout);
            SingleSelection selectionElement = uifactory.addDropdownSingleselect("customField_" + customFieldIndex, null, formLayout, theKeys, theValues, null);
            if (project.getCustomFieldValue(customFieldIndex) != null && !project.getCustomFieldValue(customFieldIndex).equals("")) {
                if (valueList.contains(project.getCustomFieldValue(customFieldIndex))) {
                    // '+1' because no-selection at the beginning
                    String key = Integer.toString(valueList.indexOf(project.getCustomFieldValue(customFieldIndex)) + 1);
                    selectionElement.select(key, true);
                } else {
                    this.showInfo("warn.customfield.key.does.not.exist", project.getCustomFieldValue(customFieldIndex));
                }
            }
            customfieldElementList.add(selectionElement);
        }
        uifactory.addSpacerElement("customField_spacer" + customFieldIndex, formLayout, false);
        customFieldIndex++;
    }
    // Events
    for (Project.EventType eventType : Project.EventType.values()) {
        if (projectBrokerModuleConfiguration.isProjectEventEnabled(eventType)) {
            ProjectEvent projectEvent = project.getProjectEvent(eventType);
            DateChooser dateChooserStart = uifactory.addDateChooser(eventType + "start", eventType.getI18nKey() + ".start.label", null, formLayout);
            dateChooserStart.setDateChooserTimeEnabled(true);
            dateChooserStart.setDisplaySize(CUSTOM_DATE_FORMAT.length());
            getLogger().info("Event=" + eventType + ", startDate=" + projectEvent.getStartDate());
            dateChooserStart.setDate(projectEvent.getStartDate());
            eventStartElementList.put(eventType, dateChooserStart);
            DateChooser dateChooserEnd = uifactory.addDateChooser(eventType + "end", eventType.getI18nKey() + ".end.label", null, formLayout);
            dateChooserEnd.setDateChooserTimeEnabled(true);
            dateChooserEnd.setDisplaySize(CUSTOM_DATE_FORMAT.length());
            getLogger().debug("Event=" + eventType + ", endDate=" + projectEvent.getEndDate());
            dateChooserEnd.setDate(projectEvent.getEndDate());
            eventEndElementList.put(eventType, dateChooserEnd);
            uifactory.addSpacerElement(eventType + "spacer", formLayout, false);
        }
    }
    attachmentFileName = uifactory.addFileElement(getWindowControl(), "detailsform.attachmentfilename.label", formLayout);
    attachmentFileName.setLabel("detailsform.attachmentfilename.label", null);
    if (project.getAttachmentFileName() != null && !project.getAttachmentFileName().equals("")) {
        attachmentFileName.setInitialFile(new File(project.getAttachmentFileName()));
        removeAttachmentLink = uifactory.addFormLink("detailsform.remove.attachment", formLayout, Link.BUTTON_XSMALL);
    }
    attachmentFileName.addActionListener(FormEvent.ONCHANGE);
    mailNotification = uifactory.addCheckboxesHorizontal("detailsform.mail.notification.label", formLayout, keys, values);
    mailNotification.select(keys[0], project.isMailNotificationEnabled());
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    uifactory.addFormSubmitButton("save", buttonGroupLayout);
    if (this.enableCancel) {
        // TODO: Frage an PB: Warum flc hier noetig ???
        uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
    }
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Project(org.olat.course.nodes.projectbroker.datamodel.Project) StringTokenizer(java.util.StringTokenizer) 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) CustomField(org.olat.course.nodes.projectbroker.datamodel.CustomField) DateChooser(org.olat.core.gui.components.form.flexible.elements.DateChooser) Identity(org.olat.core.id.Identity) File(java.io.File) ProjectEvent(org.olat.course.nodes.projectbroker.datamodel.ProjectEvent)

Example 10 with StaticTextElement

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

the class InvitationEditRightsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_pf_invitation_form");
    FormLayoutContainer inviteeCont = FormLayoutContainer.createDefaultFormLayout("inviteeInfos", getTranslator());
    inviteeCont.setRootForm(mainForm);
    formLayout.add("inviteeInfos", inviteeCont);
    firstNameEl = uifactory.addTextElement("firstName", "firstName", 64, invitation.getFirstName(), inviteeCont);
    firstNameEl.setElementCssClass("o_sel_pf_invitation_firstname");
    firstNameEl.setMandatory(true);
    lastNameEl = uifactory.addTextElement("lastName", "lastName", 64, invitation.getLastName(), inviteeCont);
    lastNameEl.setElementCssClass("o_sel_pf_invitation_lastname");
    lastNameEl.setMandatory(true);
    String invitationEmail = email != null ? email : invitation.getMail();
    mailEl = uifactory.addTextElement("mail", "mail", 128, invitationEmail, inviteeCont);
    mailEl.setElementCssClass("o_sel_pf_invitation_mail");
    mailEl.setMandatory(true);
    mailEl.setNotEmptyCheck("map.share.empty.warn");
    mailEl.setEnabled(invitation.getKey() == null);
    if (StringHelper.containsNonWhitespace(invitation.getMail()) && MailHelper.isValidEmailAddress(invitation.getMail())) {
        SecurityGroup allUsers = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
        List<Identity> shareWithIdentities = userManager.findIdentitiesByEmail(Collections.singletonList(invitation.getMail()));
        if (isAtLeastOneInSecurityGroup(shareWithIdentities, allUsers)) {
            mailEl.setErrorKey("map.share.with.mail.error.olatUser", new String[] { invitation.getMail() });
        }
    }
    String link = getInvitationLink();
    StaticTextElement linkEl = uifactory.addStaticTextElement("invitation.link", link, inviteeCont);
    linkEl.setElementCssClass("o_sel_pf_invitation_url");
    linkEl.setLabel("invitation.link", null);
    if (mailTemplate != null) {
        subjectEl = uifactory.addTextElement("subjectElem", "mail.subject", 128, mailTemplate.getSubjectTemplate(), inviteeCont);
        subjectEl.setDisplaySize(60);
        subjectEl.setMandatory(true);
        bodyEl = uifactory.addTextAreaElement("bodyElem", "mail.body", -1, 15, 60, true, mailTemplate.getBodyTemplate(), inviteeCont);
        bodyEl.setHelpUrlForManualPage("E-Mail");
        bodyEl.setMandatory(true);
    }
    // binder
    MultipleSelectionElement accessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
    accessEl.addActionListener(FormEvent.ONCHANGE);
    binderRow = new BinderAccessRightsRow(accessEl, binder);
    // sections
    List<Section> sections = portfolioService.getSections(binder);
    Map<Long, SectionAccessRightsRow> sectionMap = new HashMap<>();
    for (Section section : sections) {
        MultipleSelectionElement sectionAccessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        sectionAccessEl.addActionListener(FormEvent.ONCHANGE);
        SectionAccessRightsRow sectionRow = new SectionAccessRightsRow(sectionAccessEl, section, binderRow);
        binderRow.getSections().add(sectionRow);
        sectionMap.put(section.getKey(), sectionRow);
    }
    // pages
    List<Page> pages = portfolioService.getPages(binder, null);
    for (Page page : pages) {
        Section section = page.getSection();
        SectionAccessRightsRow sectionRow = sectionMap.get(section.getKey());
        MultipleSelectionElement pageAccessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        pageAccessEl.addActionListener(FormEvent.ONCHANGE);
        PortfolioElementAccessRightsRow pageRow = new PortfolioElementAccessRightsRow(pageAccessEl, page, sectionRow);
        sectionRow.getPages().add(pageRow);
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("binderRow", binderRow);
    }
    selectAll = uifactory.addFormLink("form.checkall", "form.checkall", null, formLayout, Link.LINK);
    selectAll.setIconLeftCSS("o_icon o_icon-sm o_icon_check_on");
    deselectAll = uifactory.addFormLink("form.uncheckall", "form.uncheckall", null, formLayout, Link.LINK);
    deselectAll.setIconLeftCSS("o_icon o_icon-sm o_icon_check_off");
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    buttonsCont.setRootForm(mainForm);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
    if (invitation.getKey() != null) {
        removeLink = uifactory.addFormLink("remove", buttonsCont, Link.BUTTON);
    }
    uifactory.addFormSubmitButton("save", buttonsCont);
}
Also used : HashMap(java.util.HashMap) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Page(org.olat.modules.portfolio.Page) SecurityGroup(org.olat.basesecurity.SecurityGroup) Section(org.olat.modules.portfolio.Section) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) Identity(org.olat.core.id.Identity)

Aggregations

StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)30 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)20 ArrayList (java.util.ArrayList)8 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)8 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)8 Identity (org.olat.core.id.Identity)8 SecurityGroup (org.olat.basesecurity.SecurityGroup)6 Date (java.util.Date)4 DateChooser (org.olat.core.gui.components.form.flexible.elements.DateChooser)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)4 FormSubmit (org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit)4 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)4 ContextEntry (org.olat.core.id.context.ContextEntry)4 TaskDueDate (org.olat.course.nodes.gta.TaskDueDate)4 DueDate (org.olat.course.nodes.gta.model.DueDate)4 ModuleConfiguration (org.olat.modules.ModuleConfiguration)4 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)4 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)4 File (java.io.File)2