Search in sources :

Example 71 with SingleSelection

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

the class AbstractPageListController method forgeSectionRow.

protected PortfolioElementRow forgeSectionRow(Section section, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap) {
    PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, config.isAssessable(), (assignments != null && assignments.size() > 0));
    String openLinkId = "open_" + (++counter);
    FormLink openLink = uifactory.addFormLink(openLinkId, "open.full", "open.full.page", null, flc, Link.BUTTON_SMALL);
    openLink.setIconRightCSS("o_icon o_icon_start");
    openLink.setPrimary(true);
    row.setOpenFormLink(openLink);
    openLink.setUserObject(row);
    addCategoriesToRow(row, categorizedElementMap);
    if (assignments != null && secCallback.canViewPendingAssignments(section) && secCallback.canInstantiateAssignment()) {
        List<Assignment> startableAssignments = assignments.stream().filter(ass -> ass.getAssignmentStatus() == AssignmentStatus.notStarted).filter(ass -> ass.getPage() == null).collect(Collectors.toList());
        if (!startableAssignments.isEmpty()) {
            String[] keys = new String[startableAssignments.size() + 1];
            String[] values = new String[startableAssignments.size() + 1];
            keys[0] = "start.assignment.hint";
            values[0] = translate("start.assignment.hint");
            int count = 1;
            for (Assignment assignment : startableAssignments) {
                keys[count] = Long.toString(assignment.getKey());
                values[count] = assignment.getTitle();
                count++;
            }
            SingleSelection startEl = uifactory.addDropdownSingleselect("assignments_" + (++counter), "", flc, keys, values, null);
            startEl.setDomReplacementWrapperRequired(false);
            startEl.addActionListener(FormEvent.ONCHANGE);
            row.setStartSelection(startEl);
        }
    }
    return row;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Assignment(org.olat.modules.portfolio.Assignment) FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) PortfolioV2Module(org.olat.modules.portfolio.PortfolioV2Module) TimelineElement(org.olat.modules.portfolio.ui.component.TimelineElement) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) ThreadLocalUserActivityLogger(org.olat.core.logging.activity.ThreadLocalUserActivityLogger) PageRemovedEvent(org.olat.modules.portfolio.ui.event.PageRemovedEvent) MediaResource(org.olat.core.gui.media.MediaResource) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) OLATResourceable(org.olat.core.id.OLATResourceable) StatusCellRenderer(org.olat.modules.portfolio.ui.renderer.StatusCellRenderer) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration) Category(org.olat.modules.portfolio.Category) OresHelper(org.olat.core.util.resource.OresHelper) Assignment(org.olat.modules.portfolio.Assignment) Map(java.util.Map) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) SectionStatus(org.olat.modules.portfolio.SectionStatus) AssignmentStatus(org.olat.modules.portfolio.AssignmentStatus) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) Page(org.olat.modules.portfolio.Page) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) PortfolioLoggingAction(org.olat.modules.portfolio.PortfolioLoggingAction) WindowControl(org.olat.core.gui.control.WindowControl) FlexiTableRendererType(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableRendererType) Set(java.util.Set) AssignmentType(org.olat.modules.portfolio.AssignmentType) Component(org.olat.core.gui.components.Component) Collectors(java.util.stream.Collectors) Mapper(org.olat.core.dispatcher.mapper.Mapper) DefaultFlexiTableCssDelegate(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiTableCssDelegate) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) PortfolioElementCellRenderer(org.olat.modules.portfolio.ui.renderer.PortfolioElementCellRenderer) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) UserCommentsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsController) TooledController(org.olat.core.gui.components.stack.TooledController) LoggingResourceable(org.olat.util.logging.activity.LoggingResourceable) ImageComponent(org.olat.core.gui.components.image.ImageComponent) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) FileMediaResource(org.olat.core.gui.media.FileMediaResource) Section(org.olat.modules.portfolio.Section) CategoriesCellRenderer(org.olat.modules.portfolio.ui.component.CategoriesCellRenderer) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) PageDeletedEvent(org.olat.modules.portfolio.ui.event.PageDeletedEvent) ReadOnlyCommentsSecurityCallback(org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback) HttpServletRequest(javax.servlet.http.HttpServletRequest) Calendar(java.util.Calendar) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) ContextEntry(org.olat.core.id.context.ContextEntry) StringHelper(org.olat.core.util.StringHelper) StateEntry(org.olat.core.id.context.StateEntry) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) PageCols(org.olat.modules.portfolio.ui.PageListDataModel.PageCols) PortfolioService(org.olat.modules.portfolio.PortfolioService) Link(org.olat.core.gui.components.link.Link) FlexiTableComponentDelegate(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableComponentDelegate) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent) Controller(org.olat.core.gui.control.Controller) File(java.io.File) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) PageImageAlign(org.olat.modules.portfolio.PageImageAlign) DialogBoxUIFactory(org.olat.core.gui.control.generic.modal.DialogBoxUIFactory) UserRequest(org.olat.core.gui.UserRequest) PageStatus(org.olat.modules.portfolio.PageStatus) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 72 with SingleSelection

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

