Search in sources :

Example 86 with SingleSelection

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

the class AttributeEasyRowAdderController method getAttributeConditions.

/**
 * Method to get a list of extended conditions represented in this form
 *
 * @return
 */
public List<ExtendedCondition> getAttributeConditions() {
    final List<ExtendedCondition> le = new ArrayList<ExtendedCondition>();
    for (final Iterator<String> iterator = columnAttribute.iterator(); iterator.hasNext(); ) {
        final String aname = iterator.next();
        final String row = aname.replace(PRE_ATTRIBUTE, "");
        final SingleSelection attribute = (SingleSelection) flc.getFormComponent(PRE_ATTRIBUTE + row);
        final String condName = attribute.getSelectedKey();
        final SingleSelection operator = (SingleSelection) flc.getFormComponent(PRE_OPERATOR + row);
        final String condOperator = operator.getSelectedKey();
        String condValue = "";
        final SingleSelection valuessi = (SingleSelection) flc.getFormComponent(PRE_VALUE_SELECTION + row);
        if (valuessi.isVisible()) {
            if (valuessi.isOneSelected()) {
                condValue = valuessi.getSelectedKey();
            } else {
                // user did not actively select one, maybe because the first one was already the one he wanted. Use this one
                condValue = valuessi.getKey(0);
            }
        } else {
            final TextElement valuetei = (TextElement) flc.getFormComponent(PRE_VALUE_TEXT + row);
            condValue = valuetei.getValue();
        }
        le.add(new ExtendedCondition(condName, condOperator, condValue));
    }
    return le;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList)

Example 87 with SingleSelection

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

the class LTIConfigForm method createNameValuePair.

private void createNameValuePair(String key, String value, int index) {
    String guid = Long.toString(CodeHelper.getRAMUniqueID());
    NameValuePair pair = new NameValuePair(guid);
    TextElement nameEl = uifactory.addTextElement("name_" + guid, null, 15, key, customParamLayout);
    nameEl.setDisplaySize(16);
    pair.setNameEl(nameEl);
    SingleSelection typeEl = uifactory.addDropdownSingleselect("typ_" + guid, customParamLayout, customTypeKeys, customTypeValues, null);
    typeEl.setUserObject(pair);
    typeEl.addActionListener(FormEvent.ONCHANGE);
    pair.setCustomType(typeEl);
    boolean userprops = value != null && value.startsWith(LTIManager.USER_PROPS_PREFIX);
    if (userprops) {
        typeEl.select("userprops", true);
        value = value.substring(LTIManager.USER_PROPS_PREFIX.length(), value.length());
    } else {
        typeEl.select("free", true);
    }
    SingleSelection userPropsChoice = uifactory.addDropdownSingleselect("userprops_" + guid, customParamLayout, userPropKeys, userPropValues, null);
    userPropsChoice.setUserObject(pair);
    userPropsChoice.setVisible(userprops);
    if (userprops) {
        for (String userPropKey : userPropKeys) {
            if (userPropKey.equals(value)) {
                userPropsChoice.select(userPropKey, true);
            }
        }
    }
    pair.setUserPropsChoice(userPropsChoice);
    TextElement valEl = uifactory.addTextElement("val_" + guid, null, 15, value, customParamLayout);
    valEl.setDisplaySize(16);
    valEl.setVisible(!userprops);
    pair.setValueEl(valEl);
    FormLink addButton = uifactory.addFormLink("add_" + guid, "add", null, customParamLayout, Link.BUTTON_XSMALL);
    addButton.setUserObject(pair);
    pair.setAddButton(addButton);
    FormLink removeButton = uifactory.addFormLink("rm_" + guid, "remove", null, customParamLayout, Link.BUTTON_XSMALL);
    removeButton.setUserObject(pair);
    pair.setRemoveButton(removeButton);
    if (index < 0 || index >= nameValuePairs.size()) {
        nameValuePairs.add(pair);
    } else {
        nameValuePairs.add(index, pair);
    }
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 88 with SingleSelection

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

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)

Aggregations

SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)88 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)34 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)26 FormItem (org.olat.core.gui.components.form.flexible.FormItem)18 ArrayList (java.util.ArrayList)14 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)12 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)12 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)12 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)10 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)8 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)8 File (java.io.File)6 Map (java.util.Map)6 FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 SliderWrapper (org.olat.modules.forms.ui.model.SliderWrapper)6 UserManager (org.olat.user.UserManager)6 HashMap (java.util.HashMap)4 List (java.util.List)4 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)4