Search in sources :

Example 11 with MultipleSelectionElement

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

the class CustomfieldsFormController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    // loop over all Element to store values
    for (int i = 0; i < customFields.size(); i++) {
        TextElement nameTextElement = customFieldNameElementList.get(i);
        if (!customFields.get(i).getName().equals(nameTextElement.getValue())) {
            customFields.get(i).setName(nameTextElement.getValue());
        }
        TextElement valueTextElement = customFieldValueElementList.get(i);
        if (!customFields.get(i).getValue().equals(valueTextElement.getValue())) {
            customFields.get(i).setValue(valueTextElement.getValue());
        }
        MultipleSelectionElement tableViewElement = customFieldTableFlagElementList.get(i);
        if (customFields.get(i).isTableViewEnabled() != tableViewElement.isSelected(0)) {
            customFields.get(i).setTableViewEnabled(tableViewElement.isSelected(0));
        }
    }
    config.setCustomFields(customFields);
    fireEvent(ureq, Event.DONE_EVENT);
    fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 12 with MultipleSelectionElement

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

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)

Example 13 with MultipleSelectionElement

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

the class ViteroAdminBookingRawInfosController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    uifactory.addStaticTextElement("booking.id", Integer.toString(booking.getBookingId()), formLayout);
    uifactory.addStaticTextElement("booking.begin", formatter.formatDateAndTime(booking.getStart()), formLayout);
    uifactory.addStaticTextElement("booking.end", formatter.formatDateAndTime(booking.getEnd()), formLayout);
    uifactory.addStaticTextElement("booking.beginBuffer", Integer.toString(booking.getStartBuffer()), formLayout);
    uifactory.addStaticTextElement("booking.endBuffer", Integer.toString(booking.getEndBuffer()), formLayout);
    uifactory.addStaticTextElement("booking.roomSize", Integer.toString(booking.getRoomSize()), formLayout);
    uifactory.addStaticTextElement("group.numOfParticipants", Integer.toString(group.getNumOfParticipants()), formLayout);
    uifactory.addStaticTextElement("group.id", Integer.toString(group.getGroupId()), formLayout);
    String name = group.getName();
    int sepIndex = name.indexOf("_OLAT_");
    if (sepIndex > 0) {
        name = name.substring(0, sepIndex);
    }
    uifactory.addStaticTextElement("group.name", name, formLayout);
    MultipleSelectionElement autoSignIn = uifactory.addCheckboxesHorizontal("booking.autoSignIn", formLayout, autoSignInKeys, autoSignInValues);
    if (booking.isAutoSignIn()) {
        autoSignIn.select(autoSignInKeys[0], true);
    }
    autoSignIn.setEnabled(false);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 14 with MultipleSelectionElement

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

the class MultiSPController method initTreeRec.

private MultipleSelectionElement initTreeRec(int level, VFSItem item, FormLayoutContainer layoutcont) {
    SelectNodeObject node = new SelectNodeObject(item, UUID.randomUUID().toString(), level);
    String[] singleKey = new String[] { node.getId() };
    String[] singleValue = new String[] { node.getName() };
    String[] iconCSS = new String[] { "o_icon o_icon-fw " + node.getIconCssClass() };
    MultipleSelectionElement nodeSelection = uifactory.addCheckboxesVertical("print.node.list." + nodeSelections.size(), layoutcont, singleKey, singleValue, iconCSS, 1);
    nodeSelection.setLabel("multi.sps.file", null);
    nodeSelection.setUserObject(node);
    nodeSelection.addActionListener(FormEvent.ONCLICK);
    nodeSelections.add(nodeSelection);
    identToSelectionMap.put(node.getId(), nodeSelection);
    layoutcont.add(nodeSelection.getComponent().getComponentName(), nodeSelection);
    if (item instanceof VFSContainer) {
        VFSContainer container = (VFSContainer) item;
        for (VFSItem subItem : container.getItems(new MultiSPVFSItemFilter())) {
            MultipleSelectionElement sel = initTreeRec(level + 1, subItem, layoutcont);
            node.getChildren().add(sel);
        }
    }
    return nodeSelection;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 15 with MultipleSelectionElement

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

the class MultiSPController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (nodeSelections.contains(source)) {
        MultipleSelectionElement nodeSelection = (MultipleSelectionElement) source;
        if (nodeSelection.isMultiselect()) {
            selectRec(nodeSelection, nodeSelection.isSelected(0));
        }
    } else if (source == selectAll) {
        for (MultipleSelectionElement nodeSelection : nodeSelections) {
            if (nodeSelection.isMultiselect() && !nodeSelection.isSelected(0)) {
                SelectNodeObject treeNode = (SelectNodeObject) nodeSelection.getUserObject();
                String id = treeNode.getId();
                nodeSelection.select(id, true);
            }
        }
    } else if (source == deselectAll) {
        for (MultipleSelectionElement nodeSelection : nodeSelections) {
            if (nodeSelection.isMultiselect() && nodeSelection.isSelected(0)) {
                SelectNodeObject treeNode = (SelectNodeObject) nodeSelection.getUserObject();
                String id = treeNode.getId();
                nodeSelection.select(id, false);
            }
        }
    } else if (source == asChild) {
        position = -1;
        ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
        create(rootSelection, course, selectedNode.getCourseNode());
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (source == sameLevel) {
        ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
        CourseEditorTreeNode parentNode = (CourseEditorTreeNode) selectedNode.getParent();
        position = 0;
        for (position = parentNode.getChildCount(); position-- > 0; ) {
            if (selectedNode.getIdent().equals(parentNode.getChildAt(position).getIdent())) {
                position++;
                break;
            }
        }
        create(rootSelection, course, parentNode.getCourseNode());
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else {
        super.formInnerEvent(ureq, source, event);
    }
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ICourse(org.olat.course.ICourse)

Aggregations

MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)136 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)22 ArrayList (java.util.ArrayList)20 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)16 MultipleSelectionElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.MultipleSelectionElementImpl)16 HashMap (java.util.HashMap)12 HashSet (java.util.HashSet)12 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)10 FormItem (org.olat.core.gui.components.form.flexible.FormItem)8 Identity (org.olat.core.id.Identity)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)8 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)6 ICourse (org.olat.course.ICourse)6 Checkbox (org.olat.course.nodes.cl.model.Checkbox)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)5 VFSItem (org.olat.core.util.vfs.VFSItem)5 Section (org.olat.modules.portfolio.Section)5 File (java.io.File)4 UserShortDescription (org.olat.admin.user.UserShortDescription)4