use of org.olat.modules.portfolio.ui.model.MediaRow 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.ui.model.MediaRow in project OpenOLAT by OpenOLAT.
the class MediaCenterController method getComponents.
@Override
public Iterable<Component> getComponents(int row, Object rowObject) {
MediaRow mediaRow = model.getObject(row);
List<Component> components = new ArrayList<>(2);
if (mediaRow.getOpenFormItem() != null) {
components.add(mediaRow.getOpenFormItem().getComponent());
}
return components;
}
use of org.olat.modules.portfolio.ui.model.MediaRow in project OpenOLAT by OpenOLAT.
the class MediaCenterController method loadModel.
private void loadModel() {
String searchString = tableEl.getQuickSearchString();
List<String> tagNames = getSelectedTagNames();
Map<Long, MediaRow> currentMap = model.getObjects().stream().collect(Collectors.toMap(r -> r.getKey(), r -> r));
List<MediaLight> medias = portfolioService.searchOwnedMedias(getIdentity(), searchString, tagNames);
List<MediaRow> rows = new ArrayList<>(medias.size());
for (MediaLight media : medias) {
if (currentMap.containsKey(media.getKey())) {
rows.add(currentMap.get(media.getKey()));
} else {
MediaHandler handler = portfolioService.getMediaHandler(media.getType());
VFSLeaf thumbnail = handler.getThumbnail(media, THUMBNAIL_SIZE);
String mediaTitle = StringHelper.escapeHtml(media.getTitle());
FormLink openLink = uifactory.addFormLink("select_" + (++counter), "select", mediaTitle, null, flc, Link.NONTRANSLATED);
MediaRow row = new MediaRow(media, thumbnail, openLink, handler.getIconCssClass(media));
openLink.setUserObject(row);
rows.add(row);
}
}
model.setObjects(rows);
model.filter(tableEl.getSelectedFilters());
Map<Long, MediaRow> rowMap = model.getObjects().stream().collect(Collectors.toMap(r -> r.getKey(), r -> r));
Set<String> duplicateCategories = new HashSet<>();
List<CategoryLight> categories = portfolioService.getMediaCategories(getIdentity());
List<FormLink> newTagLinks = new ArrayList<>(categories.size());
for (CategoryLight category : categories) {
String name = category.getCategory();
MediaRow mRow = rowMap.get(category.getMediaKey());
if (mRow != null) {
mRow.addCategory(name);
}
if (duplicateCategories.contains(name)) {
continue;
}
duplicateCategories.add(name);
FormLink tagLink = uifactory.addFormLink("tag_" + (++counter), "tag", name, null, null, Link.NONTRANSLATED);
CategoryState state = new CategoryState(category, tagNames.contains(name));
tagLink.setUserObject(state);
if (state.isSelected()) {
tagLink.setCustomEnabledLinkCSS("tag label label-info o_disabled");
} else {
tagLink.setCustomEnabledLinkCSS("tag label label-info");
}
flc.add(tagLink);
newTagLinks.add(tagLink);
}
flc.contextPut("tagLinks", newTagLinks);
tagLinks = newTagLinks;
}
use of org.olat.modules.portfolio.ui.model.MediaRow in project openolat by klemens.
the class MediaCenterController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == tableEl) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
MediaRow row = model.getObject(se.getIndex());
if ("select".equals(cmd)) {
if (select) {
doSelect(ureq, row.getKey());
} else {
Activateable2 activateable = doOpenMedia(ureq, row.getKey());
if (activateable != null) {
activateable.activate(ureq, null, null);
}
}
}
} else if (event instanceof FlexiTableSearchEvent) {
loadModel();
}
} else if (newMediaCallout == source) {
doOpenNewMediaCallout(ureq, newMediaCallout);
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("select".equals(cmd)) {
MediaRow row = (MediaRow) link.getUserObject();
if (select) {
doSelect(ureq, row.getKey());
} else {
Activateable2 activateable = doOpenMedia(ureq, row.getKey());
if (activateable != null) {
activateable.activate(ureq, null, null);
}
}
} else if ("tag".equals(cmd)) {
doToggleCategory(link);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.modules.portfolio.ui.model.MediaRow in project openolat by klemens.
the class MediaCenterController method loadModel.
private void loadModel() {
String searchString = tableEl.getQuickSearchString();
List<String> tagNames = getSelectedTagNames();
Map<Long, MediaRow> currentMap = model.getObjects().stream().collect(Collectors.toMap(r -> r.getKey(), r -> r));
List<MediaLight> medias = portfolioService.searchOwnedMedias(getIdentity(), searchString, tagNames);
List<MediaRow> rows = new ArrayList<>(medias.size());
for (MediaLight media : medias) {
if (currentMap.containsKey(media.getKey())) {
rows.add(currentMap.get(media.getKey()));
} else {
MediaHandler handler = portfolioService.getMediaHandler(media.getType());
VFSLeaf thumbnail = handler.getThumbnail(media, THUMBNAIL_SIZE);
String mediaTitle = StringHelper.escapeHtml(media.getTitle());
FormLink openLink = uifactory.addFormLink("select_" + (++counter), "select", mediaTitle, null, flc, Link.NONTRANSLATED);
MediaRow row = new MediaRow(media, thumbnail, openLink, handler.getIconCssClass(media));
openLink.setUserObject(row);
rows.add(row);
}
}
model.setObjects(rows);
model.filter(tableEl.getSelectedFilters());
Map<Long, MediaRow> rowMap = model.getObjects().stream().collect(Collectors.toMap(r -> r.getKey(), r -> r));
Set<String> duplicateCategories = new HashSet<>();
List<CategoryLight> categories = portfolioService.getMediaCategories(getIdentity());
List<FormLink> newTagLinks = new ArrayList<>(categories.size());
for (CategoryLight category : categories) {
String name = category.getCategory();
MediaRow mRow = rowMap.get(category.getMediaKey());
if (mRow != null) {
mRow.addCategory(name);
}
if (duplicateCategories.contains(name)) {
continue;
}
duplicateCategories.add(name);
FormLink tagLink = uifactory.addFormLink("tag_" + (++counter), "tag", name, null, null, Link.NONTRANSLATED);
CategoryState state = new CategoryState(category, tagNames.contains(name));
tagLink.setUserObject(state);
if (state.isSelected()) {
tagLink.setCustomEnabledLinkCSS("tag label label-info o_disabled");
} else {
tagLink.setCustomEnabledLinkCSS("tag label label-info");
}
flc.add(tagLink);
newTagLinks.add(tagLink);
}
flc.contextPut("tagLinks", newTagLinks);
tagLinks = newTagLinks;
}
Aggregations