KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > module > admininterface > trees > TemplateTreeColumnHtmlRenderer


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.module.admininterface.trees;
14
15 import info.magnolia.cms.beans.config.ContentRepository;
16 import info.magnolia.cms.core.Content;
17 import info.magnolia.cms.core.HierarchyManager;
18 import info.magnolia.cms.gui.control.TreeColumn;
19 import info.magnolia.cms.gui.control.TreeColumnHtmlRenderer;
20 import info.magnolia.cms.i18n.TemplateMessagesUtil;
21
22 import javax.jcr.RepositoryException;
23
24
25 /**
26  * @author joshu
27  */

28 public class TemplateTreeColumnHtmlRenderer implements TreeColumnHtmlRenderer {
29
30     /**
31      * @see info.magnolia.cms.gui.control.TreeColumnHtmlRenderer#renderHtml(TreeColumn, Content)
32      */

33     public String JavaDoc renderHtml(TreeColumn treeColumn, Content content) {
34         String JavaDoc templateName = content.getMetaData().getTemplate();
35         String JavaDoc strKey = this.findTemplateKey(templateName);
36         return TemplateMessagesUtil.get(treeColumn.getRequest(), strKey);
37     }
38
39     private String JavaDoc findTemplateKey(String JavaDoc templateName) {
40         HierarchyManager configHierarchyManager = ContentRepository.getHierarchyManager(ContentRepository.CONFIG);
41         try {
42             Content template = configHierarchyManager.getContent("modules/templating/Templates/" + templateName); //$NON-NLS-1$
43
return template.getTitle();
44         }
45         catch (RepositoryException e) {
46             return templateName;
47         }
48     }
49
50 }
Popular Tags