Search in sources :

Example 31 with FormLayoutContainer

use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.

the class UserSearchFlexiController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        // insert a autocompleter search
        Roles roles = ureq.getUserSession().getRoles();
        boolean autoCompleteAllowed = securityModule.isUserAllowedAutoComplete(roles);
        boolean ajax = Windows.getWindows(ureq).getWindowManager().isAjaxEnabled();
        if (ajax && autoCompleteAllowed) {
            // auto complete
            String velocityAutoCRoot = Util.getPackageVelocityRoot(FlexiAutoCompleterController.class);
            String autoCPage = velocityAutoCRoot + "/autocomplete.html";
            autoCompleterContainer = FormLayoutContainer.createCustomFormLayout("autocompletionsearch", getTranslator(), autoCPage);
            autoCompleterContainer.setRootForm(mainForm);
            layoutCont.add(autoCompleterContainer);
            layoutCont.add("autocompletionsearch", autoCompleterContainer);
            setupAutoCompleter(ureq, autoCompleterContainer, null, isAdministrativeUser, 60, 3, null);
        }
        // user search form
        backLink = uifactory.addFormLink("btn.back", formLayout);
        backLink.setIconLeftCSS("o_icon o_icon_back");
        searchFormContainer = FormLayoutContainer.createDefaultFormLayout("usersearchPanel", getTranslator());
        searchFormContainer.setRootForm(mainForm);
        searchFormContainer.setElementCssClass("o_sel_usersearch_searchform");
        searchFormContainer.setFormTitle(translate("header.normal"));
        layoutCont.add(searchFormContainer);
        layoutCont.add("usersearchPanel", searchFormContainer);
        loginEl = uifactory.addTextElement("login", "search.form.login", 128, "", searchFormContainer);
        loginEl.setVisible(isAdministrativeUser);
        propFormItems = new HashMap<>();
        for (UserPropertyHandler userPropertyHandler : userSearchFormPropertyHandlers) {
            if (userPropertyHandler == null)
                continue;
            FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, UserSearchForm.class.getCanonicalName(), false, searchFormContainer);
            // DO NOT validate email field => see OLAT-3324, OO-155, OO-222
            if (userPropertyHandler instanceof EmailProperty && fi instanceof TextElement) {
                TextElement textElement = (TextElement) fi;
                textElement.setItemValidatorProvider(null);
            }
            propFormItems.put(userPropertyHandler.getName(), fi);
        }
        FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
        buttonGroupLayout.setRootForm(mainForm);
        searchFormContainer.add(buttonGroupLayout);
        // Don't use submit button, form should not be marked as dirty since this is
        // not a configuration form but only a search form (OLAT-5626)
        searchButton = uifactory.addFormLink("submit.search", buttonGroupLayout, Link.BUTTON);
        layoutCont.contextPut("noList", "false");
        layoutCont.contextPut("showButton", "false");
        // add the table
        FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
        int colPos = 0;
        if (isAdministrativeUser) {
            tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.user.login", colPos++, true, "login"));
        }
        List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
        List<UserPropertyHandler> resultingPropertyHandlers = new ArrayList<>();
        // followed by the users fields
        for (int i = 0; i < userPropertyHandlers.size(); i++) {
            UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
            boolean visible = UserManager.getInstance().isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
            if (visible) {
                resultingPropertyHandlers.add(userPropertyHandler);
                tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos++, true, userPropertyHandler.getName()));
            }
        }
        tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select"));
        Translator myTrans = userManager.getPropertyHandlerTranslator(getTranslator());
        userTableModel = new UserSearchFlexiTableModel(Collections.<Identity>emptyList(), resultingPropertyHandlers, isAdministrativeUser, getLocale(), tableColumnModel);
        tableEl = uifactory.addTableElement(getWindowControl(), "users", userTableModel, 250, false, myTrans, formLayout);
        tableEl.setCustomizeColumns(false);
        tableEl.setMultiSelect(true);
        tableEl.setSelectAllEnable(true);
        layoutCont.put("userTable", tableEl.getComponent());
    }
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Roles(org.olat.core.id.Roles) EmailProperty(org.olat.user.propertyhandlers.EmailProperty) Translator(org.olat.core.gui.translator.Translator) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 32 with FormLayoutContainer

