use of org.olat.core.gui.components.form.flexible.FormItemContainer in project openolat by klemens.
the class TrueFalseEditorController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FormLayoutContainer metadata = FormLayoutContainer.createDefaultFormLayout("metadata", getTranslator());
if (itemBuilder.getQuestionType() == QTI21QuestionType.matchdraganddrop) {
metadata.setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_draganddrop");
} else {
metadata.setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_match");
}
metadata.setRootForm(mainForm);
formLayout.add(metadata);
formLayout.add("metadata", metadata);
titleEl = uifactory.addTextElement("title", "form.imd.title", -1, itemBuilder.getTitle(), metadata);
titleEl.setElementCssClass("o_sel_assessment_item_title");
titleEl.setMandatory(true);
titleEl.setEnabled(!readOnly);
String description = itemBuilder.getQuestion();
textEl = uifactory.addRichTextElementForQTI21("desc", "form.imd.descr", description, 8, -1, itemContainer, metadata, ureq.getUserSession(), getWindowControl());
textEl.setEnabled(!readOnly);
textEl.setVisible(!readOnly);
if (readOnly) {
FlowFormItem textReadOnlyEl = new FlowFormItem("descro", itemFile);
textReadOnlyEl.setLabel("form.imd.descr", null);
textReadOnlyEl.setBlocks(itemBuilder.getQuestionBlocks());
textReadOnlyEl.setMapperUri(mapperUri);
metadata.add(textReadOnlyEl);
}
// responses
String page = velocity_root + "/match_truefalse.html";
answersCont = FormLayoutContainer.createCustomFormLayout("answers", getTranslator(), page);
answersCont.setRootForm(mainForm);
answersCont.contextPut("showHeaders", (itemBuilder.getQuestionType() == QTI21QuestionType.matchdraganddrop));
formLayout.add(answersCont);
formLayout.add("answers", answersCont);
MatchInteraction interaction = itemBuilder.getMatchInteraction();
if (interaction != null) {
List<SimpleAssociableChoice> sourceChoices = itemBuilder.getSourceChoices();
for (SimpleAssociableChoice sourceChoice : sourceChoices) {
wrapSource(ureq, sourceChoice, sourceWrappers);
}
List<TargetWrapper> targetChoices = itemBuilder.getTargetChoices().stream().map(c -> new TargetWrapper(c)).collect(Collectors.toList());
answersCont.contextPut("targetChoices", targetChoices);
}
answersCont.contextPut("sourceChoices", sourceWrappers);
answersCont.contextPut("restrictedEdit", restrictedEdit || readOnly);
answersCont.contextPut("responseIdentifier", itemBuilder.getResponseIdentifier());
int maxAssociations = itemBuilder.getMatchInteraction().getMaxAssociations();
answersCont.contextPut("interactionMaxAssociations", maxAssociations);
JSAndCSSFormItem js = new JSAndCSSFormItem("js", new String[] { "js/jquery/qti/jquery.match.js" });
formLayout.add(js);
if (!readOnly) {
uifactory.addFormSubmitButton("submit", answersCont);
}
if (!restrictedEdit && !readOnly) {
addRowButton = uifactory.addFormLink("add.match.row", answersCont, Link.BUTTON);
addRowButton.setElementCssClass("o_sel_match_add_row");
addRowButton.setIconLeftCSS("o_icon o_icon_add");
}
}
use of org.olat.core.gui.components.form.flexible.FormItemContainer in project OpenOLAT by OpenOLAT.
the class SearchInputController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
searchClient = (SearchClient) CoreSpringFactory.getBean("searchClient");
FormItemContainer searchLayout = formLayout;
if (displayOption.equals(DisplayOption.STANDARD) || displayOption.equals(DisplayOption.STANDARD_TEXT)) {
searchLayout = FormLayoutContainer.createInputGroupLayout("searchWrapper", getTranslator(), null, null);
formLayout.add(searchLayout);
searchInput = uifactory.addTextElement("search_input", "search.title", 255, "", searchLayout);
searchInput.setLabel(null, null);
searchInput.setPlaceholderKey("search", null);
searchInput.setFocus(true);
}
if (displayOption.equals(DisplayOption.STANDARD) || displayOption.equals(DisplayOption.BUTTON)) {
searchButton = uifactory.addFormLink("rightAddOn", "", "", searchLayout, Link.NONTRANSLATED);
searchButton.setIconLeftCSS("o_icon o_icon-fw o_icon_search o_icon-lg");
String searchLabel = getTranslator().translate("search");
searchButton.setLinkTitle(searchLabel);
} else if (displayOption.equals(DisplayOption.BUTTON_WITH_LABEL)) {
searchButton = uifactory.addFormLink("rightAddOn", searchLayout, Link.BUTTON_SMALL);
} else if (displayOption.equals(DisplayOption.STANDARD_TEXT)) {
String searchLabel = getTranslator().translate("search");
searchButton = uifactory.addFormLink("rightAddOn", searchLabel, "", searchLayout, Link.NONTRANSLATED + Link.BUTTON_SMALL);
searchButton.setIconLeftCSS("o_icon o_icon-fw o_icon_search o_icon-lg");
}
searchButton.setCustomEnabledLinkCSS("o_search");
searchButton.setEnabled(true);
}
use of org.olat.core.gui.components.form.flexible.FormItemContainer in project OpenOLAT by OpenOLAT.
the class MediaCenterController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (select) {
newMediaCallout = uifactory.addFormLink("new.medias", formLayout, Link.BUTTON);
newMediaCallout.setIconRightCSS("o_icon o_icon_caret o_icon-fw");
}
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, MediaCols.key, "select"));
Map<String, MediaHandler> handlersMap = portfolioService.getMediaHandlers().stream().collect(Collectors.toMap(h -> h.getType(), h -> h));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MediaCols.type, new MediaTypeCellRenderer(handlersMap)));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MediaCols.title, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MediaCols.collectionDate, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(MediaCols.categories, new CategoriesCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select"));
model = new MediaDataModel(columnsModel, getLocale());
tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
tableEl.setAvailableRendererTypes(FlexiTableRendererType.custom, FlexiTableRendererType.classic);
tableEl.setRendererType(FlexiTableRendererType.custom);
tableEl.setSearchEnabled(true);
tableEl.setCustomizeColumns(true);
tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
tableEl.setPageSize(24);
VelocityContainer row = createVelocityContainer("media_row");
// sets its own DOM id in velocity container
row.setDomReplacementWrapperRequired(false);
tableEl.setRowRenderer(row, this);
tableEl.setCssDelegate(new MediaCssDelegate());
tableEl.setAndLoadPersistedPreferences(ureq, "media-list");
initSorters(tableEl);
initFilters(tableEl);
mapperThumbnailUrl = registerCacheableMapper(ureq, "media-thumbnail", new ThumbnailMapper(model));
row.contextPut("mapperThumbnailUrl", mapperThumbnailUrl);
}
use of org.olat.core.gui.components.form.flexible.FormItemContainer in project OpenOLAT by OpenOLAT.
the class FileUploadController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// Trigger fieldset and title
if (showTitle) {
setFormTitle("ul.header");
}
flc.contextPut("showMetadata", showMetadata);
// Add file element
FormItemContainer fileUpload;
// shown, align the file upload element
if (showMetadata) {
fileUpload = FormLayoutContainer.createDefaultFormLayout("file_upload", getTranslator());
} else {
fileUpload = FormLayoutContainer.createVerticalFormLayout("file_upload", getTranslator());
}
formLayout.add(fileUpload);
flc.contextPut("resizeImg", resizeImg);
// Add path element
if (showTargetPath) {
String path = "/ " + StringHelper.escapeHtml(uploadVFSContainer.getName());
VFSContainer container = uploadVFSContainer.getParentContainer();
while (container != null) {
path = "/ " + StringHelper.escapeHtml(container.getName()) + " " + path;
container = container.getParentContainer();
}
pathEl = uifactory.addStaticTextElement("ul.target", path, fileUpload);
if (subfolderPath != null) {
targetSubPath = uifactory.addInlineTextElement("ul.target.child", subfolderPath, fileUpload, this);
targetSubPath.setLabel("ul.target.child", null);
}
}
fileEl = uifactory.addFileElement(getWindowControl(), "fileEl", "ul.file", fileUpload);
fileEl.addActionListener(FormEvent.ONCHANGE);
setMaxUploadSizeKB((uploadLimitKB < remainingQuotKB ? uploadLimitKB : remainingQuotKB));
fileEl.setMandatory(true, "NoFileChoosen");
if (mimeTypes != null && mimeTypes.size() > 0) {
fileEl.limitToMimeType(mimeTypes, "WrongMimeType", new String[] { mimeTypes.toString() });
}
if (resizeImg) {
FormLayoutContainer resizeCont;
if (showMetadata) {
resizeCont = FormLayoutContainer.createDefaultFormLayout("resize_image_wrapper", getTranslator());
} else {
resizeCont = FormLayoutContainer.createVerticalFormLayout("resize_image_wrapper", getTranslator());
}
formLayout.add(resizeCont);
String[] values = new String[] { translate("resize_image") };
resizeEl = uifactory.addCheckboxesHorizontal("resize_image", resizeCont, resizeKeys, values);
resizeEl.setLabel(null, null);
resizeEl.select(resizeKeys[0], true);
resizeEl.setVisible(false);
}
// Check remaining quota
if (remainingQuotKB == 0) {
fileEl.setEnabled(false);
getWindowControl().setError(translate("QuotaExceeded"));
}
if (showMetadata) {
metaDataCtr = new MetaInfoFormController(ureq, getWindowControl(), mainForm);
formLayout.add("metadata", metaDataCtr.getFormItem());
listenTo(metaDataCtr);
}
// Add cancel and submit in button group layout
FormItemContainer buttons;
if (showMetadata) {
buttons = FormLayoutContainer.createDefaultFormLayout("buttons", getTranslator());
} else {
buttons = FormLayoutContainer.createVerticalFormLayout("buttons", getTranslator());
}
formLayout.add(buttons);
FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
buttons.add(buttonGroupLayout);
buttonGroupLayout.setElementCssClass("o_sel_upload_buttons");
uifactory.addFormSubmitButton("ul.upload", buttonGroupLayout);
if (showCancel) {
uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
}
}
use of org.olat.core.gui.components.form.flexible.FormItemContainer in project OpenOLAT by OpenOLAT.
the class ExportOptionsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
downloadOptionsEl = uifactory.addCheckboxesVertical("setting", "form.title", formLayout, optionKeys, optionVals, 1);
ExportFormat c = FormatConfigHelper.loadExportFormat(ureq);
if (c.isResponseCols()) {
downloadOptionsEl.select(ITEMCOLS, c.isResponseCols());
}
if (c.isPositionsOfResponsesCol()) {
downloadOptionsEl.select(POSCOL, c.isPositionsOfResponsesCol());
}
if (c.isPointCol()) {
downloadOptionsEl.select(POINTCOL, c.isPointCol());
}
if (c.isTimeCols()) {
downloadOptionsEl.select(TIMECOLS, c.isTimeCols());
}
if (c.isCommentCol()) {
downloadOptionsEl.select(COMMENTCOL, c.isCommentCol());
}
FormItemContainer buttonContainer = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
formLayout.add(buttonContainer);
uifactory.addFormCancelButton("cancel", buttonContainer, ureq, getWindowControl());
uifactory.addFormSubmitButton("save", buttonContainer);
}
Aggregations