View Javadoc

1   package org.gnomekr.potron.web.tree;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.apache.commons.lang.NullArgumentException;
7   import org.apache.myfaces.custom.tree2.TreeNodeBase;
8   import org.gnomekr.potron.data.Project;
9   
10  /***
11   * RootNode.java
12   * @author Xavier Cho
13   * @version $Revision 1.1 $ $Date: 2005/07/20 17:41:28 $
14   */
15  public class RootNode extends TreeNodeBase {
16  
17      public static final String ROOT_TYPE = "ROOT";
18      private static final long serialVersionUID = -3509023998386809950L;
19  
20      private List<ProjectNode> children;
21  
22      public RootNode(List<Project> projects) {
23          if (projects == null) {
24              throw new NullArgumentException("projects");
25          }
26  
27          this.children = new ArrayList<ProjectNode>(projects.size());
28  
29          for(Project project: projects) {
30              children.add(new ProjectNode(project));
31          }
32  
33          setLeaf(children.size() == 0);
34          setType(ROOT_TYPE);
35      }
36  
37      /***
38       * @see org.apache.myfaces.custom.tree2.TreeNode#getChildren()
39       */
40      @Override
41      public List<ProjectNode> getChildren() {
42          return children;
43      }
44  }