the class ExtendedSearchController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == searchButton) {
        doSearch(ureq);
    } else if (source instanceof SingleSelection) {
        SingleSelection attrEl = (SingleSelection) source;
        if (attrEl.isOneSelected()) {
            Object uObject = attrEl.getUserObject();
            if (uObject instanceof ConditionalQuery) {
                ConditionalQuery query = (ConditionalQuery) uObject;
                query.selectAttributeType(attrEl.getSelectedKey(), null);
            }
        }
    } else if (source instanceof FormLink) {
        FormLink button = (FormLink) source;
        if (button.getCmd().startsWith("add")) {
            ConditionalQuery query = (ConditionalQuery) button.getUserObject();
            addParameter(query);
        } else if (button.getCmd().startsWith("remove")) {
            ConditionalQuery query = (ConditionalQuery) button.getUserObject();
            removeParameter(query);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 73 with SingleSelection

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

the class EvaluationFormController method forgeDiscreteRadioButtons.

private SliderWrapper forgeDiscreteRadioButtons(Slider slider, Rubric element, EvaluationFormResponse response) {
    int start = element.getStart();
    int end = element.getEnd();
    int steps = element.getSteps();
    double[] theSteps = new double[steps];
    String[] theKeys = new String[steps];
    String[] theValues = new String[steps];
    double step = (end - start + 1) / (double) steps;
    for (int i = 0; i < steps; i++) {
        theSteps[i] = start + (i * step);
        theKeys[i] = Double.toString(theSteps[i]);
        theValues[i] = "";
    }
    SingleSelection radioEl = uifactory.addRadiosVertical("slider_" + (count++), null, flc, theKeys, theValues);
    radioEl.setDomReplacementWrapperRequired(false);
    radioEl.addActionListener(FormEvent.ONCHANGE);
    radioEl.setEnabled(!readOnly);
    radioEl.setAllowNoSelection(true);
    int widthInPercent = EvaluationFormElementWrapper.getWidthInPercent(element);
    radioEl.setWidthInPercent(widthInPercent, true);
    if (response != null && response.getNumericalResponse() != null) {
        double val = response.getNumericalResponse().doubleValue();
        double error = step / 10.0d;
        for (int i = 0; i < theSteps.length; i++) {
            double theStep = theSteps[i];
            double margin = Math.abs(theStep - val);
            if (margin < error) {
                radioEl.select(theKeys[i], true);
            }
        }
    }
    SliderWrapper sliderWrapper = new SliderWrapper(slider, radioEl);
    radioEl.setUserObject(sliderWrapper);
    return sliderWrapper;
}
Also used : SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection)

Example 74 with SingleSelection

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

the class EPShareListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    // process all form-input fields and update data-model
    secureListBox();
    // policy might be persisted. check with validateFormLogic()
    if (source == addPolicyButton) {
        if (validateFormLogic(ureq)) {
            addEPSharePolicyWrapper(null);
            initPolicyUI();
        }
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        Object userObject = link.getUserObject();
        if (userObject instanceof EPSharePolicyWrapper) {
            EPSharePolicyWrapper wrapper = (EPSharePolicyWrapper) userObject;
            if (link.getName().startsWith("map.share.policy.add")) {
                if (validateFormLogic(ureq)) {
                    addEPSharePolicyWrapper(wrapper);
                    initPolicyUI();
                }
            } else if (link.getName().startsWith("map.share.policy.delete")) {
                removeEPSharePolicyWrapper(wrapper);
                initPolicyUI();
            } else if (link.getName().startsWith("map.share.policy.invite")) {
                if (validateFormLogic(ureq)) {
                    sendInvitation(ureq, wrapper);
                    initPolicyUI();
                }
            } else if (link.getName().startsWith("choose.group")) {
                doSelectGroup(ureq, wrapper);
            } else if (link.getName().startsWith("choose.identity")) {
                doSelectIdentity(ureq, wrapper);
            }
        } else if (userObject instanceof EPShareGroupWrapper) {
            EPShareGroupWrapper wrapper = (EPShareGroupWrapper) userObject;
            wrapper.remove();
            initPolicyUI();
        } else if (userObject instanceof EPShareUserWrapper) {
            EPShareUserWrapper wrapper = (EPShareUserWrapper) userObject;
            wrapper.remove();
            initPolicyUI();
        }
    } else if (source instanceof SingleSelection && source.getUserObject() instanceof EPSharePolicyWrapper) {
        SingleSelection selection = (SingleSelection) source;
        if (selection.isOneSelected()) {
            String type = selection.getSelectedKey();
            EPSharePolicyWrapper wrapper = (EPSharePolicyWrapper) selection.getUserObject();
            changeType(wrapper, type);
        }
        initPolicyUI();
    }
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 75 with SingleSelection

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

the class EPStructureDetailsController method setCollectRestrictions.

protected void setCollectRestrictions() {
    if (restrictionElements == null || restrictionElements.isEmpty()) {
        return;
    }
    for (int i = 0; i < restrictionElements.size(); i++) {
        final SingleSelection restrictionElement = restrictionElements.get(i);
        final SingleSelection restrictToArtefactElement = restrictToArtefactElements.get(i);
        final TextElement amountElement = amountElements.get(i);
        final CollectRestriction cr = (CollectRestriction) restrictionElement.getUserObject();
        String restriction = "";
        if (restrictionElement.isOneSelected()) {
            restriction = restrictionElement.getSelectedKey();
        }
        String artefactType = "";
        if (restrictToArtefactElement.isOneSelected()) {
            artefactType = restrictToArtefactElement.getSelectedKey();
        }
        final String amount = amountElement.getValue();
        cr.setRestriction(restriction);
        cr.setArtefactType(artefactType);
        if (StringHelper.containsNonWhitespace(amount)) {
            try {
                cr.setAmount(Integer.parseInt(amount));
            } catch (final NumberFormatException e) {
                logWarn("Wrong format for number", e);
            }
        }
    }
}
Also used : 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) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

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