use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.

the class UserSearchForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_user_search_form");
    login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
    login.setVisible(isAdminProps);
    login.setElementCssClass("o_sel_user_search_username");
    Translator tr = Util.createPackageTranslator(UserPropertyHandler.class, getLocale(), getTranslator());
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, getClass().getCanonicalName(), false, formLayout);
        fi.setTranslator(tr);
        // DO NOT validate email field => see OLAT-3324, OO-155, OO-222
        if (userPropertyHandler instanceof EmailProperty && fi instanceof TextElement) {
            TextElement textElement = (TextElement) fi;
            textElement.setItemValidatorProvider(null);
        }
        fi.setElementCssClass("o_sel_user_search_".concat(userPropertyHandler.getName().toLowerCase()));
        propFormItems.put(userPropertyHandler.getName(), fi);
    }
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    // Don't use submit button, form should not be marked as dirty since this is
    // not a configuration form but only a search form (OLAT-5626)
    searchButton = uifactory.addFormLink("submit.search", buttonGroupLayout, Link.BUTTON);
    searchButton.setElementCssClass("o_sel_user_search_button");
    if (cancelButton) {
        uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
    }
}
Also used : EmailProperty(org.olat.user.propertyhandlers.EmailProperty) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) Translator(org.olat.core.gui.translator.Translator) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 33 with FormLayoutContainer

use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.

the class MembersMailController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String fullName = userManager.getUserDisplayName(getIdentity());
    if (StringHelper.containsNonWhitespace(fullName)) {
        fullName = "[" + fullName + "]";
    }
    TextElement fromEl = uifactory.addTextElement("from", "email.from", 255, fullName, formLayout);
    fromEl.setEnabled(false);
    uifactory.addSpacerElement("space-1", formLayout, false);
    String to = "send.mail.to";
    if (ownerList != null && ownerList.size() > 0) {
        String[] values = new String[] { translate("contact.all.owners") };
        ownerEl = uifactory.addCheckboxesHorizontal("contact.all.owners", to, formLayout, keys, values);
        to = null;
    }
    if (coachList != null && coachList.size() > 0) {
        String[] values = new String[] { translate("contact.all.coaches") };
        coachEl = uifactory.addCheckboxesHorizontal("contact.all.coaches", to, formLayout, keys, values);
        to = null;
    }
    if (participantList != null && participantList.size() > 0) {
        String[] values = new String[] { translate("contact.all.participants") };
        participantEl = uifactory.addCheckboxesHorizontal("contact.all.participants", to, formLayout, keys, values);
        to = null;
    }
    if (waitingList != null && waitingList.size() > 0) {
        String[] values = new String[] { translate("contact.all.waiting") };
        waitingEl = uifactory.addCheckboxesHorizontal("contact.all.waiting", to, formLayout, keys, values);
        to = null;
    }
    if ((ownerList != null && ownerList.size() > 0) || (coachList != null && coachList.size() > 0) || (participantList != null && participantList.size() > 0) || (waitingList != null && waitingList.size() > 0)) {
        String[] values = new String[] { translate("contact.individual") };
        individualEl = uifactory.addCheckboxesHorizontal("contact.individual", to, formLayout, keys, values);
        individualEl.addActionListener(FormEvent.ONCHANGE);
        to = null;
        String attachmentPage = velocity_root + "/individual_members.html";
        individualMemberCont = FormLayoutContainer.createCustomFormLayout("contact.individual.list", getTranslator(), attachmentPage);
        formLayout.add(individualMemberCont);
        individualMemberCont.setRootForm(mainForm);
        individualMemberCont.setVisible(false);
        individualMemberCont.contextPut("selectedMembers", selectedMembers);
        addMemberButton = uifactory.addFormLink("add.member", "add", "", "", individualMemberCont, Link.NONTRANSLATED);
        addMemberButton.setIconLeftCSS("o_icon o_icon-lg o_icon_table_large");
        addMemberButton.setDomReplacementWrapperRequired(false);
        addMemberButton.getComponent().setSuppressDirtyFormWarning(true);
    }
    String[] extValues = new String[] { translate("contact.external") };
    externalEl = uifactory.addCheckboxesHorizontal("contact.external", to, formLayout, keys, extValues);
    externalEl.addActionListener(FormEvent.ONCHANGE);
    externalAddressesEl = uifactory.addTextAreaElement("contact.external.list", null, 4096, 3, 60, false, "", formLayout);
    externalAddressesEl.setExampleKey("contact.external.list.example", null);
    externalAddressesEl.setVisible(false);
    uifactory.addSpacerElement("space-2", formLayout, false);
    subjectEl = uifactory.addTextElement("subject", "mail.subject", 255, "", formLayout);
    subjectEl.setDisplaySize(255);
    subjectEl.setMandatory(true);
    bodyEl = uifactory.addRichTextElementForStringDataMinimalistic("body", "mail.body", "", 15, 8, formLayout, getWindowControl());
    bodyEl.setMandatory(true);
    attachmentEl = uifactory.addFileElement(getWindowControl(), "file_upload_1", "contact.attachment", formLayout);
    attachmentEl.addActionListener(FormEvent.ONCHANGE);
    attachmentEl.setExampleKey("contact.attachment.maxsize", new String[] { Integer.toString(contactAttachmentMaxSizeInMb) });
    String attachmentPage = velocity_root + "/attachments.html";
    uploadCont = FormLayoutContainer.createCustomFormLayout("file_upload_inner", getTranslator(), attachmentPage);
    uploadCont.setRootForm(mainForm);
    uploadCont.setVisible(false);
    uploadCont.contextPut("attachments", attachments);
    formLayout.add(uploadCont);
    String[] copyValues = new String[] { "" };
    copyFromEl = uifactory.addCheckboxesHorizontal("copy.from", "contact.cp.from", formLayout, keys, copyValues);
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    uifactory.addFormSubmitButton("email.send", buttonGroupLayout);
    uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 34 with FormLayoutContainer

