Skip to content
Snippets Groups Projects
Commit 8566bab8 authored by srosse's avatar srosse
Browse files

OO-1068: fix the managed icons for gropus and learn resources

parent 869371e1
No related branches found
No related tags found
No related merge requests found
......@@ -269,7 +269,7 @@ public class CatalogController extends BasicController implements Activateable2
myContent.contextPut("canRemoveAllLinks", new Boolean(canRemoveAllLinks));
myContent.contextPut("isGuest", new Boolean(isGuest));
// add icon renderer
myContent.contextPut("iconRenderer", new RepositoryEntryIconRenderer(getLocale()));
myContent.contextPut("iconRenderer", new RepositoryEntryIconRenderer());
// add this root node as history start
historyStack.add(rootce);
updateContent(ureq, rootce, 0);
......
......@@ -19,9 +19,11 @@
*/
package org.olat.group.ui.main;
import java.util.Locale;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableComponent;
import org.olat.core.gui.components.table.CustomCssCellRenderer;
import org.olat.core.gui.components.table.CustomCellRenderer;
import org.olat.core.gui.render.Renderer;
import org.olat.core.gui.render.StringOutput;
import org.olat.core.gui.render.URLBuilder;
......@@ -35,45 +37,33 @@ import org.olat.group.BusinessGroupShort;
*
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/
public class BusinessGroupNameCellRenderer extends CustomCssCellRenderer implements FlexiCellRenderer {
public class BusinessGroupNameCellRenderer implements CustomCellRenderer, FlexiCellRenderer {
private static final String cssClass = "o_icon o_icon_group";
private static final String managedCssClass = "o_icon o_icon_group o_icon_managed";
@Override
public void render(Renderer renderer, StringOutput sb, Object cellValue,
int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
if(cellValue instanceof BusinessGroupShort) {
BusinessGroupShort group = (BusinessGroupShort)cellValue;
String css = group.getManagedFlags().length == 0 ? cssClass : managedCssClass;
sb.append("<i class='").append(css).append("'> </i> ")
.append(StringHelper.escapeHtml(group.getName()));
render(sb, (BusinessGroupShort)cellValue, renderer);
}
}
@Override
protected String getCssClass(Object val) {
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale,
int alignment, String action) {
if(val instanceof BusinessGroupShort) {
BusinessGroupShort group = (BusinessGroupShort)val;
return group.getManagedFlags().length == 0 ? cssClass : managedCssClass;
render(sb, (BusinessGroupShort)val, renderer);
}
return cssClass;
}
@Override
protected String getCellValue(Object val) {
if(val instanceof BusinessGroupShort) {
BusinessGroupShort group = (BusinessGroupShort)val;
return group.getName() == null ? "" : StringHelper.escapeHtml(group.getName());
private void render(StringOutput sb, BusinessGroupShort group, Renderer renderer) {
if(renderer != null) {
sb.append("<i class='o_icon o_icon_group'> </i> ");
if(group.getManagedFlags() != null && group.getManagedFlags().length > 0) {
sb.append("<i class='o_icon o_icon_managed'> </i> ");
}
sb.append(StringHelper.escapeHtml(group.getName()));
} else {
sb.append(group.getName());
}
return val == null ? "" : val.toString();
}
@Override
protected String getHoverText(Object val) {
return "";
}
}
\ No newline at end of file
......@@ -40,6 +40,8 @@ public interface RepositoryEntryAuthorView extends OLATResourceable, RepositoryE
public String getExternalId();
public String getExternalRef();
public RepositoryEntryManagedFlag[] getManagedFlags();
public String getAuthor();
......
......@@ -24,6 +24,7 @@ import java.util.Date;
import org.olat.core.util.resource.OresHelper;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryEntryAuthorView;
import org.olat.repository.RepositoryEntryManagedFlag;
import org.olat.resource.OLATResource;
/**
......@@ -46,6 +47,7 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView {
private String softkey;
private String externalId;
private String externalRef;
private RepositoryEntryManagedFlag[] managedFlags;
private boolean membersOnly;
private int access;
......@@ -72,6 +74,7 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView {
softkey = re.getSoftkey();
externalId = re.getExternalId();
externalRef = re.getExternalRef();
managedFlags = re.getManagedFlags();
membersOnly = re.isMembersOnly();
access = re.getAccess();
......@@ -139,6 +142,11 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView {
return externalRef;
}
@Override
public RepositoryEntryManagedFlag[] getManagedFlags() {
return managedFlags;
}
@Override
public String getAuthor() {
return author;
......
......@@ -21,10 +21,12 @@ package org.olat.repository.ui;
import java.util.Locale;
import org.apache.commons.lang.StringEscapeUtils;
import org.olat.NewControllerFactory;
import org.olat.core.gui.components.table.IconCssCellRenderer;
import org.olat.core.gui.components.table.CustomCellRenderer;
import org.olat.core.gui.render.Renderer;
import org.olat.core.gui.render.StringOutput;
import org.olat.core.util.StringHelper;
import org.olat.core.util.i18n.I18nModule;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryEntryShort;
......@@ -38,76 +40,38 @@ import org.olat.repository.RepositoryEntryShort;
*
* @author Florian Gnägi, http://www.frentix.com
*/
public class RepositoryEntryIconRenderer extends IconCssCellRenderer {
private Locale locale;
/**
* Constructor
*
* @param locale
*/
public RepositoryEntryIconRenderer(Locale locale) {
this.locale = locale;
}
public class RepositoryEntryIconRenderer implements CustomCellRenderer {
/**
* Constructor
*/
public RepositoryEntryIconRenderer() {
this.locale = I18nModule.getDefaultLocale();
}
/**
* @see org.olat.core.gui.components.table.CustomCssCellRenderer#getCellValue(java.lang.Object)
*/
@Override
protected String getCellValue(Object val) {
return "";
}
/**
* @see org.olat.core.gui.components.table.CustomCssCellRenderer#getCssClass(java.lang.Object)
*/
@Override
protected String getCssClass(Object val) {
// use small icon and create icon class for resource:
// o_FileResource-SHAREDFOLDER_icon
if(val == null) {
return "";
}
String cssClass = "";
boolean managed = false;
if(val instanceof RepositoryEntryShort) {
RepositoryEntryShort re = (RepositoryEntryShort)val;
cssClass = RepositoyUIFactory.getIconCssClass(re);
} else if (val instanceof RepositoryEntry) {
RepositoryEntry re = (RepositoryEntry)val;
cssClass = RepositoyUIFactory.getIconCssClass(re);
managed = StringHelper.containsNonWhitespace(re.getManagedFlagsString());
}
return (managed ? "o_icon o_managed_icon " : "o_icon ") + cssClass;
}
/**
* @see org.olat.core.gui.components.table.CustomCssCellRenderer#getHoverText(java.lang.Object)
*/
@Override
protected String getHoverText(Object val) {
if (val == null) {
return "n/a";
}
if(val instanceof RepositoryEntry) {
RepositoryEntry re = (RepositoryEntry) val;
String typeName = re.getOlatResource().getResourceableTypeName();
return NewControllerFactory.translateResourceableTypeName(typeName, locale);
}
if(val instanceof RepositoryEntryShort) {
RepositoryEntryShort re = (RepositoryEntryShort) val;
String typeName = re.getResourceType();
return NewControllerFactory.translateResourceableTypeName(typeName, locale);
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
if (renderer == null) {
// render for export
} else {
String type = "";
String cssClass = "";
boolean managed = false;
if(val instanceof RepositoryEntryShort) {
RepositoryEntryShort re = (RepositoryEntryShort)val;
cssClass = RepositoyUIFactory.getIconCssClass(re);
String typeName = re.getResourceType();
type = NewControllerFactory.translateResourceableTypeName(typeName, locale);
} else if (val instanceof RepositoryEntry) {
RepositoryEntry re = (RepositoryEntry)val;
cssClass = RepositoyUIFactory.getIconCssClass(re);
managed = StringHelper.containsNonWhitespace(re.getManagedFlagsString());
String typeName = re.getOlatResource().getResourceableTypeName();
type = NewControllerFactory.translateResourceableTypeName(typeName, locale);
}
sb.append("<i class='o_icon ").append(cssClass).append("'");
if (StringHelper.containsNonWhitespace(type)) {
sb.append(" title=\"");
sb.append(StringEscapeUtils.escapeHtml(type));
}
sb.append("\"> </i>");
if(managed) {
sb.append(" <i class='o_icon o_icon_managed'> </i>");
}
}
return "n/a";
}
}
......@@ -47,7 +47,7 @@ public class RepositoryEntryTypeColumnDescriptor extends CustomRenderColumnDescr
* @param aligment
*/
public RepositoryEntryTypeColumnDescriptor(String headerKey, int dataColumn, String action, Locale locale, int aligment) {
super(headerKey, dataColumn, action, locale, aligment, new RepositoryEntryIconRenderer(locale));
super(headerKey, dataColumn, action, locale, aligment, new RepositoryEntryIconRenderer());
}
/**
......
......@@ -58,6 +58,7 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig
private String externalId;
private String externalRef;
private boolean managed;
private String lifecycleLabel;
private String lifecycleSoftKey;
......@@ -91,6 +92,7 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig
externalId = view.getExternalId();
externalRef = view.getExternalRef();
managed = view.getManagedFlags() != null && view.getManagedFlags().length > 0;
membersOnly = view.isMembersOnly();
access = view.getAccess();
......@@ -200,6 +202,10 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig
public String getExternalRef() {
return externalRef;
}
public boolean isManaged() {
return managed;
}
public String getLifecycleLabel() {
return lifecycleLabel;
......
......@@ -60,7 +60,11 @@ public class TypeRenderer implements FlexiCellRenderer {
String cssClass = "";
boolean managed = false;
if (cellValue instanceof RepositoryEntryShort) {
if(cellValue instanceof AuthoringEntryRow) {
AuthoringEntryRow re = (AuthoringEntryRow) cellValue;
cssClass = RepositoyUIFactory.getIconCssClass(re);
managed = re.isManaged();
} else if (cellValue instanceof RepositoryEntryShort) {
RepositoryEntryShort re = (RepositoryEntryShort) cellValue;
cssClass = RepositoyUIFactory.getIconCssClass(re);
} else if (cellValue instanceof RepositoryEntry) {
......@@ -68,11 +72,11 @@ public class TypeRenderer implements FlexiCellRenderer {
cssClass = RepositoyUIFactory.getIconCssClass(re);
managed = StringHelper.containsNonWhitespace(re.getManagedFlagsString());
}
target.append("<div class='o_nowrap o_repoentry_type'>");
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> ");
target.append(" <i class='o_icon o_icon_managed' title=\"").append(translator.translate("cif.managedflags")).append("\"></i> ");
}
target.append("<i class='o_icon o_icon-lg ").append(cssClass).append("' title=\"").append(type).append("\"></i>");
target.append("</div>");
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment