Search in sources :

Example 16 with MultipleSelectionElement

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

the class MultiSPController method create.

private void create(MultipleSelectionElement selection, ICourse course, CourseNode parentNode) {
    SelectNodeObject node = (SelectNodeObject) selection.getUserObject();
    if (selection.isMultiselect() && selection.isSelected(0)) {
        VFSItem item = node.getItem();
        CourseNode newNode = null;
        if (item instanceof VFSLeaf) {
            // create node
            newNode = createCourseNode(item, "sp");
            ModuleConfiguration moduleConfig = newNode.getModuleConfiguration();
            String path = getRelativePath(item);
            moduleConfig.set(SPEditController.CONFIG_KEY_FILE, path);
            moduleConfig.setBooleanEntry(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS, true);
        } else if (item instanceof VFSContainer) {
            // add structure
            newNode = createCourseNode(item, "st");
        }
        int pos = -1;
        if (position >= 0 && selectedNode.getCourseNode().getIdent().equals(parentNode.getIdent())) {
            pos = position++;
        }
        if (pos < 0 || pos >= parentNode.getChildCount()) {
            course.getEditorTreeModel().addCourseNode(newNode, parentNode);
        } else {
            course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode, pos);
        }
        if (item instanceof VFSContainer) {
            parentNode = newNode;
        }
    }
    // recurse
    for (MultipleSelectionElement childElement : node.getChildren()) {
        create(childElement, course, parentNode);
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ModuleConfiguration(org.olat.modules.ModuleConfiguration) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) CourseNode(org.olat.course.nodes.CourseNode)

Example 17 with MultipleSelectionElement

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

the class MetadataBulkChangeController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (checkboxSwitch.contains(source)) {
        MultipleSelectionElement checkbox = (MultipleSelectionElement) source;
        FormItem item = (FormItem) checkbox.getUserObject();
        item.setVisible(checkbox.isAtLeastSelected(1));
        checkboxContainer.get(checkbox).setDirty(true);
    } else if (licenseEl == source) {
        updateLicenseVisibility();
        licenseWrapperCont.setDirty(true);
    } else {
        super.formInnerEvent(ureq, source, event);
    }
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) FormItem(org.olat.core.gui.components.form.flexible.FormItem)

Example 18 with MultipleSelectionElement

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

the class EPArtefactAttributeSettingController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormDescription("display.option.intro");
    String[] keys = new String[] { "onoff" };
    String[] values = new String[] { translate("display.option.enabled") };
    Map<String, Boolean> allArtAttribs = ePFMgr.getArtefactAttributeConfig(null);
    for (Iterator<Entry<String, Boolean>> iterator = allArtAttribs.entrySet().iterator(); iterator.hasNext(); ) {
        Entry<String, Boolean> entry = iterator.next();
        String attKey = entry.getKey();
        Boolean attVal = artAttribConfig.get(attKey);
        MultipleSelectionElement chkBox = uifactory.addCheckboxesHorizontal(attKey, formLayout, keys, values);
        chkBox.addActionListener(FormEvent.ONCHANGE);
        // either use users settings or the defaults
        if (attVal == null)
            attVal = entry.getValue();
        chkBox.select(keys[0], attVal);
    }
    uifactory.addFormSubmitButton("display.option.submit", formLayout);
}
Also used : Entry(java.util.Map.Entry) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 19 with MultipleSelectionElement

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

the class GenericSelectionPropertyHandler method isValid.

@Override
public boolean isValid(User user, FormItem formItem, Map<String, String> formContext) {
    if (formItem.isMandatory()) {
        if (isMultiselect) {
            MultipleSelectionElement msel = (MultipleSelectionElement) formItem;
            msel.setErrorKey("form.legende.mandatory", null);
            return msel.isAtLeastSelected(1);
        } else {
            SingleSelection ssel = (SingleSelection) formItem;
            if (ssel.getSelectedKey().equals(NO_SEL_KEY)) {
                ssel.setErrorKey("form.legende.mandatory", null);
                return false;
            }
        }
    }
    return true;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection)

Example 20 with MultipleSelectionElement

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

the class UserInterestsController 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) {
    setFormDescription("userinterests.description");
    // Draw the checkboxes
    for (int i = 0; i < this.availableUserInterests.size(); i++) {
        UserInterestsCategory category = this.availableUserInterests.get(i);
        Vector<String> keys = new Vector<String>();
        for (UserInterestsCategory subcategory : category.getSubcategories()) {
            keys.add(UserInterestsPropertyHandler.SUBCATEGORY_I18N_PREFIX + subcategory.getId());
        }
        String[] values = new String[keys.size()];
        for (int j = 0; j < values.length; j++) {
            values[j] = translate(keys.get(j));
        }
        MultipleSelectionElement interestCheckboxes = uifactory.addCheckboxesVertical("interest_" + category.getId(), formLayout, keys.toArray(new String[0]), values, null, 2);
        this.checkboxGroups.add(interestCheckboxes);
        interestCheckboxes.setLabel(UserInterestsPropertyHandler.CATEGORY_I18N_PREFIX + category.getId(), null);
        interestCheckboxes.addActionListener(FormEvent.ONCHANGE);
        if (i != this.availableUserInterests.size() - 1) {
            uifactory.addSpacerElement("spacer_" + category.getId(), formLayout, false);
        }
    }
    // Check boxes for the given interests
    this.setSelectedInterests(this.selectedInterestsIDs);
    // Disable the checkboxes if already the maximum number is selected.
    if (getSelectionCount() >= maxNumOfInterests) {
        Set<String> currentSelection = getCurrentSelection();
        for (MultipleSelectionElement checkboxGroup : this.checkboxGroups) {
            MultipleSelectionElementImpl multipleSelectionElementImpl = (MultipleSelectionElementImpl) checkboxGroup;
            Set<String> allUncheckedCheckboxes = new HashSet<String>(multipleSelectionElementImpl.getKeys());
            allUncheckedCheckboxes.removeAll(currentSelection);
            multipleSelectionElementImpl.setEnabled(allUncheckedCheckboxes, false);
        }
        showWarning("form.warning.maxNumber");
    }
    // Add submit and cancel buttons
    final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
    formLayout.add(buttonLayout);
    uifactory.addFormSubmitButton("finish", buttonLayout);
    uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) MultipleSelectionElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.MultipleSelectionElementImpl) Vector(java.util.Vector) HashSet(java.util.HashSet)

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