Search in sources :

Example 91 with FormLink

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

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 92 with FormLink

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

the class EPShareListController method createContainerForUser.

private void createContainerForUser(EPSharePolicyWrapper policyWrapper, String cmpName, FormLayoutContainer container) {
    String page = velocity_root + "/shareWithUsers.html";
    FormLayoutContainer userListBox = FormLayoutContainer.createCustomFormLayout("map.share.with." + cmpName, getTranslator(), page);
    userListBox.contextPut("wrapper", policyWrapper);
    userListBox.setRootForm(mainForm);
    container.add("map.share.with." + cmpName, userListBox);
    List<Identity> identities = policyWrapper.getIdentities();
    List<EPShareUserWrapper> groupWrappers = new ArrayList<EPShareUserWrapper>();
    for (Identity identity : identities) {
        FormLink rmLink = uifactory.addFormLink("rm-" + identity.getKey(), "", null, userListBox, Link.NONTRANSLATED + Link.LINK);
        rmLink.setIconLeftCSS("o_icon o_icon_remove");
        EPShareUserWrapper gWrapper = new EPShareUserWrapper(policyWrapper, identity, rmLink);
        rmLink.setUserObject(gWrapper);
        groupWrappers.add(gWrapper);
    }
    userListBox.contextPut("identities", groupWrappers);
    policyWrapper.setUserListBox(userListBox);
    FormLink chooseUsersLink = uifactory.addFormLink("choose.identity", "choose.identity", null, userListBox, Link.BUTTON);
    chooseUsersLink.setElementCssClass("o_form_groupchooser");
    chooseUsersLink.setUserObject(policyWrapper);
}
Also used : ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Identity(org.olat.core.id.Identity) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 93 with FormLink

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

the class EPChangelogController method getItemBundlesForSubscriptionItems.

/**
 * @param subscriptionItems
 * @return
 */
