1 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 21 public class UIJCRExplorer extends UIExplorer { 22 private Ticket ticket_ ; 23 private Node currentNode_ ; 24 25 public UIJCRExplorer(RepositoryService repositoryService) throws Exception { 26 Repository repository = repositoryService.getRepository(); 27 ticket_ = repository.login(null, "ws"); 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 uri) throws Exception { 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 { 62 UIJCRExplorer uiExplorer = (UIJCRExplorer) event.getComponent() ; 63 String uri = event.getParameter("uri") ; 64 if("../".equals(uri)) uri = uiExplorer.getSelectNode().getParentUri() ; 65 uiExplorer.changeNode(uri); 66 } 67 } 68 } | Popular Tags |