KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.List JavaDoc;
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 /**
12  * @email: tuan08@users.sourceforge.net
13  * @version: $Id: UIExplorer.java,v 1.2 2004/07/31 15:07:15 tuan08 Exp $
14  */

15 abstract public class UIExplorer extends UIExoCommand {
16   final static public String JavaDoc CHANGE_NODE_ACTION = "changeNode" ;
17   final static public String JavaDoc REMOVE_NODE = "removeNode" ;
18   final static public String JavaDoc EDIT_NODE_CONTENT = "editContent" ;
19   final static public String JavaDoc VIEW_NODE_CONTENT = "viewNodeContent" ;
20   final static public String JavaDoc 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 JavaDoc getParentUri(String JavaDoc uri) {
39     int idx = uri.lastIndexOf("/") ;
40     String JavaDoc 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 JavaDoc uri) throws Exception JavaDoc ;
50   
51   public void broadcastOnChange(NodeDescriptor node) {
52     List JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc 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