Search in sources :

Example 96 with FormLink

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

the class LicenseAdminConfigController method initHandlerConfigs.

private void initHandlerConfigs() {
    List<FormLayoutContainer> handlerConfigs = new ArrayList<>(licenseHandlers.size());
    for (LicenseHandler handler : licenseHandlers) {
        boolean handlerEnabled = licenseModule.isEnabled(handler);
        if (handlerEnabled) {
            String handlerType = handler.getType();
            FormLayoutContainer handlerCont = FormLayoutContainer.createDefaultFormLayout("handler-" + handlerType, getTranslator());
            handlerCont.setRootForm(mainForm);
            flc.add("handler-" + handlerType, handlerCont);
            uifactory.addSpacerElement("spacer-" + handlerType, handlerCont, false);
            SpacerElement handlerName = uifactory.addSpacerElement("name-" + handlerType, handlerCont, true);
            handlerName.setLabel(handler.getTitle(getLocale()), null, false);
            SingleSelection defaultLicenseTypeEl = uifactory.addDropdownSingleselect(DEFAULT_LICENSE_TYPE_PREFIX + handlerType, "admin.default.license.type", handlerCont, new String[0], new String[0], null);
            defaultLicenseTypeEl.setUserObject(handler);
            defaultLicenseTypeEl.addActionListener(FormEvent.ONCHANGE);
            defaultLicenseTypeEls.put(handlerType, defaultLicenseTypeEl);
            reloadDefaultLicenseTypeEl(handler);
            String[] licensorCreatorKeys = licensorCreators.stream().map(LicensorCreator::getType).toArray(String[]::new);
            String[] licensorCreatorValues = licensorCreators.stream().map(creator -> creator.getName(getLocale())).toArray(String[]::new);
            SingleSelection licensorCreatorEl = uifactory.addDropdownSingleselect(LICENSOR_CREATOR_TYPE_PREFIX + handlerType, "admin.licensor.creator", handlerCont, licensorCreatorKeys, licensorCreatorValues, null);
            licensorCreatorEl.setUserObject(handler);
            String creatorType = licenseModule.getLicensorCreatorType(handler);
            if (creatorType != null) {
                licensorCreatorEl.select(creatorType, true);
            }
            licensorCreatorEl.addActionListener(FormEvent.ONCHANGE);
            if (CONSTANT_CREATOR_TYPE.equals(creatorType)) {
                String licensorConstant = licenseModule.getConstantLicensor(handler);
                uifactory.addStaticTextElement("lgc-" + handlerType, "admin.licensor.constant", licensorConstant, handlerCont);
                FormLink editLicensorConstantLink = uifactory.addFormLink("lgb-", "admin.licensor.constant.edit", "", handlerCont, Link.BUTTON);
                editLicensorConstantLink.setUserObject(handler);
            }
            handlerConfigs.add(handlerCont);
        }
    }
    flc.getFormItemComponent().contextPut("handlerConfigs", handlerConfigs);
}
Also used : FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) Arrays(java.util.Arrays) LicenseModule(org.olat.core.commons.services.license.LicenseModule) LicenseService(org.olat.core.commons.services.license.LicenseService) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) ArrayList(java.util.ArrayList) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) SingleKeyTranslatorController(org.olat.core.util.i18n.ui.SingleKeyTranslatorController) Map(java.util.Map) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) CONSTANT_CREATOR_TYPE(org.olat.core.commons.services.license.manager.LicensorConstantCreator.CONSTANT_CREATOR_TYPE) LicenseTypeCols(org.olat.core.commons.services.license.ui.LicenseTypeDataModel.LicenseTypeCols) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) Link(org.olat.core.gui.components.link.Link) WindowControl(org.olat.core.gui.control.WindowControl) Collection(java.util.Collection) Controller(org.olat.core.gui.control.Controller) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) LicensorCreator(org.olat.core.commons.services.license.manager.LicensorCreator) UserRequest(org.olat.core.gui.UserRequest) LicenseType(org.olat.core.commons.services.license.LicenseType) Collections(java.util.Collections) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 97 with FormLink

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