private List<SubscriptionItemBundle> getItemBundlesForSubscriptionItems(List<SubscriptionListItem> subscriptionItems) {
    List<SubscriptionItemBundle> bundles = new ArrayList<EPChangelogController.SubscriptionItemBundle>();
    Formatter f = Formatter.getInstance(getTranslator().getLocale());
    for (int i = 0; i < subscriptionItems.size(); i++) {
        SubscriptionListItem listItem = subscriptionItems.get(i);
        SubscriptionItemBundle bundle = new SubscriptionItemBundle();
        bundle.setDateString(f.formatDate(listItem.getDate()));
        String linkName = "subscrIL_" + i;
        bundle.setLinkName(linkName);
        String text = listItem.getDescription();
        FormLink link = uifactory.addFormLink(linkName, text, null, flc, Link.NONTRANSLATED);
        link.setUserObject(listItem.getUserObject());
        bundle.setCssClass(listItem.getIconCssClass());
        bundles.add(bundle);
    }
    return bundles;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Formatter(org.olat.core.util.Formatter) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 94 with FormLink

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

the class EPArtefactViewController 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) {
    if (detailsLinkEnabled && !artefactChooseMode) {
        detailsLink = uifactory.addFormLink("details.link", formLayout, Link.BUTTON);
        detailsLink.setElementCssClass("o_sel_artefact_details");
    }
    title = uifactory.addInlineTextElement("title", artefact.getTitle(), formLayout, this);
    flc.contextPut("cssClosed", artefactInClosedMap ? "o_artefact_closed" : "");
    flc.contextPut("viewOnly", viewOnlyMode);
    if (viewOnlyMode || artefactInClosedMap)
        title.setEnabled(false);
    // get tags and prepare textboxlist-component
    List<String> tagL = ePFMgr.getArtefactTags(artefact);
    Map<String, String> tagLM = new HashMap<String, String>();
    for (String tag : tagL) {
        tagLM.put(tag, tag);
    }
    tblE = uifactory.addTextBoxListElement("tagTextbox", null, "tag.textboxlist.hint", tagLM, formLayout, getTranslator());
    if (viewOnlyMode || artefactInClosedMap) {
        tblE.setEnabled(false);
    } else {
        Map<String, String> allUsersTags = ePFMgr.getUsersMostUsedTags(getIdentity(), -1);
        tblE.setAutoCompleteContent(allUsersTags);
    }
    // get maps wherein this artefact is linked and create links to them
    List<PortfolioStructure> linkedMaps = ePFMgr.getReferencedMapsForArtefact(artefact);
    if (linkedMaps != null && linkedMaps.size() != 0) {
        List<FormLink> selectMapNames = new ArrayList<FormLink>(linkedMaps.size());
        int count = 0;
        for (PortfolioStructure ePMap : linkedMaps) {
            String mapTitle = StringHelper.escapeHtml(ePMap.getTitle());
            FormLink selectMap = uifactory.addFormLink("map-" + count++, "map", mapTitle, null, formLayout, Link.NONTRANSLATED);
            selectMap.setUserObject(ePMap.getOlatResource());
            selectMap.setEnabled(!viewOnlyMode && !artefactChooseMode);
            selectMapNames.add(selectMap);
        }
        flc.contextPut("maps", selectMapNames);
    }
    // build link to original source
    if (StringHelper.containsNonWhitespace(artefact.getBusinessPath())) {
        String sourceLink = createLinkToArtefactSource(ureq, artefact.getBusinessPath());
        flc.contextPut("artefactSourceLink", sourceLink);
    }
    // create a delete button
    deleteBtn = uifactory.addFormLink("delete.artefact", formLayout, Link.BUTTON);
    deleteBtn.setIconLeftCSS("o_icon o_icon_delete");
    deleteBtn.addActionListener(FormEvent.ONCLICK);
    if (viewOnlyMode || artefactChooseMode || artefactInClosedMap)
        deleteBtn.setVisible(false);
    // let the artefact-handler paint what is special for this kind of artefact
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
    Controller detCtrl = artHandler.createDetailsController(ureq, getWindowControl(), artefact, viewOnlyMode || artefactInClosedMap);
    if (detCtrl != null) {
        flc.put("detailsController", detCtrl.getInitialComponent());
    }
    // create edit buttons the adapt meta-data
    if (!(viewOnlyMode || artefactChooseMode || artefactInClosedMap)) {
        String reflexion = artefact.getReflexion();
        reflexion = FilterFactory.getHtmlTagAndDescapingFilter().filter(reflexion);
        reflexion = StringHelper.xssScan(reflexion);
        reflexion = Formatter.truncate(reflexion, 50);
        if (!StringHelper.containsNonWhitespace(reflexion)) {
            // show a link even if empty
            reflexion = "&nbsp; ";
        }
        reflexionBtn = uifactory.addFormLink("reflexionBtn", reflexion, null, formLayout, Link.NONTRANSLATED);
        reflexionBtn.setIconLeftCSS("o_icon o_icon_inline_editable");
        String description = artefact.getDescription();
        description = FilterFactory.getHtmlTagAndDescapingFilter().filter(description);
        description = Formatter.truncate(description, 50);
        description = StringHelper.xssScan(description);
        if (!StringHelper.containsNonWhitespace(description)) {
            // show a link even if empty
            description = "&nbsp; ";
        }
        descriptionBtn = uifactory.addFormLink("descriptionBtn", description, null, formLayout, Link.NONTRANSLATED);
        descriptionBtn.setIconLeftCSS("o_icon o_icon_inline_editable");
    }
    // if in artefactChooseMode, add an "choose this" button
    if (artefactChooseMode) {
        chooseBtn = uifactory.addFormLink("choose.artefact", formLayout, Link.BUTTON);
        chooseBtn.addActionListener(FormEvent.ONCLICK);
    }
    flc.contextPut("artefact", artefact);
    setArtAttribConfig(artAttribConfig);
}
Also used : HashMap(java.util.HashMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) Controller(org.olat.core.gui.control.Controller) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)

Example 95 with FormLink

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

the class UsrPropContextEditController method addTableRowComponents.

/**
 * adds tableRow-Components (Toggles and Links) for the given Handler
 *
 * @param handler The handler to create Components for
 * @param moveable if true, additional "up"/"down" Links will be rendered
 */
