Search in sources :

Example 21 with StaticTextElement

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

the class FormUIFactory method addStaticTextElement.

/**
 * Add a static text.
 * @param name
 * @param i18nLabel
 * @param translatedText
 * @param formLayout
 * @return
 */
public StaticTextElement addStaticTextElement(String name, String i18nLabel, String translatedText, FormItemContainer formLayout) {
    StaticTextElement ste = new StaticTextElementImpl(name, translatedText == null ? "" : translatedText);
    setLabelIfNotNull(i18nLabel, ste);
    formLayout.add(ste);
    return ste;
}
Also used : StaticTextElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.StaticTextElementImpl) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement)

Example 22 with StaticTextElement

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

the class PreviewLA method getFormItem.

/**
 * @see org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute#getFormItem(java.lang.String, org.olat.core.gui.components.form.flexible.FormItemContainer)
 */
@Override
public FormItem getFormItem(String compName, FormItemContainer formLayout) {
    FormUIFactory uifact = FormUIFactory.getInstance();
    String textEl = new String("<span style=\"" + getAttributeValue() + "\">" + formLayout.getTranslator().translate("preview.sample") + "</span>");
    StaticTextElement fi = uifact.addStaticTextElement(compName, null, textEl, formLayout);
    return fi;
}
Also used : StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) FormUIFactory(org.olat.core.gui.components.form.flexible.FormUIFactory)

Example 23 with StaticTextElement

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

the class EditMultipleDueDatesController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    ModuleConfiguration config = gtaNode.getModuleConfiguration();
    assignmentDueDateEl = uifactory.addDateChooser("assignment.duedate", null, formLayout);
    assignmentDueDateEl.setDateChooserTimeEnabled(true);
    DueDate standardAssignmentDueDate = gtaManager.getAssignmentDueDate(null, null, null, gtaNode, courseEntry, false);
    setDueDateExplanation(assignmentDueDateEl, standardAssignmentDueDate);
    assignmentDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT));
    submissionDueDateEl = uifactory.addDateChooser("submission.duedate", null, formLayout);
    submissionDueDateEl.setDateChooserTimeEnabled(true);
    DueDate standardSubmissionDueDate = gtaManager.getSubmissionDueDate(null, null, null, gtaNode, courseEntry, false);
    setDueDateExplanation(submissionDueDateEl, standardSubmissionDueDate);
    boolean submissionDeadline = config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT);
    submissionDueDateEl.setVisible(submissionDeadline);
    if (submissionDeadline) {
        for (Task task : tasks) {
            if (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);
                break;
            }
        }
    }
    revisionDueDateEl = uifactory.addDateChooser("revisions.duedate", null, formLayout);
    revisionDueDateEl.setDateChooserTimeEnabled(true);
    revisionDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD));
    solutionDueDateEl = uifactory.addDateChooser("solution.duedate", null, formLayout);
    solutionDueDateEl.setDateChooserTimeEnabled(true);
    DueDate standardSolutionDueDate = gtaManager.getSolutionDueDate(null, null, null, gtaNode, courseEntry, false);
    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 : Task(org.olat.course.nodes.gta.Task) 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)

Example 24 with StaticTextElement

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

the class EPShareListController method validateFormLogic.

