Search in sources :

Example 16 with RichTextConfiguration

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

the class InfoMsgForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    msg = uifactory.addRichTextElementForStringData("msg", "infomsg", infomsg, 20, 70, true, staticFolderMgr.getRootContainer(), null, formLayout, ureq.getUserSession(), getWindowControl());
    msg.setMaxLength(1024);
    RichTextConfiguration richTextConfig = msg.getEditorConfiguration();
    // manually enable the source edit button
    richTextConfig.enableCode();
    // allow script tags...
    richTextConfig.setInvalidElements(RichTextConfiguration.INVALID_ELEMENTS_FORM_FULL_VALUE_UNSAVE_WITH_SCRIPT);
    richTextConfig.setExtendedValidElements("script[src,type,defer]");
    // add style buttons to make alert style available
    richTextConfig.setContentCSSFromTheme(getWindowControl().getWindowBackOffice().getWindow().getGuiTheme());
    String path = Settings.getServerContextPath() + "/raw/static/";
    richTextConfig.setLinkBrowserAbsolutFilePath(path);
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    uifactory.addFormSubmitButton("submit", "submit", buttonGroupLayout);
    uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
}
Also used : RichTextConfiguration(org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 17 with RichTextConfiguration

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

the class HTMLEditorController 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(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (fileToLargeError != null) {
        VelocityContainer vc = (VelocityContainer) formLayout.getComponent();
        vc.contextPut("fileToLargeError", fileToLargeError);
    } else {
        htmlElement = uifactory.addRichTextElementForFileData("rtfElement", null, body, -1, -1, baseContainer, fileName, customLinkTreeModel, formLayout, ureq.getUserSession(), getWindowControl());
        // 
        // Add resize handler
        RichTextConfiguration editorConfiguration = htmlElement.getEditorConfiguration();
        editorConfiguration.addOnInitCallbackFunction("b_resizetofit_htmleditor");
        editorConfiguration.enableEditorHeight();
        if (StringHelper.containsNonWhitespace(mediaPath)) {
            editorConfiguration.setFileBrowserUploadRelPath(mediaPath);
        }
        // The buttons
        if (buttonsEnabled) {
            save = uifactory.addFormLink("savebuttontext", formLayout, Link.BUTTON);
            cancel = uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
            saveClose = uifactory.addFormLink("saveandclosebuttontext", formLayout, Link.BUTTON);
        }
        // Add some file metadata
        VelocityContainer vc = (VelocityContainer) formLayout.getComponent();
        metadataVC = createVelocityContainer("metadata");
        vc.put("metadata", metadataVC);
        long lm = fileLeaf.getLastModified();
        metadataVC.contextPut("lastModified", Formatter.getInstance(ureq.getLocale()).formatDateAndTime(new Date(lm)));
        metadataVC.contextPut("charSet", charSet);
        metadataVC.contextPut("fileName", fileName);
    }
}
Also used : RichTextConfiguration(org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration) Date(java.util.Date) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 18 with RichTextConfiguration

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

the class HTMLEditorControllerWithoutFile 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(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    htmlElement = uifactory.addRichTextElementForStringData("rtfElement", null, body, -1, -1, true, baseContainer, customLinkTreeModel, formLayout, ureq.getUserSession(), getWindowControl());
    // Add resize handler
    RichTextConfiguration editorConfiguration = htmlElement.getEditorConfiguration();
    editorConfiguration.addOnInitCallbackFunction("b_resizetofit_htmleditor");
    editorConfiguration.enableEditorHeight();
    // The buttons
    save = uifactory.addFormLink("savebuttontext", formLayout, Link.BUTTON);
    save.addActionListener(FormEvent.ONCLICK);
    cancel = uifactory.addFormLink("cancel", formLayout, Link.BUTTON);
    cancel.addActionListener(FormEvent.ONCLICK);
    saveClose = uifactory.addFormLink("saveandclosebuttontext", formLayout, Link.BUTTON);
    saveClose.setVisible(false);
}
Also used : RichTextConfiguration(org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration)

Example 19 with RichTextConfiguration

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

the class MaterialFormController 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(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    richText = uifactory.addRichTextElementForStringData("mce", null, htmlContent, 14, -1, true, qtiPackage.getBaseDir(), null, formLayout, ureq.getUserSession(), getWindowControl());
    richText.getEditorConfiguration().setFigCaption(false);
    RichTextConfiguration richTextConfig = richText.getEditorConfiguration();
    // disable <p> element for enabling vertical layouts
    richTextConfig.disableRootParagraphElement();
    // set upload dir to the media dir
    richTextConfig.setFileBrowserUploadRelPath("media");
    // manually enable the source edit button
    richTextConfig.enableCode();
    // allow script tags...
    richTextConfig.setInvalidElements(RichTextConfiguration.INVALID_ELEMENTS_FORM_FULL_VALUE_UNSAVE_WITH_SCRIPT);
    richTextConfig.setExtendedValidElements("script[src|type|defer]");
    uifactory.addFormSubmitButton("submit", formLayout);
}
Also used : RichTextConfiguration(org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration)

Example 20 with RichTextConfiguration

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

the class FIBEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    titleEl = uifactory.addTextElement("title", "form.imd.title", -1, itemBuilder.getTitle(), formLayout);
    titleEl.setElementCssClass("o_sel_assessment_item_title");
    titleEl.setMandatory(true);
    titleEl.setEnabled(!readOnly);
    String relativePath = rootDirectory.toPath().relativize(itemFile.toPath().getParent()).toString();
    VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
    String question = itemBuilder.getQuestion();
    textEl = uifactory.addRichTextElementForQTI21("desc", "form.imd.descr", question, 16, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    textEl.addActionListener(FormEvent.ONCLICK);
    textEl.setElementCssClass("o_sel_assessment_item_fib_text");
    RichTextConfiguration richTextConfig = textEl.getEditorConfiguration();
    richTextConfig.setReadOnly(restrictedEdit || readOnly);
    boolean hasNumericals = itemBuilder.hasNumericalInputs();
    boolean hasTexts = itemBuilder.hasTextEntry();
    if (!hasNumericals && !hasTexts) {
        if (preferredType == QTI21QuestionType.numerical) {
            hasNumericals = true;
            hasTexts = false;
        } else if (preferredType == QTI21QuestionType.fib) {
            hasNumericals = false;
            hasTexts = true;
        } else {
            hasNumericals = true;
            hasTexts = true;
        }
    }
    if (hasNumericals) {
        setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_ni");
    } else {
        setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_fib");
    }
    richTextConfig.enableQTITools(hasTexts, hasNumericals, false);
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setElementCssClass("o_sel_fib_save");
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : RichTextConfiguration(org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration) VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Aggregations

RichTextConfiguration (org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration)20 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)12 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 File (java.io.File)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2 WindowControl (org.olat.core.gui.control.WindowControl)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)2 Control (org.olat.ims.qti.editor.beecom.objects.Control)2 Question (org.olat.ims.qti.editor.beecom.objects.Question)2