Search in sources :

Example 21 with SingleSelection

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

the class AbstractPageListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (tableEl == source) {
        if (event instanceof FlexiTableSearchEvent) {
            FlexiTableSearchEvent se = (FlexiTableSearchEvent) event;
            loadModel(ureq, se.getSearch());
        } else if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            if ("up".equals(cmd)) {
                PortfolioElementRow row = model.getObject(se.getIndex());
                if (row.isPendingAssignment()) {
                    doMoveUpAssignment(ureq, row);
                }
            } else if ("down".equals(cmd)) {
                PortfolioElementRow row = model.getObject(se.getIndex());
                if (row.isPendingAssignment()) {
                    doMoveDownAssignment(ureq, row);
                }
            }
        }
    } else if (timelineSwitchOnButton == source) {
        doSwitchTimelineOff();
    } else if (timelineSwitchOffButton == source) {
        doSwitchTimelineOn();
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if ("open.full".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doOpenRow(ureq, row, false);
        } else if ("comment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doComment(ureq, row.getPage());
        } else if ("close.section".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doConfirmCloseSection(ureq, row);
        } else if ("reopen.section".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doConfirmReopenSection(ureq, row);
        } else if ("edit.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doEditAssignment(ureq, row);
        } else if ("delete.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doConfirmDeleteAssignment(ureq, row);
        } else if ("move.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doMoveAssignment(ureq, row);
        } else if ("start.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doStartAssignment(ureq, row);
        } else if ("open.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doOpenAssignment(ureq, row);
        } else if ("up.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doMoveUpAssignment(ureq, row);
        } else if ("down.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doMoveDownAssignment(ureq, row);
        }
    } else if (source instanceof SingleSelection) {
        SingleSelection startAssignment = (SingleSelection) source;
        if (startAssignment.isOneSelected()) {
            String selectedKey = startAssignment.getSelectedKey();
            try {
                Long key = Long.parseLong(selectedKey);
                doStartAssignment(ureq, key);
            } catch (Exception e) {
            // 
            }
        }
    } else if (source == flc) {
        if ("ONCLICK".equals(event.getCommand())) {
            String category = ureq.getParameter("tag_select");
            if (StringHelper.containsNonWhitespace(category)) {
                tableEl.quickSearch(ureq, category);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 22 with SingleSelection

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

the class GenericSelectionPropertyHandler method getStringValue.

@Override
public String getStringValue(FormItem formItem) {
    if (isMultiselect) {
        Collection<String> selectedKeys = ((MultipleSelectionElement) formItem).getSelectedKeys();
        StringBuilder sb = new StringBuilder();
        for (String sKey : selectedKeys) {
            sb.append(sKey).append(KEY_DELIMITER);
        }
        return sb.toString();
    }
    if (formItem instanceof SingleSelection) {
        SingleSelection sel = (SingleSelection) formItem;
        if (sel.isOneSelected()) {
            return sel.getSelectedKey();
        } else {
            return null;
        }
    }
    return null;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection)

Example 23 with SingleSelection

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

the class UsrPropCfgTableController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    UserPropertyHandler handler = (UserPropertyHandler) source.getUserObject();
    if (source instanceof FormToggle) {
        FormToggle toggle = (FormToggle) source;
        if (toggle.isOn()) {
            usrPropCfgMng.getUserPropertiesConfigObject().setHandlerAsActive(handler, true);
            usrPropCfgMng.saveUserPropertiesConfig();
        } else {
            deactPropertyYesNoCtrl = activateYesNoDialog(ureq, translate("upc.deact_confirmationtitle"), translate("upc.deact_confirmationtext"), deactPropertyYesNoCtrl);
            deactPropertyYesNoCtrl.setUserObject(handler);
        }
    } else if (source instanceof SingleSelection) {
        SingleSelection groupSel = (SingleSelection) source;
        handler.setGroup(groupSel.getSelectedKey());
        usrPropCfgMng.saveUserPropertiesConfig();
    } else if (source instanceof FormLink) {
        String itemname = source.getName();
        if (itemname.startsWith(FT_NAME_PREFIX_TRANSL)) {
            // open the singlekeyTranslator-controller callout
            String key2Translate1 = handler.i18nFormElementLabelKey();
            String key2Translate2 = handler.i18nColumnDescriptorLabelKey();
            String[] keys2Translate = { key2Translate1, key2Translate2 };
            singleKeyTrnsCtrl = new SingleKeyTranslatorController(ureq, getWindowControl(), keys2Translate, UserPropertyHandler.class);
            listenTo(singleKeyTrnsCtrl);
            removeAsListenerAndDispose(translatorCallout);
            translatorCallout = new CloseableCalloutWindowController(ureq, getWindowControl(), singleKeyTrnsCtrl.getInitialComponent(), (FormLink) source, "Translate:: " + key2Translate1, false, null);
            listenTo(translatorCallout);
            translatorCallout.activate();
        } else if (itemname.startsWith(FT_NAME_PREFIX_HDNL)) {
            handlerConfigCtrl = handlerConfigCtrlFactory.getConfigController(ureq, getWindowControl(), handler);
            listenTo(handlerConfigCtrl);
            if (handlerConfigCtrl.getInitialComponent() != null) {
                handlerPopupCtr = new CloseableModalController(getWindowControl(), "Save", handlerConfigCtrl.getInitialComponent(), true, translate("upc.handlerconfigtitle"), false);
                handlerPopupCtr.activate();
            }
        }
    }
}
Also used : SingleKeyTranslatorController(org.olat.core.util.i18n.ui.SingleKeyTranslatorController) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 24 with SingleSelection

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

the class EPShareListController method initPolicyUI.

/**
 * creates the custom formLayoutContainer and adds a form-component for every
 * EPSharePolicyWrapper, according to its type.
 */
protected void initPolicyUI() {
    String template = Util.getPackageVelocityRoot(this.getClass()) + "/sharePolicy.html";
    for (EPSharePolicyWrapper policyWrapper : policyWrappers) {
        String cmpName = policyWrapper.getComponentName();
        if (cmpName != null && flc.getFormComponent(cmpName) != null) {
            flc.remove(cmpName);
        }
        cmpName = Integer.toString(cmpSuffixGenerator.getAndIncrement());
        policyWrapper.setComponentName(cmpName);
        FormLayoutContainer container = FormLayoutContainer.createCustomFormLayout(cmpName, getTranslator(), template);
        container.contextPut("wrapper", policyWrapper);
        container.setRootForm(mainForm);
        if (policyWrapper.getType() != null) {
            String[] curatedTargetKeys;
            String[] curatedTargetValues;
            if (!Type.invitation.equals(policyWrapper.getType()) && !loginModule.isInvitationEnabled()) {
                curatedTargetKeys = new String[targetKeys.length - 1];
                curatedTargetValues = new String[targetKeys.length - 1];
                int pos = 0;
                for (int i = targetKeys.length; i-- > 0; ) {
                    if (!targetKeys[i].equals(Type.invitation.name())) {
                        curatedTargetKeys[pos] = targetKeys[i];
                        curatedTargetValues[pos++] = targetValues[i];
                    }
                }
            } else {
                curatedTargetKeys = targetKeys;
                curatedTargetValues = targetValues;
            }
            SingleSelection type = uifactory.addDropdownSingleselect("map.share.target." + cmpName, "map.share.target", container, curatedTargetKeys, curatedTargetValues, null);
            type.addActionListener(FormEvent.ONCHANGE);
            type.setUserObject(policyWrapper);
            type.select(policyWrapper.getType().name(), true);
            switch(policyWrapper.getType()) {
                case user:
                    createContainerForUser(policyWrapper, cmpName, container);
                    break;
                case group:
                    createContainerForGroup(policyWrapper, cmpName, container);
                    break;
                case invitation:
                    Invitation invitation = policyWrapper.getInvitation();
                    if (invitation == null) {
                        invitation = invitationDao.createAndPersistInvitation();
                        policyWrapper.setInvitation(invitation);
                    }
                    createContainerForInvitation(invitation, policyWrapper, cmpName, container);
                    break;
                case allusers:
                    String text = translate("map.share.with.allOlatUsers");
                    uifactory.addStaticTextElement("map.share.with." + cmpName, text, container);
                    break;
            }
        }
        if (policyWrapper instanceof TutorEPSharePolicyWrapper) {
            String text = translate("map.share.with.tutor");
            uifactory.addStaticTextElement("map.share.text." + cmpName, text, container);
        } else {
            DateChooser fromChooser = uifactory.addDateChooser("map.share.from." + cmpName, "map.share.from", null, container);
            fromChooser.setDate(policyWrapper.getFrom());
            fromChooser.setValidDateCheck("map.share.date.invalid");
            policyWrapper.setFromChooser(fromChooser);
            DateChooser toChooser = uifactory.addDateChooser("map.share.to." + cmpName, "map.share.to", null, container);
            toChooser.setDate(policyWrapper.getTo());
            toChooser.setValidDateCheck("map.share.date.invalid");
            policyWrapper.setToChooser(toChooser);
            FormLink addLink = uifactory.addFormLink("map.share.policy.add." + cmpName, "map.share.policy.add", null, container, Link.BUTTON);
            addLink.setIconLeftCSS("o_icon o_icon-fw o_icon_add");
            addLink.setUserObject(policyWrapper);
            FormLink removeLink = uifactory.addFormLink("map.share.policy.delete." + cmpName, "map.share.policy.delete", null, container, Link.BUTTON);
            removeLink.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
            removeLink.setUserObject(policyWrapper);
            if (!policyWrapper.getType().equals(EPMapPolicy.Type.allusers)) {
                FormLink inviteLink = uifactory.addFormLink("map.share.policy.invite." + cmpName, "map.share.policy.invite", null, container, Link.BUTTON);
                inviteLink.setIconLeftCSS("o_icon o_icon-fw o_icon_share");
                inviteLink.setUserObject(policyWrapper);
                inviteLink.setEnabled(!policyWrapper.isInvitationSend() && (loginModule.isInvitationEnabled() || !policyWrapper.getType().equals(Type.invitation)));
            }
            StaticTextElement genErrorPanel = uifactory.addStaticTextElement("errorpanel." + cmpName, "", container);
            genErrorPanel.setUserObject(policyWrapper);
            policyWrapper.setErrorEl(genErrorPanel);
        }
        policyWrapper.setComponentName(cmpName);
        flc.add(container);
        flc.contextPut("wrapper", policyWrapper);
    }
    flc.contextPut("wrappers", policyWrappers);
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) Invitation(org.olat.basesecurity.Invitation) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) DateChooser(org.olat.core.gui.components.form.flexible.elements.DateChooser) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 25 with SingleSelection

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

the class EPStructureDetailsController method formOK.

/**
 * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formOK(org.olat.core.gui.UserRequest)
 */
@Override
protected void formOK(final UserRequest ureq) {
    editStructure = ePFMgr.reloadPortfolioStructure(editStructure);
    editStructure.setTitle(titleEl.getValue());
    editStructure.setDescription(descriptionEl.getValue());
    editStructure.setArtefactRepresentationMode(viewRadio.getSelectedKey());
    if (rootStructure instanceof EPStructuredMapTemplate && restrictionElements != null) {
        clearErrors();
        editStructure.getCollectRestrictions().clear();
        setCollectRestrictions();
        for (final SingleSelection restrictionElement : restrictionElements) {
            final CollectRestriction restriction = (CollectRestriction) restrictionElement.getUserObject();
            if (restriction.isValid()) {
                final CollectRestriction cr = new CollectRestriction(restriction);
                editStructure.getCollectRestrictions().add(cr);
            }
        }
    }
    ePFMgr.savePortfolioStructure(editStructure);
    fireEvent(ureq, new EPStructureEvent(EPStructureEvent.CHANGE, editStructure));
}
Also used : EPStructureEvent(org.olat.portfolio.ui.structel.EPStructureEvent) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) 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