@Override
protected boolean validateFormLogic(UserRequest ureq) {
    boolean allOk = true;
    // process all form-input fields and update data-model
    secureListBox();
    String genericError = null;
    for (EPSharePolicyWrapper policyWrapper : policyWrappers) {
        Type type = policyWrapper.getType();
        if (type == null) {
            // tutor implicit rule
            continue;
        }
        TextElement mailEl = policyWrapper.getMailEl();
        if (mailEl != null) {
            String mail = mailEl.getValue();
            if (StringHelper.containsNonWhitespace(mail)) {
                if (MailHelper.isValidEmailAddress(mail)) {
                    SecurityGroup allUsers = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
                    List<Identity> shareWithIdentities = userManager.findIdentitiesByEmail(Collections.singletonList(mail));
                    if (isAtLeastOneInSecurityGroup(shareWithIdentities, allUsers)) {
                        mailEl.setErrorKey("error.invitation.mail.used", new String[] { mail });
                        allOk &= false;
                    }
                } else {
                    mailEl.setErrorKey("map.share.with.mail.error", null);
                    allOk &= false;
                }
            } else if (type.equals(Type.invitation)) {
                genericError = translate("map.share.error.invite");
                allOk &= false;
            }
        } else if (type.equals(Type.group)) {
            List<BusinessGroup> groups = policyWrapper.getGroups();
            if (groups.size() == 0) {
                genericError = translate("map.share.error.group");
                allOk &= false;
            }
        } else if (type.equals(Type.user)) {
            List<Identity> idents = policyWrapper.getIdentities();
            if (idents.size() == 0) {
                genericError = translate("map.share.error.user");
                allOk &= false;
            }
        }
        if ((policyWrapper.getFromChooser() != null && policyWrapper.getFromChooser().hasError()) || (policyWrapper.getToChooser() != null && policyWrapper.getToChooser().hasError())) {
            genericError = translate("map.share.date.invalid");
            allOk &= false;
        }
        if (policyWrapper.getFrom() != null && policyWrapper.getTo() != null && policyWrapper.getFrom().after(policyWrapper.getTo())) {
            // show invalid date warning
            policyWrapper.getFromChooser().setErrorKey("from.date.behind.to", null);
            policyWrapper.getFromChooser().showError(true);
            genericError = translate("from.date.behind.to");
            allOk &= false;
        }
        StaticTextElement errTextEl = policyWrapper.getErrorEl();
        if (genericError != null && errTextEl != null) {
            errTextEl.setValue(genericError);
        }
    }
    return allOk && super.validateFormLogic(ureq);
}
Also used : Type(org.olat.portfolio.manager.EPMapPolicy.Type) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) SecurityGroup(org.olat.basesecurity.SecurityGroup) Identity(org.olat.core.id.Identity)

Example 25 with StaticTextElement

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

the class EPStructureDetailsController 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(final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) {
    if (formLayout.getFormComponent("struct.title") != null) {
        formLayout.remove("struct.title");
    }
    titleEl = uifactory.addTextElement("struct.title", "struct.title", 512, editStructure.getTitle(), formLayout);
    titleEl.setNotEmptyCheck("map.title.not.empty");
    titleEl.setMandatory(true);
    // choose representation mode (table or minimized artefact-view)
    if (formLayout.getFormComponent("view.mode") != null) {
        formLayout.remove("view.mode");
    }
    final String[] theKeys = new String[] { VIEWMODE_TABLE, VIEWMODE_MINI };
    final String[] theValues = new String[] { translate("view.mode." + VIEWMODE_TABLE), translate("view.mode." + VIEWMODE_MINI) };
    viewRadio = uifactory.addRadiosHorizontal("view.mode", formLayout, theKeys, theValues);
    final String artRepMode = editStructure.getArtefactRepresentationMode();
    if (artRepMode != null) {
        viewRadio.select(artRepMode, true);
    } else {
        viewRadio.select(VIEWMODE_MINI, true);
    }
    if (formLayout.getFormComponent("struct.description") != null) {
        formLayout.remove("struct.description");
    }
    descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic("struct.description", "struct.description", editStructure.getDescription(), -1, -1, formLayout, getWindowControl());
    descriptionEl.setMaxLength(2047);
    descriptionEl.setNotLongerThanCheck(2047, "map.description.too.long");
    // hint for no edit options
    if (formLayout.getFormComponent("noEditInfo") != null) {
        formLayout.remove("noEditInfo");
    }
    noEditInfo = uifactory.addStaticTextElement("noEditInfo", "no.edit.info.label", translate("no.edit.info"), formLayout);
    noEditInfo.setVisible(false);
    if (formLayout.getFormComponent("collect.restriction") != null) {
        formLayout.remove("collect.restriction");
    }
    // show restrictions only for templates and on page/structure-level, as artefacts are not linkable on maps itself
    if (editStructure instanceof EPStructureElement && rootStructure instanceof EPStructuredMapTemplate && editStructure.getRoot() != null) {
        final FormLayoutContainer collectContainer = FormLayoutContainer.createCustomFormLayout("collect.restriction", getTranslator(), velocity_root + "/restrictions.html");
        collectContainer.setRootForm(mainForm);
        collectContainer.setLabel("collect.restriction", null);
        formLayout.add(collectContainer);
        final String[] restrictionKeys = new String[] { "", RestrictionsConstants.MAX, RestrictionsConstants.EQUAL, RestrictionsConstants.MIN };
        final String[] restrictionValues = new String[restrictionKeys.length];
        restrictionValues[0] = "";
        for (int i = 1; i < restrictionKeys.length; i++) {
            restrictionValues[i] = translate("restriction." + restrictionKeys[i]);
        }
        // allow only to use enabled handlers
        final List<EPArtefactHandler<?>> handlers = portfolioModule.getArtefactHandlers();
        final String[] artefactKeys = new String[handlers.size() + 1];
        final String[] artefactValues = new String[artefactKeys.length];
        artefactValues[0] = artefactKeys[0] = "";
        for (int i = 0; i < handlers.size(); i++) {
            final EPArtefactHandler<?> handler = handlers.get(i);
            artefactKeys[i + 1] = handler.getType();
            final String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + PortfolioFilterController.HANDLER_TITLE_SUFFIX;
            artefactValues[i + 1] = handler.getHandlerTranslator(getTranslator()).translate(handlerClass);
        }
        if (collectRestrictions.isEmpty()) {
            collectRestrictions.add(new CollectRestriction());
        }
        restrictionElements = new ArrayList<SingleSelection>();
        restrictToArtefactElements = new ArrayList<SingleSelection>();
        amountElements = new ArrayList<TextElement>();
        errorElements = new ArrayList<StaticTextElement>();
        final List<String> counts = new ArrayList<String>();
        for (final CollectRestriction restriction : collectRestrictions) {
            final int count = restrictionElements.size();
            final SingleSelection restrictionElement = uifactory.addDropdownSingleselect("collect.restriction.restriction." + count, "", collectContainer, restrictionKeys, restrictionValues, null);
            restrictionElement.setDomReplacementWrapperRequired(false);
            restrictionElement.setMandatory(true);
            if (restriction != null && StringHelper.containsNonWhitespace(restriction.getRestriction())) {
                restrictionElement.select(restriction.getRestriction(), true);
            }
            restrictionElement.setUserObject(restriction);
            final SingleSelection restrictToArtefactElement = uifactory.addDropdownSingleselect("collect.restriction.artefacts." + count, "", collectContainer, artefactKeys, artefactValues, null);
            restrictToArtefactElement.setDomReplacementWrapperRequired(false);
            restrictToArtefactElement.setMandatory(true);
            if (restriction != null && StringHelper.containsNonWhitespace(restriction.getArtefactType())) {
                restrictToArtefactElement.select(restriction.getArtefactType(), true);
            }
            String amountStr = "";
            if (restriction != null && restriction.getAmount() > 0) {
                amountStr = Integer.toString(restriction.getAmount());
            }
            final TextElement amountElement = uifactory.addTextElement("collect.restriction.amount." + count, null, 2, amountStr, collectContainer);
            amountElement.setDomReplacementWrapperRequired(false);
            amountElement.setDisplaySize(3);
            StaticTextElement errorElement = uifactory.addStaticTextElement("collect.restriction.error." + count, null, "", collectContainer);
            errorElement.setVisible(false);
            restrictionElements.add(restrictionElement);
            restrictToArtefactElements.add(restrictToArtefactElement);
            amountElements.add(amountElement);
            errorElements.add(errorElement);
            final FormLink addLink = uifactory.addFormLink("collect.restriction.add." + count, "collect.restriction.add", "collect.restriction.add", collectContainer, Link.BUTTON_SMALL);
            addLink.setDomReplacementWrapperRequired(false);
            addLink.setUserObject(restriction);
            final FormLink delLink = uifactory.addFormLink("collect.restriction.del." + count, "collect.restriction.delete", "collect.restriction.delete", collectContainer, Link.BUTTON_SMALL);
            delLink.setDomReplacementWrapperRequired(false);
            delLink.setUserObject(restriction);
            counts.add(Integer.toString(count));
        }
        collectContainer.contextPut("counts", counts);
    }
    if (formLayout.getFormComponent("save") != null) {
        formLayout.remove("save");
    }
    uifactory.addFormSubmitButton("save", formLayout);
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) 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) EPArtefactHandler(org.olat.portfolio.EPArtefactHandler) RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement)

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