Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 09c67445bdc8d81e081ea0fca26b11b373ee6d8a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**********************************************************************
Copyright (c) 2000, 2002 IBM Corp.  All rights reserved.
This file is made available under the terms of the Common Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/cpl-v10.html
**********************************************************************/
package org.eclipse.ui.externaltools.internal.ant.view.elements;

import java.util.ArrayList;
import java.util.List;

/**
 * The root node of an ant node tree
 */
public class RootNode extends AntNode {

	private List projects= new ArrayList();
	
	public RootNode() {
		super(null);
	}
	
	/**
	 * Creates a new root node containing the given projects
	 * 
	 * @param projects the projects to add to this node
	 */
	public RootNode(ProjectNode[] projects) {
		super(null);
		for (int i = 0; i < projects.length; i++) {
			this.projects.add(projects[i]);
		}
	}
	
	/**
	 * Returns the list of projects stored in this root node
	 * 
	 * @return ProjectNode[] the projects in this node
	 */
	public ProjectNode[] getProjects() {
		return (ProjectNode[])projects.toArray(new ProjectNode[projects.size()]);
	}
	
	/**
	 * Returns whether this root node contains any projects
	 * 
	 * @return boolean Whether there are any projects
	 */
	public boolean hasProjects() {
		return !projects.isEmpty();
	}
	
	/**
	 * Adds the given project to this root node
	 * 
	 * @param project the project to add
	 */
	public void addProject(ProjectNode project) {
		projects.add(project);
	}
	
	/**
	 * Removes the given project from this root node. Has no effect if the given
	 * project is not a child of this root
	 * 
	 * @param project the project to remove
	 */
	public void removeProject(ProjectNode project) {
		projects.remove(project);
	}
	
	/**
	 * Removes all projects from this root node. Has no effect if this node has
	 * no projects.
	 */
	public void removeAllProjects() {
		projects.clear();
	}

}

Back to the top