Search in sources :

Example 1 with StaticTextElement

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

the class InvitationEditRightsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_pf_invitation_form");
    FormLayoutContainer inviteeCont = FormLayoutContainer.createDefaultFormLayout("inviteeInfos", getTranslator());
    inviteeCont.setRootForm(mainForm);
    formLayout.add("inviteeInfos", inviteeCont);
    firstNameEl = uifactory.addTextElement("firstName", "firstName", 64, invitation.getFirstName(), inviteeCont);
    firstNameEl.setElementCssClass("o_sel_pf_invitation_firstname");
    firstNameEl.setMandatory(true);
    lastNameEl = uifactory.addTextElement("lastName", "lastName", 64, invitation.getLastName(), inviteeCont);
    lastNameEl.setElementCssClass("o_sel_pf_invitation_lastname");
    lastNameEl.setMandatory(true);
    String invitationEmail = email != null ? email : invitation.getMail();
    mailEl = uifactory.addTextElement("mail", "mail", 128, invitationEmail, inviteeCont);
    mailEl.setElementCssClass("o_sel_pf_invitation_mail");
    mailEl.setMandatory(true);
    mailEl.setNotEmptyCheck("map.share.empty.warn");
    mailEl.setEnabled(invitation.getKey() == null);
    if (StringHelper.containsNonWhitespace(invitation.getMail()) && MailHelper.isValidEmailAddress(invitation.getMail())) {
        SecurityGroup allUsers = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
        List<Identity> shareWithIdentities = userManager.findIdentitiesByEmail(Collections.singletonList(invitation.getMail()));
        if (isAtLeastOneInSecurityGroup(shareWithIdentities, allUsers)) {
            mailEl.setErrorKey("map.share.with.mail.error.olatUser", new String[] { invitation.getMail() });
        }
    }
    String link = getInvitationLink();
    StaticTextElement linkEl = uifactory.addStaticTextElement("invitation.link", link, inviteeCont);
    linkEl.setElementCssClass("o_sel_pf_invitation_url");
    linkEl.setLabel("invitation.link", null);
    if (mailTemplate != null) {
        subjectEl = uifactory.addTextElement("subjectElem", "mail.subject", 128, mailTemplate.getSubjectTemplate(), inviteeCont);
        subjectEl.setDisplaySize(60);
        subjectEl.setMandatory(true);
        bodyEl = uifactory.addTextAreaElement("bodyElem", "mail.body", -1, 15, 60, true, mailTemplate.getBodyTemplate(), inviteeCont);
        bodyEl.setHelpUrlForManualPage("E-Mail");
        bodyEl.setMandatory(true);
    }
    // binder
    MultipleSelectionElement accessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
    accessEl.addActionListener(FormEvent.ONCHANGE);
    binderRow = new BinderAccessRightsRow(accessEl, binder);
    // sections
    List<Section> sections = portfolioService.getSections(binder);
    Map<Long, SectionAccessRightsRow> sectionMap = new HashMap<>();
    for (Section section : sections) {
        MultipleSelectionElement sectionAccessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        sectionAccessEl.addActionListener(FormEvent.ONCHANGE);
        SectionAccessRightsRow sectionRow = new SectionAccessRightsRow(sectionAccessEl, section, binderRow);
        binderRow.getSections().add(sectionRow);
        sectionMap.put(section.getKey(), sectionRow);
    }
    // pages
    List<Page> pages = portfolioService.getPages(binder, null);
    for (Page page : pages) {
        Section section = page.getSection();
        SectionAccessRightsRow sectionRow = sectionMap.get(section.getKey());
        MultipleSelectionElement pageAccessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        pageAccessEl.addActionListener(FormEvent.ONCHANGE);
        PortfolioElementAccessRightsRow pageRow = new PortfolioElementAccessRightsRow(pageAccessEl, page, sectionRow);
        sectionRow.getPages().add(pageRow);
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("binderRow", binderRow);
    }
    selectAll = uifactory.addFormLink("form.checkall", "form.checkall", null, formLayout, Link.LINK);
    selectAll.setIconLeftCSS("o_icon o_icon-sm o_icon_check_on");
    deselectAll = uifactory.addFormLink("form.uncheckall", "form.uncheckall", null, formLayout, Link.LINK);
    deselectAll.setIconLeftCSS("o_icon o_icon-sm o_icon_check_off");
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    buttonsCont.setRootForm(mainForm);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
    if (invitation.getKey() != null) {
        removeLink = uifactory.addFormLink("remove", buttonsCont, Link.BUTTON);
    }
    uifactory.addFormSubmitButton("save", buttonsCont);
}
Also used : HashMap(java.util.HashMap) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Page(org.olat.modules.portfolio.Page) SecurityGroup(org.olat.basesecurity.SecurityGroup) Section(org.olat.modules.portfolio.Section) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) Identity(org.olat.core.id.Identity)

