KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.jcr.Node ;
8 import org.exoplatform.portlets.content.explorer.component.model.NodeDescriptor;
9 /**
10  * @email: tuan08@users.sourceforge.net
11  * @version: $Id: UIContentDisplayer.java,v 1.2 2004/08/07 18:11:26 tuan08 Exp $
12  */

13 public class UIJCRContentViewer extends UIContentViewer {
14   public UIJCRContentViewer() {
15     
16   }
17   
18   public void onChange(UIExplorer uiExplorer, NodeDescriptor node) {
19     if(!node.isLeafNode()) {
20       setRendered(false) ;
21       return;
22     }
23     String JavaDoc content = "" ;
24     String JavaDoc mimeType = node.getNodeType() ;
25     try {
26       UIJCRExplorer uiJCRExplorer = (UIJCRExplorer) uiExplorer ;
27       renderer_ = getRenderer(mimeType) ;
28       if (renderer_ != null) {
29         if (mimeType.startsWith("text")) {
30           Node jcrnode = uiJCRExplorer.getCurrentNode() ;
31           Node jcrcontent = jcrnode.getNode("jcr:content") ;
32           content = jcrcontent.getProperty("exo:content").getValue().getString() ;
33         } else {
34           content = "/content/FileContentServlet?path=" + node.getUri() ;
35         }
36       } else {
37         String JavaDoc relativePath = node.getUri();
38         renderer_ = getRenderer("default") ;
39         content = "/content/FileContentServlet?path=" + relativePath ;
40       }
41     } catch (Exception JavaDoc ex) {
42       renderer_ = getRenderer("text/plain") ;
43       content = org.exoplatform.commons.utils.ExceptionUtil.getExoStackTrace(ex) ;
44     }
45     setContent(content) ;
46     setContentType(mimeType) ;
47     setRendered(true) ;
48   }
49   
50   public void onModify(UIExplorer uiExplorer, NodeDescriptor node) {
51    
52   }
53 }
54
Popular Tags