use of org.olat.modules.portfolio.MediaHandler in project openolat by klemens.
the class MediaCenterController method initFilters.
private void initFilters(FlexiTableElement tableElement) {
List<FlexiTableFilter> filters = new ArrayList<>(16);
filters.add(new FlexiTableFilter(translate("filter.show.all"), "showall"));
filters.add(FlexiTableFilter.SPACER);
List<MediaHandler> handlers = portfolioService.getMediaHandlers();
for (MediaHandler handler : handlers) {
filters.add(new FlexiTableFilter(translate("artefact." + handler.getType()), handler.getType()));
}
tableElement.setFilters(null, filters, false);
}
use of org.olat.modules.portfolio.MediaHandler 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.modules.portfolio.MediaHandler 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);
}
}
use of org.olat.modules.portfolio.MediaHandler in project openolat by klemens.
the class MediaTypeCellRenderer method render.
@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
if (cellValue instanceof MediaRow) {
MediaRow mRow = (MediaRow) cellValue;
MediaHandler handler = handlersMap.get(mRow.getType());
if (handler != null) {
target.append("<i class='o_icon o_icon-lg ").append(handler.getIconCssClass(mRow)).append("'> </i>");
}
}
}
use of org.olat.modules.portfolio.MediaHandler in project openolat by klemens.
the class MediaUploadController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (mediaReference == null) {
String title = titleEl.getValue();
String description = descriptionEl.getValue();
File uploadedFile = fileEl.getUploadFile();
String uploadedFilename = fileEl.getUploadFileName();
MediaHandler mediaHandler = getHandler();
if (mediaHandler != null) {
UploadMedia mObject = new UploadMedia(uploadedFile, uploadedFilename, fileEl.getUploadMimeType());
mediaReference = mediaHandler.createMedia(title, description, mObject, businessPath, getIdentity());
}
} else {
// TODO can we update an artefact?
}
List<String> updatedCategories = categoriesEl.getValueList();
portfolioService.updateCategories(mediaReference, updatedCategories);
fireEvent(ureq, Event.DONE_EVENT);
}
Aggregations