Search in sources :

Example 61 with FormItem

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

the class MessageEditController method createOrUpdateAttachmentListLayout.

// adds or updates the list of already existing attachments with a delete
// button for each
private void createOrUpdateAttachmentListLayout(FormItemContainer formLayout) {
    FormItem attachLayout = formLayout.getFormComponent("attachLayout");
    List<VFSItem> attachments = new ArrayList<VFSItem>();
    // add already existing attachments:
    if (message.getKey() != null) {
        VFSContainer msgContainer = fm.getMessageContainer(message.getForum().getKey(), message.getKey());
        attachments.addAll(msgContainer.getItems(exclFilter));
    }
    // add files from TempFolder
    attachments.addAll(getTempFolderFileList());
    Collections.sort(attachments, new Comparator<VFSItem>() {

        final Collator c = Collator.getInstance(getLocale());

        public int compare(final VFSItem o1, final VFSItem o2) {
            return c.compare((o1).getName(), (o2).getName());
        }
    });
    FormLayoutContainer tmpLayout;
    if (attachLayout == null) {
        String editPage = Util.getPackageVelocityRoot(this.getClass()) + "/attachments-editview.html";
        tmpLayout = FormLayoutContainer.createCustomFormLayout("attachLayout", getTranslator(), editPage);
        formLayout.add(tmpLayout);
    } else {
        tmpLayout = (FormLayoutContainer) attachLayout;
    }
    tmpLayout.contextPut("attachments", attachments);
    // add delete links for each attachment if user is allowed to see them
    int attNr = 1;
    for (VFSItem tmpFile : attachments) {
        FormLink tmpLink = uifactory.addFormLink(CMD_DELETE_ATTACHMENT + attNr, tmpLayout, Link.BUTTON_XSMALL);
        if (!(foCallback.mayEditMessageAsModerator() || ((userIsMsgCreator) && (msgHasChildren == false)))) {
            tmpLink.setEnabled(false);
            tmpLink.setVisible(false);
        }
        tmpLink.setUserObject(tmpFile);
        tmpLink.setI18nKey("attachments.remove.string");
        attNr++;
    }
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Collator(java.text.Collator)

Example 62 with FormItem

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

the class EMailCalloutCtrl method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    Roles roles = ureq.getUserSession().getRoles();
    boolean autoCompleteAllowed = securityModule.isUserAllowedAutoComplete(roles);
    boolean isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
    if (autoCompleteAllowed) {
        ListProvider provider = new UserSearchListProvider();
        autocompleterC = new FlexiAutoCompleterController(ureq, getWindowControl(), provider, null, isAdministrativeUser, allowExternalAddress, 60, 3, null, mainForm);
        autocompleterC.setFormElement(false);
        listenTo(autocompleterC);
        FormItem item = autocompleterC.getInitialFormItem();
        formLayout.add(item);
    } else if (allowExternalAddress) {
        emailEl = uifactory.addTextElement("email" + CodeHelper.getRAMUniqueID(), "email", null, 256, "", formLayout);
    }
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) UserSearchListProvider(org.olat.admin.user.UserSearchListProvider) ListProvider(org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider) UserSearchListProvider(org.olat.admin.user.UserSearchListProvider) Roles(org.olat.core.id.Roles) FlexiAutoCompleterController(org.olat.core.gui.control.generic.ajax.autocompletion.FlexiAutoCompleterController)

Example 63 with FormItem

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

the class CourseReminderEditController method initRuleForm.

protected RuleElement initRuleForm(UserRequest ureq, RuleSPI ruleSpi, ReminderRule rule) {
    String id = Integer.toString(counter++);
    String type = ruleSpi.getClass().getSimpleName();
    SingleSelection typeEl = uifactory.addDropdownSingleselect("rule.type.".concat(id), null, rulesCont, typeKeys, typeValues, null);
    typeEl.addActionListener(FormEvent.ONCHANGE);
    for (String typeKey : typeKeys) {
        if (type.equals(typeKey)) {
            typeEl.select(typeKey, true);
        }
    }
    FormLink addRuleButton = uifactory.addFormLink("add.rule.".concat(id), "add", "add.rule", null, rulesCont, Link.BUTTON);
    addRuleButton.setIconLeftCSS("o_icon o_icon-fw o_icon_add");
    addRuleButton.setElementCssClass("o_sel_course_add_rule");
    FormLink deleteRuleButton = uifactory.addFormLink("delete.rule.".concat(id), "delete", "delete.rule", null, rulesCont, Link.BUTTON);
    deleteRuleButton.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
    deleteRuleButton.setElementCssClass("o_sel_course_delete_rule");
    RuleEditorFragment editor = ruleSpi.getEditorFragment(rule, entry);
    FormItem customItem = editor.initForm(rulesCont, this, ureq);
    RuleElement ruleEl = new RuleElement(typeEl, addRuleButton, deleteRuleButton, editor, customItem);
    typeEl.setUserObject(ruleEl);
    addRuleButton.setUserObject(ruleEl);
    deleteRuleButton.setUserObject(ruleEl);
    return ruleEl;
}
Also used : RuleEditorFragment(org.olat.modules.reminder.RuleEditorFragment) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 64 with FormItem

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

the class CourseReminderEditController method doUpdateRuleForm.

private void doUpdateRuleForm(UserRequest ureq, RuleElement panelToUpdate, RuleSPI ruleSpi) {
    // remove old editor
    rulesCont.remove(panelToUpdate.getCustomItem());
    // add new one
    RuleEditorFragment editor = ruleSpi.getEditorFragment(null, entry);
    FormItem customItem = editor.initForm(rulesCont, this, ureq);
    panelToUpdate.setCustomItem(customItem, editor);
    rulesCont.setDirty(true);
}
Also used : RuleEditorFragment(org.olat.modules.reminder.RuleEditorFragment) FormItem(org.olat.core.gui.components.form.flexible.FormItem)

Example 65 with FormItem

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

the class UserSearchFlexiController method doSearch.

public void doSearch() {
    String login = loginEl.getValue();
    // build user fields search map
    Map<String, String> userPropertiesSearch = new HashMap<>();
    for (UserPropertyHandler userPropertyHandler : userSearchFormPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        FormItem ui = propFormItems.get(userPropertyHandler.getName());
        String uiValue = userPropertyHandler.getStringValue(ui);
        if (userPropertyHandler.getName().startsWith("genericCheckboxProperty")) {
            if (!"false".equals(uiValue)) {
                userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
            }
        } else if (StringHelper.containsNonWhitespace(uiValue)) {
            userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
        }
    }
    if (userPropertiesSearch.isEmpty()) {
        userPropertiesSearch = null;
    }
    tableEl.reset();
    List<Identity> users = searchUsers(login, userPropertiesSearch, true);
    if (!users.isEmpty()) {
        userTableModel.setObjects(users);
        flc.contextPut("showButton", "true");
    } else {
        getWindowControl().setInfo(translate("error.no.user.found"));
    }
}
Also used : HashMap(java.util.HashMap) FormItem(org.olat.core.gui.components.form.flexible.FormItem) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Aggregations

FormItem (org.olat.core.gui.components.form.flexible.FormItem)142 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)62 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)34 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)30 ArrayList (java.util.ArrayList)24 HashMap (java.util.HashMap)22 Identity (org.olat.core.id.Identity)20 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)16 User (org.olat.core.id.User)16 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)14 UserManager (org.olat.user.UserManager)12 EmailProperty (org.olat.user.propertyhandlers.EmailProperty)12 HashSet (java.util.HashSet)10 Translator (org.olat.core.gui.translator.Translator)10 File (java.io.File)8 Map (java.util.Map)8 Component (org.olat.core.gui.components.Component)8 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)8 Date (java.util.Date)6 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)6