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());
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations