use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.
the class RepositoryEntryIconRenderer method getIconCssClass.
public String getIconCssClass(Object val) {
String cssClass = null;
if (val instanceof RepositoryEntry) {
RepositoryEntry re = (RepositoryEntry) val;
cssClass = RepositoyUIFactory.getIconCssClass(re);
} else if (val instanceof RepositoryEntryShort) {
RepositoryEntryShort re = (RepositoryEntryShort) val;
cssClass = RepositoyUIFactory.getIconCssClass(re);
}
return cssClass == null ? "" : cssClass;
}
use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.
the class TypeRenderer method render.
@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
String type = null;
if (cellValue instanceof RepositoryEntryShort) {
// add image and typename code
type = ((RepositoryEntryShort) cellValue).getResourceType();
} else if (cellValue instanceof RepositoryEntry) {
type = ((RepositoryEntry) cellValue).getOlatResource().getResourceableTypeName();
}
if (type == null) {
type = translator.translate("cif.type.na");
} else {
type = NewControllerFactory.translateResourceableTypeName(type, translator.getLocale());
}
type = StringEscapeUtils.escapeHtml(type);
String cssClass = "";
boolean managed = false;
int access = -1;
if (cellValue instanceof AuthoringEntryRow) {
AuthoringEntryRow re = (AuthoringEntryRow) cellValue;
cssClass = RepositoyUIFactory.getIconCssClass(re);
managed = re.isManaged();
access = re.getAccess();
} else if (cellValue instanceof RepositoryEntryShort) {
RepositoryEntryShort re = (RepositoryEntryShort) cellValue;
cssClass = RepositoyUIFactory.getIconCssClass(re);
} else if (cellValue instanceof RepositoryEntry) {
RepositoryEntry re = (RepositoryEntry) cellValue;
cssClass = RepositoyUIFactory.getIconCssClass(re);
managed = StringHelper.containsNonWhitespace(re.getManagedFlagsString());
access = re.getStatusCode();
}
if (renderer == null) {
// excel download
target.append(type);
} else {
target.append("<div class='o_nowrap o_repoentry_type'>").append("<i class='o_icon o_icon-lg ").append(cssClass).append("' title=\"").append(type).append("\"> </i>");
if (managed) {
target.append(" <i class='o_icon o_icon_managed' title=\"").append(translator.translate("cif.managedflags")).append("\"> </i> ");
}
if (access == 0) {
target.append(" <i class='o_icon o_icon-lg o_icon_deleted'> </i> ");
}
target.append("</div>");
}
}
use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.
the class AbstractBusinessGroupListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (createButton == source) {
doCreate(ureq, getWindowControl(), null);
} else if (deleteButton == source) {
confirmDelete(ureq, getSelectedItems());
} else if (duplicateButton == source) {
doCopy(ureq, getSelectedItems());
} else if (configButton == source) {
doConfiguration(ureq, getSelectedItems());
} else if (emailButton == source) {
doEmails(ureq, getSelectedItems());
} else if (usersButton == source) {
doUserManagement(ureq, getSelectedItems());
} else if (mergeButton == source) {
doMerge(ureq, getSelectedItems());
} else if (selectButton == source) {
doSelect(ureq, getSelectedItems());
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("mark".equals(cmd)) {
BusinessGroupRow row = (BusinessGroupRow) link.getUserObject();
boolean marked = toogleMark(row);
link.setIconLeftCSS(marked ? "o_icon o_icon_bookmark o_icon-lg" : "o_icon o_icon_bookmark_add o_icon-lg");
link.getComponent().setDirty(true);
} else if ("allresources".equals(cmd)) {
BusinessGroupShort bg = (BusinessGroupShort) link.getUserObject();
NewControllerFactory.getInstance().launch("[BusinessGroup:" + bg.getKey() + "][toolresources:0]", ureq, getWindowControl());
} else if ("resource".equals(cmd)) {
RepositoryEntryShort re = (RepositoryEntryShort) link.getUserObject();
NewControllerFactory.getInstance().launch("[RepositoryEntry:" + re.getKey() + "]", ureq, getWindowControl());
} else if (link.getUserObject() instanceof BusinessGroupRef) {
BusinessGroupRef item = (BusinessGroupRef) link.getUserObject();
Long businessGroupKey = item.getKey();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
if (businessGroup == null) {
groupTableModel.removeBusinessGroup(businessGroupKey);
tableEl.reset();
} else if (TABLE_ACTION_ACCESS.equals(cmd)) {
doAccess(ureq, businessGroup);
} else if (TABLE_ACTION_LEAVE.equals(cmd)) {
doConfirmLeaving(ureq, businessGroup);
}
}
} else if (source == tableEl) {
String cmd = event.getCommand();
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if (se.getIndex() >= 0 && se.getIndex() < groupTableModel.getRowCount()) {
BusinessGroupRef item = groupTableModel.getObject(se.getIndex());
Long businessGroupKey = item.getKey();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
// prevent rs after a group is deleted by someone else
if (businessGroup == null) {
groupTableModel.removeBusinessGroup(businessGroupKey);
tableEl.reset();
} else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
doLaunch(ureq, businessGroup);
} else if (TABLE_ACTION_DELETE.equals(cmd)) {
confirmDelete(ureq, Collections.singletonList(item));
} else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
doLaunch(ureq, businessGroup);
} else if (TABLE_ACTION_EDIT.equals(cmd)) {
doEdit(ureq, businessGroup);
} else if (TABLE_ACTION_LEAVE.equals(cmd)) {
doConfirmLeaving(ureq, businessGroup);
} else if (TABLE_ACTION_ACCESS.equals(cmd)) {
doAccess(ureq, businessGroup);
} else if (TABLE_ACTION_SELECT.equals(cmd)) {
doSelect(ureq, businessGroup);
}
}
} else if (event instanceof FlexiTableSearchEvent) {
doSearch((FlexiTableSearchEvent) event);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.
the class BGResourcesCellRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
if (cellValue instanceof BGTableItem) {
BGTableItem item = (BGTableItem) cellValue;
if (item.getRelations() != null && !item.getRelations().isEmpty()) {
List<RepositoryEntryShort> relations = item.getRelations();
int count = 0;
for (RepositoryEntryShort relation : relations) {
if (renderer == null) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(StringHelper.escapeHtml(relation.getDisplayname()));
} else if (count >= 2) {
sb.append(" ");
FormLink allResourcesLink = item.getAllResourcesLink();
if (allResourcesLink == null) {
allResourcesLink = uifactory.addFormLink("repo_entry_" + counter.incrementAndGet(), "allresources", "...", null, formLayout, Link.NONTRANSLATED);
}
allResourcesLink.setUserObject(item);
allResourcesLink.getComponent().getHTMLRendererSingleton().render(renderer, sb, allResourcesLink.getComponent(), ubu, translator, null, null);
break;
} else {
if (count > 0)
sb.append(" ");
String name = "repo_entry_" + item.getBusinessGroupKey() + "_" + relation.getKey();
FormLink markLink = (FormLink) formLayout.getFormComponent(name);
if (markLink == null) {
String resourceName = StringHelper.escapeHtml(relation.getDisplayname());
markLink = uifactory.addFormLink("repo_entry_" + relation.getKey(), "resource", resourceName, null, formLayout, Link.NONTRANSLATED);
markLink.setIconLeftCSS("o_icon o_CourseModule_icon");
markLink.setUserObject(relation);
formLayout.add(name, markLink);
}
markLink.getComponent().getHTMLRendererSingleton().render(renderer, sb, markLink.getComponent(), ubu, translator, null, null);
count++;
}
}
}
}
}
use of org.olat.repository.RepositoryEntryShort in project OpenOLAT by OpenOLAT.
the class BGMailHelper method getTemplateInfos.
public static BGMailTemplateInfos getTemplateInfos(BusinessGroupShort group, List<RepositoryEntryShort> repoEntries) {
StringBuilder learningResources = new StringBuilder();
if (repoEntries != null && repoEntries.size() > 0) {
for (RepositoryEntryShort entry : repoEntries) {
String title = entry.getDisplayname();
String url = BusinessControlFactory.getInstance().getURLFromBusinessPathString("[RepositoryEntry:" + entry.getKey() + "]");
learningResources.append(title);
learningResources.append(" (");
learningResources.append(url);
learningResources.append(")\n");
}
}
String courseList = null;
if (learningResources.length() > 0) {
courseList = learningResources.toString();
}
String groupNameWithUrl = null;
String groupDescription = null;
if (group != null) {
// get group name and description
StringBuilder sb = new StringBuilder();
sb.append(group.getName() == null ? "" : group.getName()).append(" (").append(BusinessControlFactory.getInstance().getURLFromBusinessPathString("[BusinessGroup:" + group.getKey() + "]")).append(")\n");
groupNameWithUrl = sb.toString();
String description;
if (group instanceof BusinessGroup) {
description = ((BusinessGroup) group).getDescription();
} else {
description = CoreSpringFactory.getImpl(BusinessGroupDAO.class).loadDescription(group.getKey());
}
groupDescription = FilterFactory.getHtmlTagAndDescapingFilter().filter(description);
}
return new BGMailTemplateInfos(group.getName(), groupNameWithUrl, groupDescription, courseList);
}
Aggregations