use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.

the class InfoDisplayController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (secCallback.canAdd()) {
        newInfoLink = uifactory.addFormLink("new_message", "new_message", "new_message", formLayout, Link.BUTTON);
        newInfoLink.setElementCssClass("o_sel_course_info_create_msg");
    }
    oldMsgsLink = uifactory.addFormLink("display.old_messages", "display.old_messages", "display.old_messages", formLayout, Link.BUTTON);
    oldMsgsLink.setElementCssClass("o_sel_course_info_old_msgs");
    newMsgsLink = uifactory.addFormLink("display.new_messages", "display.new_messages", "display.new_messages", formLayout, Link.BUTTON);
    newMsgsLink.setElementCssClass("o_sel_course_info_new_msgs");
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("thumbnailMapper", thumbnailMapper);
        layoutCont.contextPut("attachmentMapper", attachmentMapper);
    }
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 35 with FormLayoutContainer

use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.

the class InfoEditController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormLayoutContainer editCont = editForm.getInitialFormItem();
    flc.add("edit", editCont);
    final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
    editCont.add(buttonLayout);
    uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
    uifactory.addFormSubmitButton("submit", buttonLayout);
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Aggregations

FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)844 ArrayList (java.util.ArrayList)96 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)76 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)76 Date (java.util.Date)56 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)56 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)42 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)40 FormItem (org.olat.core.gui.components.form.flexible.FormItem)38 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)32 Translator (org.olat.core.gui.translator.Translator)30 Identity (org.olat.core.id.Identity)30 VFSContainer (org.olat.core.util.vfs.VFSContainer)28 File (java.io.File)26 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)26 BusinessGroup (org.olat.group.BusinessGroup)26 HashMap (java.util.HashMap)22 HashSet (java.util.HashSet)22 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)22 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)20