private void addTableRowComponents(UserPropertyHandler handler, boolean moveable) {
    List<FormItem> rowFormItemComponents = new ArrayList<FormItem>();
    final String handlername = handler.getName();
    final boolean isIncluded = context.contains(handler);
    final boolean isMandatory = context.isMandatoryUserProperty(handler);
    final boolean isAdminOnly = context.isForAdministrativeUserOnly(handler);
    final boolean isUserReadOnly = context.isUserViewReadOnly(handler);
    // put the translation (in the current language) for the property
    String translatedName = I18nManager.getInstance().getLocalizedString(UserPropertyHandler.class.getPackage().getName(), handler.i18nFormElementLabelKey(), null, getLocale(), true, true);
    uifactory.addStaticTextElement(FT_NAME_PREFIX_TRANS + handlername, (translatedName == null ? "-" : translatedName), contTableFlc);
    FormToggle ftMandatory = uifactory.addToggleButton(FT_NAME_PREFIX_MAND + handlername, "&nbsp;&nbsp;&nbsp;&nbsp;", contTableFlc, null, null);
    ftMandatory.setUserObject(handler);
    if (isMandatory)
        ftMandatory.toggleOn();
    else
        ftMandatory.toggleOff();
    if (!isIncluded) {
        ftMandatory.setEnabled(false);
        ftMandatory.setVisible(false);
    }
    FormToggle ftAdminonly = uifactory.addToggleButton(FT_NAME_PREFIX_ADMN + handlername, "&nbsp;&nbsp;&nbsp;&nbsp;", contTableFlc, null, null);
    ftAdminonly.setUserObject(handler);
    if (isAdminOnly)
        ftAdminonly.toggleOn();
    else
        ftAdminonly.toggleOff();
    if (!isIncluded) {
        ftAdminonly.setEnabled(false);
        ftAdminonly.setVisible(false);
    }
    FormToggle ftUserreadonly = uifactory.addToggleButton(FT_NAME_PREFIX_USR + handlername, "&nbsp;&nbsp;&nbsp;&nbsp;", contTableFlc, null, null);
    ftUserreadonly.setUserObject(handler);
    if (isUserReadOnly)
        ftUserreadonly.toggleOn();
    else
        ftUserreadonly.toggleOff();
    if (!isIncluded) {
        ftUserreadonly.setEnabled(false);
        ftUserreadonly.setVisible(false);
    }
    FormToggle ftInclude = uifactory.addToggleButton(FT_NAME_PREFIX_INCL + handlername, "&nbsp;&nbsp;&nbsp;&nbsp;", contTableFlc, null, null);
    ftInclude.setUserObject(handler);
    if (isIncluded) {
        ftInclude.toggleOn();
        includedPropertiesCount++;
    } else
        ftInclude.toggleOff();
    // up/down links
    FormLink fl_up = uifactory.addFormLink(FT_NAME_PREFIX_MUP + handlername, " ", null, contTableFlc, Link.NONTRANSLATED);
    fl_up.setIconLeftCSS("o_icon o_icon_move_up o_icon-lg");
    fl_up.setUserObject(handler);
    FormLink fl_down = uifactory.addFormLink(FT_NAME_PREFIX_MDN + handlername, " ", null, contTableFlc, Link.NONTRANSLATED);
    fl_down.setIconRightCSS("o_icon o_icon_move_down o_icon-lg");
    fl_down.setUserObject(handler);
    if (!moveable) {
        fl_up.setEnabled(false);
        fl_up.setVisible(false);
        fl_down.setEnabled(false);
        fl_down.setVisible(false);
    }
    rowFormItemComponents.add(ftMandatory);
    rowFormItemComponents.add(ftAdminonly);
    rowFormItemComponents.add(ftUserreadonly);
    rowFormItemComponents.add(fl_up);
    rowFormItemComponents.add(fl_down);
    rowToggleButtonsMap.put(handlername, rowFormItemComponents);
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)376 ArrayList (java.util.ArrayList)108 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)64 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)40 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)36 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)34 List (java.util.List)30 FormItem (org.olat.core.gui.components.form.flexible.FormItem)28 HashMap (java.util.HashMap)26 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)24 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)22 Date (java.util.Date)18 Map (java.util.Map)18 Link (org.olat.core.gui.components.link.Link)18 Identity (org.olat.core.id.Identity)18 Component (org.olat.core.gui.components.Component)16 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)16 FormEvent (org.olat.core.gui.components.form.flexible.impl.FormEvent)16 Controller (org.olat.core.gui.control.Controller)16 Event (org.olat.core.gui.control.Event)16