KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > views > elements > RootNode


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ant.internal.ui.views.elements;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.List JavaDoc;
15
16 /**
17  * The root node of an ant node tree
18  */

19 public class RootNode extends AntNode {
20
21     private List JavaDoc projects= new ArrayList JavaDoc();
22     
23     public RootNode() {
24         super(null);
25     }
26     
27     /**
28      * Creates a new root node containing the given projects
29      *
30      * @param projects the projects to add to this node
31      */

32     public RootNode(ProjectNode[] projects) {
33         super(null);
34         for (int i = 0; i < projects.length; i++) {
35             this.projects.add(projects[i]);
36         }
37     }
38     
39     /**
40      * Returns the list of projects stored in this root node
41      *
42      * @return ProjectNode[] the projects in this node
43      */

44     public ProjectNode[] getProjects() {
45         return (ProjectNode[])projects.toArray(new ProjectNode[projects.size()]);
46     }
47     
48     /**
49      * Returns whether this root node contains any projects
50      *
51      * @return boolean Whether there are any projects
52      */

53     public boolean hasProjects() {
54         return !projects.isEmpty();
55     }
56     
57     /**
58      * Adds the given project to this root node
59      *
60      * @param project the project to add
61      */

62     public void addProject(ProjectNode project) {
63         projects.add(project);
64     }
65     
66     /**
67      * Removes the given project from this root node. Has no effect if the given
68      * project is not a child of this root
69      *
70      * @param project the project to remove
71      */

72     public void removeProject(ProjectNode project) {
73         projects.remove(project);
74     }
75     
76     /**
77      * Removes all projects from this root node. Has no effect if this node has
78      * no projects.
79      */

80     public void removeAllProjects() {
81         projects.clear();
82     }
83
84 }
85
Popular Tags