use of org.olat.core.gui.components.form.flexible.elements.RichTextElement in project openolat by klemens.
the class SingleChoiceEditorController method wrapAnswer.
private void wrapAnswer(UserRequest ureq, SimpleChoice choice) {
List<FlowStatic> choiceFlow = choice.getFlowStatics();
String choiceContent = itemBuilder.getHtmlHelper().flowStaticString(choiceFlow);
String choiceId = "answer" + count++;
RichTextElement choiceEl = uifactory.addRichTextElementForQTI21(choiceId, "form.imd.answer", choiceContent, 8, -1, itemContainer, answersCont, ureq.getUserSession(), getWindowControl());
choiceEl.setEnabled(!readOnly);
choiceEl.setVisible(!readOnly);
choiceEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
choiceEl.setUserObject(choice);
answersCont.add("choiceId", choiceEl);
String choiceRoId = "answerro" + count++;
FlowFormItem choiceReadOnlyEl = new FlowFormItem(choiceRoId, itemFile);
choiceReadOnlyEl.setFlowStatics(choiceFlow);
choiceReadOnlyEl.setMapperUri(mapperUri);
answersCont.add(choiceRoId, choiceReadOnlyEl);
FormLink removeLink = uifactory.addFormLink("rm-".concat(choiceId), "rm", "", null, answersCont, Link.NONTRANSLATED);
removeLink.setIconLeftCSS("o_icon o_icon-lg o_icon_delete");
removeLink.setEnabled(!restrictedEdit && !readOnly);
answersCont.add(removeLink);
answersCont.add("rm-".concat(choiceId), removeLink);
FormLink addLink = uifactory.addFormLink("add-".concat(choiceId), "add", "", null, answersCont, Link.NONTRANSLATED);
addLink.setIconLeftCSS("o_icon o_icon-lg o_icon_add");
addLink.setEnabled(!restrictedEdit && !readOnly);
answersCont.add(addLink);
answersCont.add("add-".concat(choiceId), addLink);
FormLink upLink = uifactory.addFormLink("up-".concat(choiceId), "up", "", null, answersCont, Link.NONTRANSLATED);
upLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_up");
upLink.setEnabled(!restrictedEdit && !readOnly);
answersCont.add(upLink);
answersCont.add("up-".concat(choiceId), upLink);
FormLink downLink = uifactory.addFormLink("down-".concat(choiceId), "down", "", null, answersCont, Link.NONTRANSLATED);
downLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_down");
downLink.setEnabled(!restrictedEdit && !readOnly);
answersCont.add(downLink);
answersCont.add("down-".concat(choiceId), downLink);
choiceWrappers.add(new SimpleChoiceWrapper(choice, choiceEl, choiceReadOnlyEl, removeLink, addLink, upLink, downLink));
}
use of org.olat.core.gui.components.form.flexible.elements.RichTextElement in project openolat by klemens.
the class TrueFalseEditorController method wrapSource.
private void wrapSource(UserRequest ureq, SimpleAssociableChoice choice, List<SourceWrapper> wrappers) {
List<FlowStatic> choiceFlow = choice.getFlowStatics();
String choiceContent = itemBuilder.getHtmlHelper().flowStaticString(choiceFlow);
String choiceId = "answer" + count++;
RichTextElement choiceEl = uifactory.addRichTextElementForQTI21Match(choiceId, "form.imd.answer", choiceContent, 4, -1, itemContainer, answersCont, ureq.getUserSession(), getWindowControl());
choiceEl.setUserObject(choice);
choiceEl.setEnabled(!readOnly);
choiceEl.setVisible(!readOnly);
answersCont.add("choiceId", choiceEl);
String choiceRoId = "answerro" + count++;
FlowFormItem choiceReadOnlyEl = new FlowFormItem(choiceRoId, itemFile);
choiceReadOnlyEl.setFlowStatics(choiceFlow);
choiceReadOnlyEl.setMapperUri(mapperUri);
answersCont.add(choiceRoId, choiceReadOnlyEl);
FormLink deleteButton = uifactory.addFormLink("del_" + (count++), "delete", "delete", null, answersCont, Link.NONTRANSLATED);
deleteButton.setIconLeftCSS("o_icon o_icon_delete_item");
deleteButton.setVisible(!restrictedEdit && !readOnly);
deleteButton.setI18nKey("");
SourceWrapper wrapper = new SourceWrapper(choice, choiceEl, choiceReadOnlyEl, deleteButton);
deleteButton.setUserObject(wrapper);
wrappers.add(wrapper);
}
use of org.olat.core.gui.components.form.flexible.elements.RichTextElement in project openolat by klemens.
the class KPrimEditorController method wrapAnswer.
private void wrapAnswer(UserRequest ureq, SimpleAssociableChoice choice) {
List<FlowStatic> choiceFlow = choice.getFlowStatics();
String choiceContent = itemBuilder.getHtmlHelper().flowStaticString(choiceFlow);
String choiceId = "answer" + count++;
RichTextElement choiceEl = uifactory.addRichTextElementForQTI21(choiceId, "form.imd.answer", choiceContent, 8, -1, itemContainer, answersCont, ureq.getUserSession(), getWindowControl());
choiceEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
choiceEl.setUserObject(choice);
choiceEl.setEnabled(!readOnly);
choiceEl.setVisible(!readOnly);
answersCont.add("choiceId", choiceEl);
String choiceRoId = "answerro" + count++;
FlowFormItem choiceReadOnlyEl = new FlowFormItem(choiceRoId, itemFile);
choiceReadOnlyEl.setFlowStatics(choiceFlow);
choiceReadOnlyEl.setMapperUri(mapperUri);
answersCont.add(choiceRoId, choiceReadOnlyEl);
FormLink upLink = uifactory.addFormLink("up-".concat(choiceId), "up", "", null, answersCont, Link.NONTRANSLATED);
upLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_up");
upLink.setEnabled(!restrictedEdit && !readOnly);
answersCont.add(upLink);
answersCont.add("up-".concat(choiceId), upLink);
FormLink downLink = uifactory.addFormLink("down-".concat(choiceId), "down", "", null, answersCont, Link.NONTRANSLATED);
downLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_down");
downLink.setEnabled(!restrictedEdit && !readOnly);
answersCont.add(downLink);
answersCont.add("down-".concat(choiceId), downLink);
choiceWrappers.add(new KprimWrapper(choice, choiceEl, choiceReadOnlyEl, upLink, downLink));
}
use of org.olat.core.gui.components.form.flexible.elements.RichTextElement 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));
}
use of org.olat.core.gui.components.form.flexible.elements.RichTextElement in project OpenOLAT by OpenOLAT.
the class FormUIFactory method addRichTextElementForQTI21Match.
public RichTextElement addRichTextElementForQTI21Match(String name, String i18nLabel, String initialHTMLValue, int rows, int cols, VFSContainer baseContainer, FormItemContainer formLayout, UserSession usess, WindowControl wControl) {
// Create rich text element with bare bone configuration
RichTextElement rte = new RichTextElementImpl(name, initialHTMLValue, rows, cols, formLayout.getRootForm(), formLayout.getTranslator().getLocale());
setLabelIfNotNull(i18nLabel, rte);
// Now configure editor
Theme theme = wControl.getWindowBackOffice().getWindow().getGuiTheme();
rte.getEditorConfiguration().setConfigProfileFormVeryMinimalisticConfigEditor(usess, theme, baseContainer);
rte.getEditorConfiguration().setInvalidElements(RichTextConfiguration.INVALID_ELEMENTS_FORM_FULL_VALUE_UNSAVE_WITH_SCRIPT);
rte.getEditorConfiguration().setExtendedValidElements("script[src|type|defer]");
rte.getEditorConfiguration().disableTinyMedia();
rte.getEditorConfiguration().setFilenameUriValidation(true);
rte.getEditorConfiguration().setFigCaption(false);
// Add to form and finish
formLayout.add(rte);
return rte;
}
Aggregations