Search in sources :

Example 11 with FormItem

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

the class ShibbolethRegistrationUserPropertiesFrom method updateShibboletAttribute.

private void updateShibboletAttribute(UserPropertyHandler userPropertyHandler) {
    String propertyName = userPropertyHandler.getName();
    FormItem propertyItem = this.flc.getFormComponent(propertyName);
    String propertyValue = userPropertyHandler.getStringValue(propertyItem);
    shibbolethAttributes.setValueForUserPropertyName(propertyName, propertyValue);
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem)

Example 12 with FormItem

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

the class ShibbolethRegistrationUserPropertiesFrom method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // Add all available user fields to this form
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler != null) {
            FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, USERPROPERTIES_FORM_IDENTIFIER, false, formLayout);
            propFormItems.put(userPropertyHandler.getName(), fi);
            if (fi instanceof TextElement) {
                String value = shibbolethAttributes.getValueForUserPropertyName(userPropertyHandler.getName());
                if (StringHelper.containsNonWhitespace(value)) {
                    TextElement formElement = (TextElement) fi;
                    formElement.setValue(value);
                    formElement.setEnabled(false);
                }
            }
        }
    }
    FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
    formLayout.add(buttonLayout);
    uifactory.addFormSubmitButton("save", buttonLayout);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 13 with FormItem

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

the class ProjectEditDetailsFormController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    boolean projectChanged = false;
    if (!project.getTitle().equals(projectTitle.getValue())) {
        // title has been changed => change project-group name too
        String newProjectGroupName = translate("project.member.groupname", projectTitle.getValue());
        String newProjectGroupDescription = translate("project.member.groupdescription", projectTitle.getValue());
        OLATResource courseResource = courseEnv.getCourseGroupManager().getCourseResource();
        projectGroupManager.changeProjectGroupName(getIdentity(), project.getProjectGroup(), newProjectGroupName, newProjectGroupDescription, courseResource);
        projectGroupManager.sendGroupChangeEvent(project, courseEnv.getCourseResourceableId(), ureq.getIdentity());
        projectChanged = true;
    }
    if (!project.getTitle().equals(projectTitle.getValue())) {
        project.setTitle(projectTitle.getValue());
        projectChanged = true;
    }
    if (!project.getDescription().equals(projectDescription.getValue())) {
        project.setDescription(projectDescription.getValue());
        projectChanged = true;
    }
    if (project.getMaxMembers() != maxMembers.getIntValue()) {
        project.setMaxMembers(maxMembers.getIntValue());
        projectGroupManager.setProjectGroupMaxMembers(getIdentity(), project.getProjectGroup(), maxMembers.getIntValue());
        projectChanged = true;
    }
    if (StringHelper.containsNonWhitespace(attachmentFileName.getUploadFileName())) {
        // First call uploadFiles than setAttachedFileName because uploadFiles needs old attachment name
        uploadFiles(attachmentFileName);
        project.setAttachedFileName(attachmentFileName.getUploadFileName());
        projectChanged = true;
    } else if (StringHelper.containsNonWhitespace(project.getAttachmentFileName()) && attachmentFileName.getInitialFile() == null) {
        // Attachment file has been removed
        project.setAttachedFileName("");
        projectChanged = true;
    }
    // store customfields
    int index = 0;
    for (Iterator<FormItem> iterator = customfieldElementList.iterator(); iterator.hasNext(); ) {
        FormItem element = iterator.next();
        String value = "";
        if (element instanceof TextElement) {
            TextElement textElement = (TextElement) element;
            value = textElement.getValue();
        } else if (element instanceof SingleSelection) {
            SingleSelection selectionElement = (SingleSelection) element;
            if (!selectionElement.getSelectedKey().equals(DROPDOWN_NO_SELECETION)) {
                value = selectionElement.getValue(selectionElement.getSelected());
            } else {
                value = "";
            }
        }
        getLogger().debug("customfield index=" + index + " value=" + value + " project.getCustomFieldValue(index)=" + project.getCustomFieldValue(index));
        if (!project.getCustomFieldValue(index).equals(value)) {
            project.setCustomFieldValue(index, value);
            projectChanged = true;
        }
        index++;
    }
    // store events
    for (Project.EventType eventType : eventStartElementList.keySet()) {
        Date startDate = eventStartElementList.get(eventType).getDate();
        Date endDate = eventEndElementList.get(eventType).getDate();
        // First handle startdate
        if (hasBeenChanged(project.getProjectEvent(eventType).getStartDate(), startDate) || hasBeenChanged(project.getProjectEvent(eventType).getEndDate(), endDate)) {
            project.setProjectEvent(new ProjectEvent(eventType, startDate, endDate));
            projectChanged = true;
        }
    }
    if (mailNotification.isSelected(0) != project.isMailNotificationEnabled()) {
        project.setMailNotificationEnabled(mailNotification.isSelected(0));
        projectChanged = true;
    }
    if (projectChanged) {
        if (projectBrokerManager.existsProject(project.getKey())) {
            projectBrokerManager.updateProject(project);
            projectBrokerMailer.sendProjectChangedEmailToParticipants(ureq.getIdentity(), project, this.getTranslator());
        } else {
            showInfo("info.project.nolonger.exist", project.getTitle());
        }
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) 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) FormItem(org.olat.core.gui.components.form.flexible.FormItem) OLATResource(org.olat.resource.OLATResource) Date(java.util.Date) ProjectEvent(org.olat.course.nodes.projectbroker.datamodel.ProjectEvent)