the class DialogElementListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == tableEl) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            DialogElementRow row = tableModel.getObject(se.getIndex());
            if ("forum".equals(se.getCommand())) {
                fireEvent(ureq, new SelectRowEvent(row));
            } else if ("delete".equals(se.getCommand())) {
                doConfirmDelete(ureq, row);
            }
        }
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if ("download".equals(cmd)) {
            doFileDelivery(ureq, (DialogElement) link.getUserObject());
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) DialogElement(org.olat.course.nodes.dialog.DialogElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 98 with FormLink

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

the class EdubaseBookSectionListController method wrapBookSection.

private void wrapBookSection(BookSection bookSection) {
    String bookSectionId = "" + countBookSections++;
    // remove
    FormLink removeLink = uifactory.addFormLink(RM_PREFIX.concat(bookSectionId), RM_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
    removeLink.setIconLeftCSS("o_icon o_icon-lg o_icon_delete");
    bookSectionsCont.add(removeLink);
    bookSectionsCont.add(RM_PREFIX.concat(bookSectionId), removeLink);
    // add
    FormLink addLink = uifactory.addFormLink(ADD_PREFIX.concat(bookSectionId), ADD_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
    addLink.setIconLeftCSS("o_icon o_icon-lg o_icon_add");
    bookSectionsCont.add(addLink);
    bookSectionsCont.add(ADD_PREFIX.concat(bookSectionId), addLink);
    // up
    FormLink upLink = uifactory.addFormLink(UP_PREFIX.concat(bookSectionId), UP_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
    upLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_up");
    bookSectionsCont.add(upLink);
    bookSectionsCont.add(UP_PREFIX.concat(bookSectionId), upLink);
    // down
    FormLink downLink = uifactory.addFormLink(DOWN_PREFIX.concat(bookSectionId), DOWN_PREFIX, "", null, bookSectionsCont, Link.NONTRANSLATED);
    downLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_down");
    bookSectionsCont.add(downLink);
    bookSectionsCont.add(DOWN_PREFIX.concat(bookSectionId), downLink);
    // Details button
    FormLink detailsLinkEl = uifactory.addFormLink(DETAILS_PREFIX.concat(bookSectionId), DETAILS_PREFIX, "edubase.book.section.details", null, bookSectionsCont, Link.BUTTON);
    detailsLinkEl.setElementCssClass("o_edubase_bs_details");
    bookSectionsCont.add(detailsLinkEl);
    bookSectionsCont.add(DETAILS_PREFIX.concat(bookSectionId), detailsLinkEl);
    // book id
    TextElement bookIdEl = uifactory.addTextElement(BOOK_ID_PREFIX.concat(bookSectionId), "edubase.book.section.id", 128, bookSection.getBookId(), bookSectionsCont);
    bookIdEl.setMandatory(true);
    bookIdEl.setHelpTextKey("edubase.book.section.id.help", null);
    // page from
    String pageFrom = bookSection.getPageFrom() != null ? Integer.toString(bookSection.getPageFrom()) : null;
    TextElement pageFromEl = uifactory.addTextElement(PAGE_FROM_PREFIX.concat(bookSectionId), "edubase.book.section.page.from", 6, pageFrom, bookSectionsCont);
    // page to
    String pageTo = bookSection.getPageTo() != null ? Integer.toString(bookSection.getPageTo()) : null;
    TextElement pageToEl = uifactory.addTextElement(PAGE_TO_PREFIX.concat(bookSectionId), "edubase.book.section.page.to", 6, pageTo, bookSectionsCont);
    // title
    TextElement titleEl = uifactory.addTextElement("title".concat(bookSectionId), "edubase.book.section.title", 128, bookSection.getTitle(), bookSectionsCont);
    // description
    RichTextElement descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic(DESC_PREFIX.concat(bookSectionId), "edubase.book.section.description", bookSection.getDescription(), 4, -1, bookSectionsCont, getWindowControl());
    boolean discriptionEnabled = config.getBooleanSafe(EdubaseCourseNode.CONFIG_DESCRIPTION_ENABLED);
    descriptionEl.setVisible(discriptionEnabled);
    bookSectionWrappers.add(new BookSectionWrapper(bookSection, removeLink, addLink, upLink, downLink, detailsLinkEl, bookIdEl, pageFromEl, pageToEl, titleEl, descriptionEl));
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 99 with FormLink

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

the class PortfolioResultDetailsController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if (cmd != null && cmd.startsWith("map.deadline.change")) {
            if (deadlineCalloutCtr == null) {
                EPStructuredMap map = (EPStructuredMap) link.getUserObject();
                popupDeadlineBox(ureq, map);
            } else {
                // close on second click
                closeDeadlineBox();
            }
        } else if (link.getName().startsWith("open.map")) {
            PortfolioStructureMap map = (PortfolioStructureMap) link.getUserObject();
            doOpenMap(ureq, map);
        } else if (link.getName().startsWith("open.binder")) {
            Binder map = (Binder) link.getUserObject();
            doOpenMap(ureq, map);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Binder(org.olat.modules.portfolio.Binder) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 100 with FormLink

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

the class CustomfieldsFormController method formInnerEvent.

protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        if (link.getName().equals(ADD_FIELD_LINK)) {
            if (customFields.size() < MAX_NBR_CUSTOM_FIELDS) {
                // Add new custom-field
                int indexNewCustomField = customFields.size();
                customFields.add(new CustomField("", "", false));
                // first remove existing submit button, add it again at the end
                flc.remove(formSubmit);
                createFormElemente(this.flc, indexNewCustomField, customFields.get(indexNewCustomField));
                formSubmit = uifactory.addFormSubmitButton("save", this.flc);
            } else {
                this.showInfo("info.max.nbr.custom.fields");
            }
        } else {
            int deleteElementNumber = ((Integer) link.getUserObject()).intValue();
            getLogger().debug("remove customfield #=" + deleteElementNumber);
            customFields.remove(deleteElementNumber);
            initFormElements(flc);
        }
    }
    this.flc.setDirty(true);
}
Also used : CustomField(org.olat.course.nodes.projectbroker.datamodel.CustomField) 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