Search in sources :

Example 31 with TextElement

use of org.olat.core.gui.components.form.flexible.elements.TextElement 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 32 with TextElement

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

the class CustomfieldsFormController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    // loop over all Element to store values
    for (int i = 0; i < customFields.size(); i++) {
        TextElement nameTextElement = customFieldNameElementList.get(i);
        if (!customFields.get(i).getName().equals(nameTextElement.getValue())) {
            customFields.get(i).setName(nameTextElement.getValue());
        }
        TextElement valueTextElement = customFieldValueElementList.get(i);
        if (!customFields.get(i).getValue().equals(valueTextElement.getValue())) {
            customFields.get(i).setValue(valueTextElement.getValue());
        }
        MultipleSelectionElement tableViewElement = customFieldTableFlagElementList.get(i);
        if (customFields.get(i).isTableViewEnabled() != tableViewElement.isSelected(0)) {
            customFields.get(i).setTableViewEnabled(tableViewElement.isSelected(0));
        }
    }
    config.setCustomFields(customFields);
    fireEvent(ureq, Event.DONE_EVENT);
    fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 33 with TextElement

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

the class CustomfieldsFormController method createFormElemente.

private void createFormElemente(FormItemContainer formLayout, int i, CustomField customField) {
    TextElement nameElement = uifactory.addTextElement("customfield_name_" + i, "-", 50, customField.getName(), formLayout);
    nameElement.setLabel("customfield.name.label", null);
    if (i == 0)
        nameElement.setExampleKey("customfield.example.name", null);
    customFieldNameElementList.add(nameElement);
    TextElement valueElement = uifactory.addTextAreaElement("customfield_value_" + i, "-", 2500, 5, 2, true, customField.getValue(), formLayout);
    valueElement.setLabel("customfield.value.label", null);
    if (i == 0)
        valueElement.setExampleKey("customfield.example.value", null);
    customFieldValueElementList.add(valueElement);
    MultipleSelectionElement tableEnabledElement = uifactory.addCheckboxesHorizontal("customfield.table.enabled." + i, null, formLayout, keys, values);
    tableEnabledElement.select(keys[0], customField.isTableViewEnabled());
    customFieldTableFlagElementList.add(tableEnabledElement);
    FormLink deleteLink = uifactory.addFormLink("customfield.delete.link." + i, formLayout, Link.BUTTON_SMALL);
    deleteLink.setUserObject(new Integer(i));
    customFieldLinkElementList.add(deleteLink);
    SpacerElement spacerElement = uifactory.addSpacerElement("spacer" + i, formLayout, false);
    customFieldSpacerElementList.add(spacerElement);
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) SpacerElement(org.olat.core.gui.components.form.flexible.elements.SpacerElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 34 with TextElement

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

the class ProjectEditDetailsFormController method initForm.

/**
 * Initialize form.
 */
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // create form elements
    projectTitle = uifactory.addTextElement("title", "detailsform.title.label", 100, project.getTitle(), formLayout);
    // account-Managers
    StringBuilder projectLeaderString = new StringBuilder();
    for (Iterator<Identity> iterator = project.getProjectLeaders().iterator(); iterator.hasNext(); ) {
        Identity identity = iterator.next();
        String last = identity.getUser().getProperty(UserConstants.LASTNAME, getLocale());
        String first = identity.getUser().getProperty(UserConstants.FIRSTNAME, getLocale());
        if (projectLeaderString.length() > 0) {
            projectLeaderString.append(",");
        }
        projectLeaderString.append(first);
        projectLeaderString.append(" ");
        projectLeaderString.append(last);
    }
    projectLeaders = uifactory.addTextElement("projectleaders", "detailsform.projectleaders.label", 100, projectLeaderString.toString(), formLayout);
    projectLeaders.setEnabled(false);
    // add the learning objectives rich text input element
    projectDescription = uifactory.addRichTextElementForStringData("description", "detailsform.description.label", project.getDescription(), 10, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl());
    projectDescription.setMaxLength(2500);
    stateLayout = FormLayoutContainer.createHorizontalFormLayout("stateLayout", getTranslator());
    stateLayout.setLabel("detailsform.state.label", null);
    formLayout.add(stateLayout);
    String stateValue = getTranslator().translate(projectBrokerManager.getStateFor(project, ureq.getIdentity(), projectBrokerModuleConfiguration));
    projectState = uifactory.addStaticTextElement("detailsform.state", stateValue + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", stateLayout);
    projectState.setLabel(null, null);
    String keyDetailsformMax = null;
    if (projectBrokerModuleConfiguration.isAcceptSelectionManually()) {
        keyDetailsformMax = "detailsform.max.candidates.label";
    } else {
        keyDetailsformMax = "detailsform.max.members.label";
    }
    selectionMaxMembers = uifactory.addCheckboxesHorizontal(keyDetailsformMax, formLayout, keys, values);
    maxMembers = uifactory.addIntegerElement("form.options.number.of.participants.per.topic_nbr", project.getMaxMembers(), formLayout);
    maxMembers.setMinValueCheck(0, null);
    maxMembers.setDisplaySize(3);
    if (project.getMaxMembers() == Project.MAX_MEMBERS_UNLIMITED) {
        maxMembers.setVisible(false);
        selectionMaxMembers.select(keys[0], false);
    } else {
        selectionMaxMembers.select(keys[0], true);
    }
    selectionMaxMembers.addActionListener(FormEvent.ONCLICK);
    String[] deselectValues = new String[] { translate("detailsform.allow.deselection.hint") };
    allowDeselection = uifactory.addCheckboxesHorizontal("detailsform.allow.deselection", formLayout, keys, deselectValues);
    allowDeselection.select(keys[0], projectGroupManager.isDeselectionAllowed(project));
    allowDeselection.addActionListener(FormEvent.ONCLICK);
    uifactory.addSpacerElement("spacer_1", formLayout, false);
    // customfields
    List<CustomField> customFields = projectBrokerModuleConfiguration.getCustomFields();
    int customFieldIndex = 0;
    for (Iterator<CustomField> iterator = customFields.iterator(); iterator.hasNext(); ) {
        CustomField customField = iterator.next();
        getLogger().debug("customField: " + customField.getName() + "=" + customField.getValue());
        StringTokenizer tok = new StringTokenizer(customField.getValue(), ProjectBrokerManager.CUSTOMFIELD_LIST_DELIMITER);
        if (customField.getValue() == null || customField.getValue().equals("") || !tok.hasMoreTokens()) {
            // no value define => Text-input
            // Add StaticTextElement as workaroung for non translated label
            // null > no label
            uifactory.addStaticTextElement("customField_label" + customFieldIndex, null, customField.getName(), formLayout);
            TextElement textElement = uifactory.addTextElement("customField_" + customFieldIndex, "", 150, project.getCustomFieldValue(customFieldIndex), formLayout);
            textElement.setDisplaySize(60);
            // textElement.setTranslator(null);
            // textElement.setLabel(customField.getName(), null);
            textElement.showLabel(false);
            customfieldElementList.add(textElement);
        } else {
            // values define => dropdown selection
            List<String> valueList = new ArrayList<String>();
            while (tok.hasMoreTokens()) {
                String value = tok.nextToken();
                valueList.add(value);
                getLogger().debug("valueList add: " + value);
            }
            String[] theValues = new String[valueList.size() + 1];
            String[] theKeys = new String[valueList.size() + 1];
            int arrayIndex = 0;
            theValues[arrayIndex] = translate(DROPDOWN_NO_SELECETION);
            theKeys[arrayIndex] = DROPDOWN_NO_SELECETION;
            arrayIndex++;
            for (Iterator<String> iterator2 = valueList.iterator(); iterator2.hasNext(); ) {
                String value = iterator2.next();
                theValues[arrayIndex] = value;
                theKeys[arrayIndex] = Integer.toString(arrayIndex);
                arrayIndex++;
            }
            // Add StaticTextElement as workaround for non translated label
            // null > no label
            uifactory.addStaticTextElement("customField_label" + customFieldIndex, null, customField.getName(), formLayout);
            SingleSelection selectionElement = uifactory.addDropdownSingleselect("customField_" + customFieldIndex, null, formLayout, theKeys, theValues, null);
            if (project.getCustomFieldValue(customFieldIndex) != null && !project.getCustomFieldValue(customFieldIndex).equals("")) {
                if (valueList.contains(project.getCustomFieldValue(customFieldIndex))) {
                    // '+1' because no-selection at the beginning
                    String key = Integer.toString(valueList.indexOf(project.getCustomFieldValue(customFieldIndex)) + 1);
                    selectionElement.select(key, true);
                } else {
                    this.showInfo("warn.customfield.key.does.not.exist", project.getCustomFieldValue(customFieldIndex));
                }
            }
            customfieldElementList.add(selectionElement);
        }
        uifactory.addSpacerElement("customField_spacer" + customFieldIndex, formLayout, false);
        customFieldIndex++;
    }
    // Events
    for (Project.EventType eventType : Project.EventType.values()) {
        if (projectBrokerModuleConfiguration.isProjectEventEnabled(eventType)) {
            ProjectEvent projectEvent = project.getProjectEvent(eventType);
            DateChooser dateChooserStart = uifactory.addDateChooser(eventType + "start", eventType.getI18nKey() + ".start.label", null, formLayout);
            dateChooserStart.setDateChooserTimeEnabled(true);
            dateChooserStart.setDisplaySize(CUSTOM_DATE_FORMAT.length());
            getLogger().info("Event=" + eventType + ", startDate=" + projectEvent.getStartDate());
            dateChooserStart.setDate(projectEvent.getStartDate());
            eventStartElementList.put(eventType, dateChooserStart);
            DateChooser dateChooserEnd = uifactory.addDateChooser(eventType + "end", eventType.getI18nKey() + ".end.label", null, formLayout);
            dateChooserEnd.setDateChooserTimeEnabled(true);
            dateChooserEnd.setDisplaySize(CUSTOM_DATE_FORMAT.length());
            getLogger().debug("Event=" + eventType + ", endDate=" + projectEvent.getEndDate());
            dateChooserEnd.setDate(projectEvent.getEndDate());
            eventEndElementList.put(eventType, dateChooserEnd);
            uifactory.addSpacerElement(eventType + "spacer", formLayout, false);
        }
    }
    attachmentFileName = uifactory.addFileElement(getWindowControl(), "detailsform.attachmentfilename.label", formLayout);
    attachmentFileName.setLabel("detailsform.attachmentfilename.label", null);
    if (project.getAttachmentFileName() != null && !project.getAttachmentFileName().equals("")) {
        attachmentFileName.setInitialFile(new File(project.getAttachmentFileName()));
        removeAttachmentLink = uifactory.addFormLink("detailsform.remove.attachment", formLayout, Link.BUTTON_XSMALL);
    }
    attachmentFileName.addActionListener(FormEvent.ONCHANGE);
    mailNotification = uifactory.addCheckboxesHorizontal("detailsform.mail.notification.label", formLayout, keys, values);
    mailNotification.select(keys[0], project.isMailNotificationEnabled());
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    uifactory.addFormSubmitButton("save", buttonGroupLayout);
    if (this.enableCancel) {
        // TODO: Frage an PB: Warum flc hier noetig ???
        uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
    }
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Project(org.olat.course.nodes.projectbroker.datamodel.Project) StringTokenizer(java.util.StringTokenizer) 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) CustomField(org.olat.course.nodes.projectbroker.datamodel.CustomField) DateChooser(org.olat.core.gui.components.form.flexible.elements.DateChooser) Identity(org.olat.core.id.Identity) File(java.io.File) ProjectEvent(org.olat.course.nodes.projectbroker.datamodel.ProjectEvent)

Example 35 with TextElement

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

the class BinderAssessmentController method forgeAssessmentSection.

private void forgeAssessmentSection(AssessmentSectionWrapper row) {
    AssessmentSection assessmentSection = row.getAssessmentSection();
    Section section = row.getSection();
    if (!SectionStatus.isClosed(section)) {
        // score
        String pointVal = null;
        if (assessmentSection != null && assessmentSection.getScore() != null) {
            BigDecimal score = assessmentSection.getScore();
            pointVal = AssessmentHelper.getRoundedScore(score);
        }
        TextElement pointEl = uifactory.addTextElement("point" + (++counter), null, 5, pointVal, flc);
        pointEl.setDisplaySize(5);
        row.setScoreEl(pointEl);
        // passed
        Boolean passed = assessmentSection == null ? null : assessmentSection.getPassed();
        MultipleSelectionElement passedEl = uifactory.addCheckboxesHorizontal("check" + (++counter), null, flc, onKeys, onValues);
        if (passed != null && passed.booleanValue()) {
            passedEl.select(onKeys[0], passed.booleanValue());
        }
        row.setPassedEl(passedEl);
    }
    if (SectionStatus.isClosed(section)) {
        FormLink reopenButton = uifactory.addFormLink("reopen" + (++counter), "reopen", "reopen", null, flc, Link.BUTTON);
        reopenButton.setElementCssClass("o_sel_pf_reopen_section");
        reopenButton.setUserObject(row);
        row.setButton(reopenButton);
    } else {
        FormLink closeButton = uifactory.addFormLink("close" + (++counter), "close", "close.section", null, flc, Link.BUTTON);
        closeButton.setElementCssClass("o_sel_pf_close_section");
        closeButton.setUserObject(row);
        row.setButton(closeButton);
    }
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) BigDecimal(java.math.BigDecimal)

Aggregations

TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)146 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)40 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)36 FormItem (org.olat.core.gui.components.form.flexible.FormItem)34 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)30 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)26 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)24 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)18 ArrayList (java.util.ArrayList)16 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)16 Identity (org.olat.core.id.Identity)12 HashMap (java.util.HashMap)8 FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)8 EmailProperty (org.olat.user.propertyhandlers.EmailProperty)8 Date (java.util.Date)6 DateChooser (org.olat.core.gui.components.form.flexible.elements.DateChooser)6 StaticTextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.StaticTextElementImpl)6 TextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.TextElementImpl)6 RichTextElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl)6 File (java.io.File)4