Example 14 with FormItem

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

the class MessageEditController method createOrUpdateAttachmentListLayout.

// adds or updates the list of already existing attachments with a delete
// button for each
private void createOrUpdateAttachmentListLayout(FormItemContainer formLayout) {
    FormItem attachLayout = formLayout.getFormComponent("attachLayout");
    List<VFSItem> attachments = new ArrayList<VFSItem>();
    // add already existing attachments:
    if (message.getKey() != null) {
        VFSContainer msgContainer = fm.getMessageContainer(message.getForum().getKey(), message.getKey());
        attachments.addAll(msgContainer.getItems(exclFilter));
    }
    // add files from TempFolder
    attachments.addAll(getTempFolderFileList());
    Collections.sort(attachments, new Comparator<VFSItem>() {

        final Collator c = Collator.getInstance(getLocale());

        public int compare(final VFSItem o1, final VFSItem o2) {
            return c.compare((o1).getName(), (o2).getName());
        }
    });
    FormLayoutContainer tmpLayout;
    if (attachLayout == null) {
        String editPage = Util.getPackageVelocityRoot(this.getClass()) + "/attachments-editview.html";
        tmpLayout = FormLayoutContainer.createCustomFormLayout("attachLayout", getTranslator(), editPage);
        formLayout.add(tmpLayout);
    } else {
        tmpLayout = (FormLayoutContainer) attachLayout;
    }
    tmpLayout.contextPut("attachments", attachments);
    // add delete links for each attachment if user is allowed to see them
    int attNr = 1;
    for (VFSItem tmpFile : attachments) {
        FormLink tmpLink = uifactory.addFormLink(CMD_DELETE_ATTACHMENT + attNr, tmpLayout, Link.BUTTON_XSMALL);
        if (!(foCallback.mayEditMessageAsModerator() || ((userIsMsgCreator) && (msgHasChildren == false)))) {
            tmpLink.setEnabled(false);
            tmpLink.setVisible(false);
        }
        tmpLink.setUserObject(tmpFile);
        tmpLink.setI18nKey("attachments.remove.string");
        attNr++;
    }
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Collator(java.text.Collator)

Example 15 with FormItem

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

the class ColorLA method getFormItem.

/**
 * @see org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute#getFormItem(java.lang.String, org.olat.core.gui.components.form.flexible.FormItemContainer)
 * get a dropdown and an input field wrapped in a FormLayoutContainer
 */
@Override
public FormItem getFormItem(String compName, FormItemContainer formLayout) {
    FormUIFactory uifact = FormUIFactory.getInstance();
    FormLayoutContainer colorFLC = FormLayoutContainer.createVerticalFormLayout(compName, formLayout.getTranslator());
    formLayout.add(compName, colorFLC);
    FormItem dropDown = super.getFormItem(compName + "sel", formLayout);
    dropDown.addActionListener(FormEvent.ONCHANGE);
    colorFLC.add(dropDown);
    String inputValue = "";
    if (getAttributeValue() != null && !((SingleSelection) dropDown).isOneSelected()) {
        inputValue = getAttributeValue();
    }
    TextElement inputEl = uifact.addTextElement(compName + "value", null, 7, inputValue, colorFLC);
    inputEl.setDisplaySize(7);
    colorFLC.setUserObject(new ColorSpecialHandler(colorFLC));
    return colorFLC;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormUIFactory(org.olat.core.gui.components.form.flexible.FormUIFactory)

Aggregations

FormItem (org.olat.core.gui.components.form.flexible.FormItem)142 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)62 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)34 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)30 ArrayList (java.util.ArrayList)24 HashMap (java.util.HashMap)22 Identity (org.olat.core.id.Identity)20 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)16 User (org.olat.core.id.User)16 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)14 UserManager (org.olat.user.UserManager)12 EmailProperty (org.olat.user.propertyhandlers.EmailProperty)12 HashSet (java.util.HashSet)10 Translator (org.olat.core.gui.translator.Translator)10 File (java.io.File)8 Map (java.util.Map)8 Component (org.olat.core.gui.components.Component)8 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)8 Date (java.util.Date)6 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)6