KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.jcr.Repository;
9 import javax.jcr.Ticket;
10 import org.exoplatform.faces.core.component.UINode;
11 import org.exoplatform.faces.core.event.ExoActionEvent;
12 import org.exoplatform.faces.core.event.ExoActionListener;
13 import org.exoplatform.portlets.content.explorer.component.model.JCRNodeDescriptor;
14 import org.exoplatform.services.jcr.RepositoryService;
15 /**
16  * Jun 22, 2004
17  * @author: Tuan Nguyen
18  * @email: tuan08@users.sourceforge.net
19  * @version: $Id: UIFileExplorer.java,v 1.3 2004/08/17 13:07:02 tuan08 Exp $
20  */

21 public class UIJCRExplorer extends UIExplorer {
22     private Ticket ticket_ ;
23   private Node currentNode_ ;
24   
25     public UIJCRExplorer(RepositoryService repositoryService) throws Exception JavaDoc {
26     Repository repository = repositoryService.getRepository();
27     ticket_ = repository.login(null, "ws");//annonymous ticket
28
UINode uiDetail = (UINode)addChild(UINode.class) ;
29     uiDetail.setRendererType("SimpleTabRenderer") ;
30     UINode uiNodeContent = (UINode)uiDetail.addChild(UINode.class) ;
31     UINode uiAdmin = (UINode)uiDetail.addChild(UINode.class) ;
32     
33     uiNodeContent.setRendererType("ChildrenRenderer") ;
34     uiNodeContent.setName("View") ;
35     uiNodeContent.setId("UINodeContent") ;
36     uiNodeContent.addChild(UIJCRChildrenInfo.class) ;
37     uiNodeContent.addChild(UIJCRContentViewer.class).setRendered(false) ;
38     
39     uiAdmin.setRendered(false) ;
40     uiAdmin.setId("UIAdmin") ;
41     uiAdmin.setName("Admin") ;
42     uiAdmin.setRendererType("SimpleTabRenderer") ;
43     uiAdmin.addChild(UIJCRNodeInfo.class) ;
44     
45     addActionListener(ChangeNodeActionListener.class, CHANGE_NODE_ACTION) ;
46     
47     changeNode("/") ;
48   }
49   
50   public void changeNode(String JavaDoc uri) throws Exception JavaDoc {
51     if(uri == null) uri = "/" ;
52     currentNode_ = ticket_.getNodeByAbsPath(uri) ;
53     setSelectNode(new JCRNodeDescriptor(currentNode_.getParent().getPath(), currentNode_));
54   }
55   
56   public Node getCurrentNode() { return currentNode_ ; }
57   
58   public Ticket getTicket() { return ticket_ ; }
59   
60   static public class ChangeNodeActionListener extends ExoActionListener {
61     public void execute(ExoActionEvent event) throws Exception JavaDoc {
62       UIJCRExplorer uiExplorer = (UIJCRExplorer) event.getComponent() ;
63       String JavaDoc uri = event.getParameter("uri") ;
64       if("../".equals(uri)) uri = uiExplorer.getSelectNode().getParentUri() ;
65       uiExplorer.changeNode(uri);
66     }
67   }
68 }
Popular Tags