use of org.olat.core.gui.components.velocity.VelocityContainer in project openolat by klemens.
the class BinderListController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, PortfolioCols.key, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(PortfolioCols.title, "select"));
model = new BindersDataModel(columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
tableEl.setAvailableRendererTypes(FlexiTableRendererType.custom);
tableEl.setRendererType(FlexiTableRendererType.custom);
tableEl.setSearchEnabled(false);
tableEl.setCustomizeColumns(false);
tableEl.setElementCssClass("o_portfolio_listing");
tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
tableEl.setNumOfRowsEnabled(false);
tableEl.setPageSize(24);
VelocityContainer row = createVelocityContainer("binder_row");
// sets its own DOM id in velocity container
row.setDomReplacementWrapperRequired(false);
tableEl.setRowRenderer(row, this);
tableEl.setCssDelegate(new BinderCssDelegate());
tableEl.setAndLoadPersistedPreferences(ureq, getTableId());
mapperThumbnailUrl = registerCacheableMapper(ureq, "binder-list", new ImageMapper(model));
row.contextPut("mapperThumbnailUrl", mapperThumbnailUrl);
if (!portfolioModule.isLearnerCanCreateBinders() && !portfolioModule.isCanCreateBindersFromTemplate() && portfolioModule.isCanCreateBindersFromCourse()) {
newBinderFromCourseButton = uifactory.addFormLink("create.binder.from.course", "create.empty.binder.from.course", null, formLayout, Link.BUTTON);
row.put("createBinderFromCourse", newBinderFromCourseButton.getComponent());
} else if (portfolioModule.isLearnerCanCreateBinders() || portfolioModule.isCanCreateBindersFromTemplate() || portfolioModule.isCanCreateBindersFromCourse()) {
newBinderDropdown = uifactory.addFormLink("create.binders", "create.new.binder", null, formLayout, Link.BUTTON);
int count = (portfolioModule.isLearnerCanCreateBinders() ? 1 : 0) + (portfolioModule.isCanCreateBindersFromTemplate() ? 1 : 0) + (portfolioModule.isCanCreateBindersFromCourse() ? 1 : 0);
if (count > 1) {
newBinderDropdown.setIconRightCSS("o_icon o_icon_caret");
}
row.put("createDropdown", newBinderDropdown.getComponent());
}
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project openolat by klemens.
the class BinderOnePageController method loadSection.
private void loadSection(Section section) {
String id = "section_" + (++counter);
VelocityContainer rowVC = createVelocityContainer(id, "portfolio_element_row");
AssessmentSection assessmentSection = null;
PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, false, false);
rowVC.contextPut("row", row);
rowVC.contextPut("rowIndex", 0);
mainVC.put(id, rowVC);
components.add(id);
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project openolat by klemens.
the class BinderOnePageController method loadPage.
private void loadPage(UserRequest ureq, Page page) {
String id = "page_w_" + (++counter);
VelocityContainer pageVC = createVelocityContainer(id, "page_content_print");
mainVC.put(id, pageVC);
components.add(id);
BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getReadOnlyCallback();
PageMetadataController metadatCtrl = new PageMetadataController(ureq, getWindowControl(), secCallback, page);
listenTo(metadatCtrl);
Component pageMetaCmp = metadatCtrl.getInitialComponent();
pageVC.put("meta", pageMetaCmp);
PageController pageCtrl = new PageController(ureq, getWindowControl(), new PortfolioPageProvider(page), renderingHints);
listenTo(pageCtrl);
pageCtrl.loadElements(ureq);
Component pageCmp = pageCtrl.getInitialComponent();
pageVC.put("page", pageCmp);
CommentAndRatingSecurityCallback commentSecCallback = new ReadOnlyCommentsSecurityCallback();
OLATResourceable ores = OresHelper.createOLATResourceableInstance(Page.class, page.getKey());
UserCommentsController commentsCtrl = new UserCommentsController(ureq, getWindowControl(), ores, null, commentSecCallback);
listenTo(commentsCtrl);
if (commentsCtrl.getNumOfComments() > 0) {
pageVC.put("comments", commentsCtrl.getInitialComponent());
}
}
use of org.olat.core.gui.components.velocity.VelocityContainer 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.velocity.VelocityContainer in project openolat by klemens.
the class MediaMetadataController method loadMetadata.
private void loadMetadata(VelocityContainer metaVC) {
metaVC.contextPut("media", media);
String author = userManager.getUserDisplayName(media.getAuthor());
metaVC.contextPut("author", author);
MediaHandler handler = portfolioService.getMediaHandler(media.getType());
String type = translate("artefact." + handler.getType());
metaVC.contextPut("mediaType", type);
String iconCssClass = handler.getIconCssClass(media);
if (StringHelper.containsNonWhitespace(iconCssClass)) {
metaVC.contextPut("mediaIconCssClass", iconCssClass);
}
if (media.getCollectionDate() != null) {
String collectionDate = Formatter.getInstance(getLocale()).formatDate(media.getCollectionDate());
metaVC.contextPut("collectionDate", collectionDate);
}
if (StringHelper.containsNonWhitespace(media.getMetadataXml())) {
Object metadata = MetadataXStream.get().fromXML(media.getMetadataXml());
metaVC.contextPut("metadata", metadata);
}
List<Category> categories = portfolioService.getCategories(media);
if (categories != null && categories.size() > 0) {
List<String> categoriesList = categories.stream().map(c -> c.getName()).collect(Collectors.toList());
metaVC.contextPut("categoriesList", categoriesList);
}
}
Aggregations