1 13 package info.magnolia.cms.gui.control; 14 15 import info.magnolia.cms.core.Content; 16 import info.magnolia.cms.core.MetaData; 17 import info.magnolia.cms.core.NodeData; 18 import info.magnolia.cms.util.MetaDataUtil; 19 import info.magnolia.cms.util.NodeDataUtil; 20 21 import java.util.Calendar ; 22 23 24 27 public class TreeColumnHtmlRendererImpl implements TreeColumnHtmlRenderer { 28 29 32 public String renderHtml(TreeColumn treeColumn, Content content) { 33 String html; 34 if (treeColumn.getIsMeta()) { 35 html = new MetaDataUtil(content).getPropertyValueString(treeColumn.getName(), treeColumn.getDateFormat()); 36 } 37 else if (treeColumn.getIsLabel()) { 38 html = content.getName(); 39 } 40 else if (treeColumn.getIsIcons()) { 41 html = getHtmlIcons(treeColumn, content); 42 } 43 else { 44 NodeData data = content.getNodeData(treeColumn.getName()); 45 html = new NodeDataUtil(data).getValueString(treeColumn.getDateFormat()); 46 } 47 if (treeColumn.getKeyValue().size() != 0) { 49 String value = (String ) treeColumn.getKeyValue().get(html); 50 if (value != null) { 51 html = value; 52 } 53 } 54 return html; 55 56 } 57 58 64 private String getHtmlIcons(TreeColumn treeColumn, Content content) { 65 StringBuffer html = new StringBuffer (); 66 if (treeColumn.getIconsActivation()) { 67 MetaData activationMetaData = content.getMetaData(MetaData.ACTIVATION_INFO); 68 MetaData generalMetaData = content.getMetaData(); 69 boolean isActivated = activationMetaData.getIsActivated(); 70 Calendar actionDate = activationMetaData.getLastActionDate(); 71 Calendar lastModifiedDate = generalMetaData.getModificationDate(); 72 String imgSrc; 73 if (isActivated) { 74 if (lastModifiedDate != null && lastModifiedDate.after(actionDate)) { 75 imgSrc = Tree.ICONDOCROOT + "indicator_yellow.gif"; } 78 else { 79 imgSrc = Tree.ICONDOCROOT + "indicator_green.gif"; } 82 } 83 else { 84 imgSrc = Tree.ICONDOCROOT + "indicator_red.gif"; } 87 html.append("<img SRC=\"" + treeColumn.getRequest().getContextPath() + imgSrc + "\" />"); } 89 if (treeColumn.getIconsPermission()) { 90 if (!content.isGranted(info.magnolia.cms.security.Permission.WRITE)) { 91 html.append("<img SRC=\"" + treeColumn.getRequest().getContextPath() + Tree.ICONDOCROOT + "pen_blue_canceled.gif\" />"); } 94 } 95 return html.toString(); 96 } 97 98 } 99 | Popular Tags |