Example 2 with StaticTextElement

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

the class CreateRepositoryEntryController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String typeName;
    if (handler != null) {
        typeName = NewControllerFactory.translateResourceableTypeName(handler.getSupportedType(), getLocale());
    } else {
        typeName = translate("cif.type.na");
    }
    StaticTextElement typeEl = uifactory.addStaticTextElement("cif.type", typeName, formLayout);
    typeEl.setElementCssClass("o_sel_author_type");
    displaynameEl = uifactory.addTextElement("cif.displayname", "cif.displayname", 100, "", formLayout);
    displaynameEl.setElementCssClass("o_sel_author_displayname");
    displaynameEl.setFocus(true);
    displaynameEl.setDisplaySize(30);
    displaynameEl.setMandatory(true);
    String page = velocity_root + "/example_help.html";
    exampleHelpEl = FormLayoutContainer.createCustomFormLayout("example.help", "example.help", getTranslator(), page);
    formLayout.add(exampleHelpEl);
    exampleHelpEl.setVisible(false);
    FormLayoutContainer buttonContainer = FormLayoutContainer.createButtonLayout("buttonContainer", getTranslator());
    formLayout.add("buttonContainer", buttonContainer);
    buttonContainer.setElementCssClass("o_sel_repo_save_details");
    FormSubmit submit = uifactory.addFormSubmitButton("cmd.create.ressource", buttonContainer);
    submit.setElementCssClass("o_sel_author_create_submit");
    if (handler.isPostCreateWizardAvailable()) {
        wizardButton = uifactory.addFormLink("csc.startwizard", buttonContainer, Link.BUTTON);
        wizardButton.setElementCssClass("o_sel_author_create_wizard");
    }
    uifactory.addFormCancelButton("cancel", buttonContainer, ureq, getWindowControl());
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement)

Example 3 with StaticTextElement

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

the class EPCollectStepForm00 method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    title = uifactory.addTextElement("title", "artefact.title", 500, artefact.getTitle(), formLayout);
    title.setElementCssClass("o_sel_ep_artefact_metadata_title");
    title.setMandatory(true);
    title.setNotEmptyCheck("artefact.title.not.empty");
    title.setNotLongerThanCheck(512, "artefact.title.too.long");
    title.setVisible(!simpleMode);
    descript = uifactory.addRichTextElementForStringDataMinimalistic("description", "artefact.description", artefact.getDescription(), 7, -1, formLayout, getWindowControl());
    descript.setMaxLength(4000);
    descript.setNotLongerThanCheck(4000, "artefact.description.too.long");
    String artSource = artefact.getSource();
    if (StringHelper.containsNonWhitespace(artSource) && !simpleMode) {
        uifactory.addStaticTextElement("artefact.source", artSource, formLayout);
    }
    Date artDate = artefact.getCreationDate();
    if (artDate == null)
        artDate = new Date();
    StaticTextElement date = uifactory.addStaticTextElement("artefact.date", Formatter.getInstance(getLocale()).formatDateAndTime(artDate), formLayout);
    date.setVisible(!simpleMode);
    String busPath = artefact.getBusinessPath();
    if (StringHelper.containsNonWhitespace(busPath) && !simpleMode) {
        BusinessControlFactory bCF = BusinessControlFactory.getInstance();
        List<ContextEntry> ceList = bCF.createCEListFromString(busPath);
        String busLink = bCF.getAsURIString(ceList, true);
        if (StringHelper.containsNonWhitespace(busLink)) {
            String finalPath = "<a href=\"" + busLink + "\">" + busLink + "</a>";
            uifactory.addStaticTextElement("artefact.link", finalPath, formLayout);
        }
    }
    if (!isUsedInStepWizzard()) {
        // add form buttons
        uifactory.addFormSubmitButton("stepform.submit", formLayout);
    }
}
Also used : StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) Date(java.util.Date) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 4 with StaticTextElement

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

the class EditDueDatesController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    ModuleConfiguration config = gtaNode.getModuleConfiguration();
    Date assignmentDueDate = task.getAssignmentDueDate();
    assignmentDueDateEl = uifactory.addDateChooser("assignment.duedate", assignmentDueDate, formLayout);
    assignmentDueDateEl.setDateChooserTimeEnabled(true);
    DueDate standardAssignmentDueDate = gtaManager.getAssignmentDueDate(task, assessedIdentity, assessedGroup, gtaNode, courseEntry, false);
    setDueDateExplanation(assignmentDueDateEl, standardAssignmentDueDate);
    assignmentDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT));
    Date submissionDueDate = task.getSubmissionDueDate();
    submissionDueDateEl = uifactory.addDateChooser("submission.duedate", submissionDueDate, formLayout);
    submissionDueDateEl.setDateChooserTimeEnabled(true);
    DueDate standardSubmissionDueDate = gtaManager.getSubmissionDueDate(task, assessedIdentity, assessedGroup, gtaNode, courseEntry, false);
    setDueDateExplanation(submissionDueDateEl, standardSubmissionDueDate);
    boolean submissionDeadline = config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT);
    submissionDueDateEl.setVisible(submissionDeadline);
    if (submissionDeadline && task.getTaskStatus().ordinal() > TaskProcess.submit.ordinal()) {
        StaticTextElement warningReopenEl = uifactory.addStaticTextElement("reopen", translate("warning.reopen"), formLayout);
        warningReopenEl.setElementCssClass("o_gta_reopen_warning");
        warningReopenEl.setLabel(null, null);
    }
    Date revisionsDueDate = task.getRevisionsDueDate();
    revisionDueDateEl = uifactory.addDateChooser("revisions.duedate", revisionsDueDate, formLayout);
    revisionDueDateEl.setDateChooserTimeEnabled(true);
    revisionDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD));
    Date solutionDueDate = task.getSolutionDueDate();
    solutionDueDateEl = uifactory.addDateChooser("solution.duedate", solutionDueDate, formLayout);
    solutionDueDateEl.setDateChooserTimeEnabled(true);
    DueDate standardSolutionDueDate = gtaManager.getSolutionDueDate(task, assessedIdentity, assessedGroup, gtaNode, courseEntry, true);
    setDueDateExplanation(solutionDueDateEl, standardSolutionDueDate);
    solutionDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION));
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
    uifactory.addFormSubmitButton("save", buttonsCont);
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) DueDate(org.olat.course.nodes.gta.model.DueDate) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) Date(java.util.Date) DueDate(org.olat.course.nodes.gta.model.DueDate) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate)

Example 5 with StaticTextElement

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

