KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > content > explorer > component > UIContentViewer


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.content.explorer.component;
6
7 import java.io.IOException JavaDoc;
8 import java.util.HashMap JavaDoc;
9 import java.util.Map JavaDoc;
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 /**
20  * @email: tuan08@users.sourceforge.net
21  * @version: $Id: UIContentDisplayer.java,v 1.2 2004/08/07 18:11:26 tuan08 Exp $
22  */

23 abstract public class UIContentViewer
24   extends UIExoComponentBase implements ExplorerListener {
25   
26     final static public String JavaDoc BACK_ACTION = "backAction" ;
27   protected static Map JavaDoc 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 JavaDoc() ;
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 JavaDoc mimeType_ ;
53   protected String JavaDoc content_ ;
54   protected Renderer renderer_ ;
55   
56   public UIContentViewer() {
57   }
58
59   public String JavaDoc getContentType() { return mimeType_ ;}
60   public void setContentType(String JavaDoc s) {mimeType_ = s ;}
61   
62   public String JavaDoc getContent() { return content_ ; }
63   public void setContent(String JavaDoc s) {content_ = s ; }
64   
65   public String JavaDoc getUri() { return "" ; }
66   
67   public Renderer getRenderer(String JavaDoc 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 JavaDoc {
78     renderer_.encodeBegin(context, this) ;
79   }
80   
81   final public void encodeChildren( FacesContext context) throws IOException JavaDoc { }
82   
83   final public void encodeEnd( FacesContext context) throws IOException JavaDoc { }
84 }
85
Popular Tags