1 5 package org.exoplatform.portlets.content.explorer.component; 6 7 import java.io.IOException ; 8 import java.util.HashMap ; 9 import java.util.Map ; 10 11 import javax.faces.FactoryFinder; 12 import javax.faces.context.FacesContext; 13 import javax.faces.render.RenderKit; 14 import javax.faces.render.RenderKitFactory; 15 import javax.faces.render.Renderer; 16 import org.exoplatform.faces.core.component.UIExoComponentBase; 17 import org.exoplatform.faces.core.component.UIExoComponent; 18 import org.exoplatform.portlets.content.explorer.component.model.NodeDescriptor; 19 23 abstract public class UIContentViewer 24 extends UIExoComponentBase implements ExplorerListener { 25 26 final static public String BACK_ACTION = "backAction" ; 27 protected static Map supportType_ ; 28 29 static { 30 RenderKitFactory rkFactory = 31 (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); 32 RenderKit renderKit = rkFactory.getRenderKit(null, RenderKitFactory.HTML_BASIC_RENDER_KIT); 33 supportType_ = new HashMap () ; 34 Renderer renderer = renderKit.getRenderer(UIExoComponent.COMPONENT_FAMILY, "TextContentRenderer"); 35 supportType_.put("text/plain" , renderer) ; 36 supportType_.put("text/html" , renderer) ; 37 supportType_.put("text/xml" , renderer) ; 38 supportType_.put("text/properties" , renderer) ; 39 supportType_.put("text/css" , renderer) ; 40 supportType_.put("text/java" , renderer) ; 41 42 renderer = renderKit.getRenderer(UIExoComponent.COMPONENT_FAMILY, "ImageRenderer"); 43 supportType_.put("image/jpeg" , renderer) ; 44 supportType_.put("image/gif" , renderer) ; 45 supportType_.put("image/png" , renderer) ; 46 supportType_.put("image/bmp" , renderer) ; 47 48 renderer = renderKit.getRenderer(UIExoComponent.COMPONENT_FAMILY, "DefaultContentRenderer"); 49 supportType_.put("default" , renderer) ; 50 } 51 52 protected String mimeType_ ; 53 protected String content_ ; 54 protected Renderer renderer_ ; 55 56 public UIContentViewer() { 57 } 58 59 public String getContentType() { return mimeType_ ;} 60 public void setContentType(String s) {mimeType_ = s ;} 61 62 public String getContent() { return content_ ; } 63 public void setContent(String s) {content_ = s ; } 64 65 public String getUri() { return "" ; } 66 67 public Renderer getRenderer(String name) { 68 return (Renderer) supportType_.get(name) ; 69 } 70 71 public void onModify(UIExplorer uiExplorer, NodeDescriptor node) {} 72 73 public void onAddChild(UIExplorer uiExplorer, NodeDescriptor node) { } 74 75 public void onRemove(UIExplorer uiExplorer, NodeDescriptor node) { } 76 77 final public void encodeBegin( FacesContext context) throws IOException { 78 renderer_.encodeBegin(context, this) ; 79 } 80 81 final public void encodeChildren( FacesContext context) throws IOException { } 82 83 final public void encodeEnd( FacesContext context) throws IOException { } 84 } 85 | Popular Tags |