Search in sources :

Example 76 with TextElement

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

the class AttributeEasyRowAdderController method updateValueElementForAttribute.

/**
 * Internal method to update a row's value element. This can be a text input box or a selection drop down depending on the shibboleth module configuration and the selected attribute. The method
 * will set the given value as the users selected / inputed value
 *
 * @param attribute The attribute key. Must not be NULL
 * @param row the row ID
 * @param value The value that should be selected / used in the text input field. Can be NULL.
 */
private void updateValueElementForAttribute(final String attribute, final int row, final String value) {
    String[] selectableKeys = getSelectableKeys(attribute);
    // Get the value text input and selection drop down form elements for this
    // row. Don't use the element name since there we have the global row
    // counter in the name and _not_ the current row id!
    final SingleSelection iselect = (SingleSelection) flc.getFormComponent(columnValueSelection.get(row));
    final TextElement tei = (TextElement) flc.getFormComponent(columnValueText.get(row));
    if (selectableKeys.length > 0) {
        attributeAsSelectBox(attribute, value, selectableKeys, iselect, tei);
    } else {
        attributeAsTextField(value, iselect, tei);
    }
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection)

Example 77 with TextElement

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

the class AttributeEasyRowAdderController method getAttributeConditions.

/**
 * Method to get a list of extended conditions represented in this form
 *
 * @return
 */
public List<ExtendedCondition> getAttributeConditions() {
    final List<ExtendedCondition> le = new ArrayList<ExtendedCondition>();
    for (final Iterator<String> iterator = columnAttribute.iterator(); iterator.hasNext(); ) {
        final String aname = iterator.next();
        final String row = aname.replace(PRE_ATTRIBUTE, "");
        final SingleSelection attribute = (SingleSelection) flc.getFormComponent(PRE_ATTRIBUTE + row);
        final String condName = attribute.getSelectedKey();
        final SingleSelection operator = (SingleSelection) flc.getFormComponent(PRE_OPERATOR + row);
        final String condOperator = operator.getSelectedKey();
        String condValue = "";
        final SingleSelection valuessi = (SingleSelection) flc.getFormComponent(PRE_VALUE_SELECTION + row);
        if (valuessi.isVisible()) {
            if (valuessi.isOneSelected()) {
                condValue = valuessi.getSelectedKey();
            } else {
                // user did not actively select one, maybe because the first one was already the one he wanted. Use this one
                condValue = valuessi.getKey(0);
            }
        } else {
            final TextElement valuetei = (TextElement) flc.getFormComponent(PRE_VALUE_TEXT + row);
            condValue = valuetei.getValue();
        }
        le.add(new ExtendedCondition(condName, condOperator, condValue));
    }
    return le;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) ArrayList(java.util.ArrayList)

Example 78 with TextElement

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

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 79 with TextElement

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

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 80 with TextElement

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

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)

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