1 5 package org.exoplatform.portlets.content.explorer.component; 6 7 import java.util.List ; 8 import org.exoplatform.faces.core.component.UIExoCommand; 9 import org.exoplatform.faces.core.component.model.Parameter; 10 import org.exoplatform.portlets.content.explorer.component.model.NodeDescriptor; 11 15 abstract public class UIExplorer extends UIExoCommand { 16 final static public String CHANGE_NODE_ACTION = "changeNode" ; 17 final static public String REMOVE_NODE = "removeNode" ; 18 final static public String EDIT_NODE_CONTENT = "editContent" ; 19 final static public String VIEW_NODE_CONTENT = "viewNodeContent" ; 20 final static public String UPLOAD_FILE = "uploadFile" ; 21 22 public static Parameter[] CHANGE_NODE = { new Parameter(ACTION , CHANGE_NODE_ACTION)} ; 23 24 private NodeDescriptor selectNode_ ; 25 26 public UIExplorer() { 27 setId("UIExplorer") ; 28 setRendererType("ExplorerRenderer") ; 29 } 30 31 public NodeDescriptor getSelectNode() { return selectNode_ ; } 32 33 protected void setSelectNode(NodeDescriptor node) { 34 selectNode_ = node ; 35 broadcastOnChange(node) ; 36 } 37 38 public String getParentUri(String uri) { 39 int idx = uri.lastIndexOf("/") ; 40 String parentUri = "/" ; 41 if(idx > 0) { 42 parentUri = uri.substring(0, idx) ; 43 } else if( idx == 0) { 44 parentUri = "/" ; 45 } 46 return parentUri; 47 } 48 49 public abstract void changeNode(String uri) throws Exception ; 50 51 public void broadcastOnChange(NodeDescriptor node) { 52 List list = findDescendantsOfType(ExplorerListener.class) ; 53 for(int i = 0 ; i < list.size(); i++) { 54 ExplorerListener listener = (ExplorerListener) list.get(i) ; 55 listener.onChange(this, node) ; 56 } 57 } 58 59 public void broadcastOnRemove(NodeDescriptor node) { 60 List list = findDescendantsOfType(ExplorerListener.class) ; 61 for(int i = 0 ; i < list.size(); i++) { 62 ExplorerListener listener = (ExplorerListener) list.get(i) ; 63 listener.onRemove(this,node) ; 64 } 65 } 66 67 public void broacastOnModify(NodeDescriptor node) { 68 List list = findDescendantsOfType(ExplorerListener.class) ; 69 for(int i = 0 ; i < list.size(); i++) { 70 ExplorerListener listener = (ExplorerListener) list.get(i) ; 71 listener.onModify(this,node) ; 72 } 73 } 74 75 public void broadcastOnAddChild(NodeDescriptor node) { 76 List list = findDescendantsOfType(ExplorerListener.class) ; 77 for(int i = 0 ; i < list.size(); i++) { 78 ExplorerListener listener = (ExplorerListener) list.get(i) ; 79 listener.onAddChild(this,node) ; 80 } 81 } 82 } | Popular Tags |