use of org.olat.core.gui.components.form.flexible.FormItemContainer in project openolat by klemens.
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 klemens.
the class MediaDetailsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("title", StringHelper.escapeHtml(media.getTitle()));
layoutCont.contextPut("description", StringHelper.xssScan(media.getDescription()));
layoutCont.contextPut("iconCssClass", handler.getIconCssClass(media));
mediaCtrl = handler.getMediaController(ureq, getWindowControl(), media, new StandardMediaRenderingHints());
if (mediaCtrl != null) {
listenTo(mediaCtrl);
layoutCont.put("media", mediaCtrl.getInitialComponent());
}
String metaPage = velocity_root + "/media_details_metadata.html";
FormLayoutContainer metaCont = FormLayoutContainer.createCustomFormLayout("meta", getTranslator(), metaPage);
layoutCont.add("meta", metaCont);
metaCont.setRootForm(mainForm);
metaCont.contextPut("media", media);
String author = userManager.getUserDisplayName(media.getAuthor());
metaCont.contextPut("author", author);
if (media.getCollectionDate() != null) {
String collectionDate = Formatter.getInstance(getLocale()).formatDate(media.getCollectionDate());
metaCont.contextPut("collectionDate", collectionDate);
}
if (media.getBusinessPath() != null) {
gotoOriginalLink = LinkFactory.createLink("goto.original", metaCont.getFormItemComponent(), this);
}
if (StringHelper.containsNonWhitespace(media.getMetadataXml())) {
Object metadata = MetadataXStream.get().fromXML(media.getMetadataXml());
metaCont.contextPut("metadata", metadata);
}
List<Category> categories = portfolioService.getCategories(media);
if (categories != null && categories.size() > 0) {
Map<String, String> categoriesMap = categories.stream().collect(Collectors.toMap(c -> c.getName(), c -> c.getName()));
TextBoxListElement categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categoriesMap, metaCont, getTranslator());
categoriesEl.setHelpText(translate("categories.hint"));
categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
categoriesEl.setEnabled(false);
}
List<FormLink> binderLinks = new ArrayList<>(usedInList.size());
Set<Long> binderUniqueKeys = new HashSet<>();
for (BinderPageUsage binder : usedInList) {
if (binderUniqueKeys.contains(binder.getBinderKey()))
continue;
FormLink link;
if (binder.getBinderKey() == null) {
link = uifactory.addFormLink("binder_" + (++counter), "page", binder.getPageTitle(), null, metaCont, Link.LINK | Link.NONTRANSLATED);
binderUniqueKeys.add(binder.getPageKey());
} else {
link = uifactory.addFormLink("binder_" + (++counter), "binder", binder.getBinderTitle(), null, metaCont, Link.LINK | Link.NONTRANSLATED);
binderUniqueKeys.add(binder.getBinderKey());
}
link.setUserObject(binder);
binderLinks.add(link);
}
metaCont.contextPut("binderLinks", binderLinks);
}
}
use of org.olat.core.gui.components.form.flexible.FormItemContainer in project openolat by klemens.
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 klemens.
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);
}
use of org.olat.core.gui.components.form.flexible.FormItemContainer in project openolat by klemens.
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());
}
}
Aggregations