the class PreferencesFormController 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)
 */
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("title.prefs");
    setFormContextHelp("Configuration#_einstellungen");
    // load preferences
    Preferences prefs = tobeChangedIdentity.getUser().getPreferences();
    // Username
    StaticTextElement username = uifactory.addStaticTextElement("form.username", tobeChangedIdentity.getName(), formLayout);
    username.setElementCssClass("o_sel_home_settings_username");
    username.setEnabled(false);
    // Roles
    final String[] roleKeys = new String[] { Constants.GROUP_USERMANAGERS, Constants.GROUP_GROUPMANAGERS, Constants.GROUP_POOL_MANAGER, Constants.GROUP_AUTHORS, Constants.GROUP_INST_ORES_MANAGER, Constants.GROUP_ADMIN };
    String iname = getIdentity().getUser().getProperty("institutionalName", null);
    String ilabel = iname != null ? translate("rightsForm.isInstitutionalResourceManager.institution", iname) : translate("rightsForm.isInstitutionalResourceManager");
    final String[] roleValues = new String[] { translate("rightsForm.isUsermanager"), translate("rightsForm.isGroupmanager"), translate("rightsForm.isPoolmanager"), translate("rightsForm.isAuthor"), ilabel, translate("rightsForm.isAdmin") };
    final BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
    String userRoles = "";
    List<String> roles = securityManager.getRolesAsString(tobeChangedIdentity);
    for (String role : roles) {
        for (int i = 0; i < roleKeys.length; i++) {
            if (roleKeys[i].equals(role)) {
                userRoles = userRoles + roleValues[i] + ", ";
            }
        }
    }
    if (userRoles.equals("")) {
        userRoles = translate("rightsForm.isAnonymous.false");
    } else {
        userRoles = userRoles.substring(0, userRoles.lastIndexOf(","));
    }
    uifactory.addStaticTextElement("rightsForm.roles", userRoles, formLayout);
    username.setElementCssClass("o_sel_home_settings_username");
    username.setEnabled(false);
    // Language
    Map<String, String> languages = I18nManager.getInstance().getEnabledLanguagesTranslated();
    String[] langKeys = StringHelper.getMapKeysAsStringArray(languages);
    String[] langValues = StringHelper.getMapValuesAsStringArray(languages);
    ArrayHelper.sort(langKeys, langValues, false, true, false);
    language = uifactory.addDropdownSingleselect("form.language", formLayout, langKeys, langValues, null);
    language.setElementCssClass("o_sel_home_settings_language");
    String langKey = prefs.getLanguage();
    // this server
    if (prefs.getLanguage() != null && i18nModule.getEnabledLanguageKeys().contains(langKey)) {
        language.select(prefs.getLanguage(), true);
    } else {
        language.select(I18nModule.getDefaultLocale().toString(), true);
    }
    // Font size
    String[] cssFontsizeValues = new String[] { translate("form.fontsize.xsmall"), translate("form.fontsize.small"), translate("form.fontsize.normal"), translate("form.fontsize.large"), translate("form.fontsize.xlarge"), translate("form.fontsize.presentation") };
    fontsize = uifactory.addDropdownSingleselect("form.fontsize", formLayout, cssFontsizeKeys, cssFontsizeValues, null);
    fontsize.setElementCssClass("o_sel_home_settings_fontsize");
    fontsize.select(prefs.getFontsize(), true);
    fontsize.addActionListener(FormEvent.ONCHANGE);
    // Email notification interval
    NotificationsManager nMgr = NotificationsManager.getInstance();
    List<String> intervals = nMgr.getEnabledNotificationIntervals();
    if (intervals.size() > 0) {
        String[] intervalKeys = new String[intervals.size()];
        intervals.toArray(intervalKeys);
        String[] intervalValues = new String[intervalKeys.length];
        String i18nPrefix = "interval.";
        for (int i = 0; i < intervalKeys.length; i++) {
            intervalValues[i] = translate(i18nPrefix + intervalKeys[i]);
        }
        notificationInterval = uifactory.addDropdownSingleselect("form.notification", formLayout, intervalKeys, intervalValues, null);
        notificationInterval.setElementCssClass("o_sel_home_settings_notification_interval");
        notificationInterval.select(prefs.getNotificationInterval(), true);
    }
    // fxdiff VCRP-16: intern mail system
    MailModule mailModule = (MailModule) CoreSpringFactory.getBean("mailModule");
    if (mailModule.isInternSystem()) {
        String userEmail = UserManager.getInstance().getUserDisplayEmail(tobeChangedIdentity, ureq.getLocale());
        String[] mailInternLabels = new String[] { translate("mail." + mailIntern[0], userEmail), translate("mail." + mailIntern[1], userEmail) };
        mailSystem = uifactory.addRadiosVertical("mail-system", "mail.system", formLayout, mailIntern, mailInternLabels);
        mailSystem.setElementCssClass("o_sel_home_settings_mail");
        String mailPrefs = prefs.getReceiveRealMail();
        if (StringHelper.containsNonWhitespace(mailPrefs)) {
            if ("true".equals(mailPrefs)) {
                mailSystem.select(mailIntern[1], true);
            } else {
                mailSystem.select(mailIntern[0], true);
            }
        } else if (mailModule.isReceiveRealMailUserDefaultSetting()) {
            mailSystem.select(mailIntern[1], true);
        } else {
            mailSystem.select(mailIntern[0], true);
        }
    }
    // Text encoding
    Map<String, Charset> charsets = Charset.availableCharsets();
    String currentCharset = UserManager.getInstance().getUserCharset(tobeChangedIdentity);
    String[] csKeys = StringHelper.getMapKeysAsStringArray(charsets);
    charset = uifactory.addDropdownSingleselect("form.charset", formLayout, csKeys, csKeys, null);
    charset.setElementCssClass("o_sel_home_settings_charset");
    if (currentCharset != null) {
        for (String csKey : csKeys) {
            if (csKey.equals(currentCharset)) {
                charset.select(currentCharset, true);
            }
        }
    }
    if (!charset.isOneSelected() && charsets.containsKey("UTF-8")) {
        charset.select("UTF-8", true);
    }
    // Submit and cancel buttons
    final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
    formLayout.add(buttonLayout);
    buttonLayout.setElementCssClass("o_sel_home_settings_prefs_buttons");
    uifactory.addFormSubmitButton("submit", buttonLayout);
    uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
Also used : Charset(java.nio.charset.Charset) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) BaseSecurity(org.olat.basesecurity.BaseSecurity) MailModule(org.olat.core.util.mail.MailModule) NotificationsManager(org.olat.core.commons.services.notifications.NotificationsManager) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) Preferences(org.olat.core.id.Preferences)

Aggregations

StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)30 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)20 ArrayList (java.util.ArrayList)8 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)8 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)8 Identity (org.olat.core.id.Identity)8 SecurityGroup (org.olat.basesecurity.SecurityGroup)6 Date (java.util.Date)4 DateChooser (org.olat.core.gui.components.form.flexible.elements.DateChooser)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)4 FormSubmit (org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit)4 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)4 ContextEntry (org.olat.core.id.context.ContextEntry)4 TaskDueDate (org.olat.course.nodes.gta.TaskDueDate)4 DueDate (org.olat.course.nodes.gta.model.DueDate)4 ModuleConfiguration (org.olat.modules.ModuleConfiguration)4 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)4 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)4 File (java.io.File)2