Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: bcd1c0095354ae2ba6adede6e8bc6c7cc01568ce (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*******************************************************************************
 * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
 * This program and the accompanying materials are made available under the terms
 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tm.te.core.interfaces.nodes;

import java.util.List;


/**
 * A container (data) model node.
 * <p>
 * The container can have both container model node and model node
 * children. Container model nodes can be used as synchronization
 * object for the Eclipse jobs API.
 */
public interface IContainerModelNode extends IModelNode {
	/**
	 * Property change notification: Specific child node has been added.
	 */
	public static final String NOTIFY_ADDED = "added";  //$NON-NLS-1$

	/**
	 * Property change notification: Specific child node has been removed.
	 */
	public static final String NOTIFY_REMOVED = "removed";  //$NON-NLS-1$

	/**
	 * Property change notification: Unspecified child nodes may have changed, added or removed.
	 */
	public static final String NOTIFY_CHANGED = "changed"; //$NON-NLS-1$

	/**
	 * Adds the given child node to the list of children.
	 *
	 * @param child The child node to append. Must not be <code>null</code>!
	 */
	public boolean add(IModelNode child);

	/**
	 * Removes the given node from the list of children.
	 *
	 * @param node The node to remove or <code>null</code>.
	 * @param recursive If <code>true</code> and the node is a container model node, the children
	 *                  of the container model node will be removed recursively.
	 *
	 * @return <code>true</code> if the list of children contained the given node, <code>false</code> otherwise.
	 */
	public boolean remove(IModelNode node, boolean recursive);

	/**
	 * Remove all child nodes recursively.
	 */
	public boolean clear();

	/**
	 * Remove all child nodes with a special type.
	 *
	 * @param nodeType The node type.
	 * @return <code>True</code> if child nodes got removed from the mode, <code>false</code> if not.
	 */
	public <T> boolean removeAll(Class<T> nodeType);

	/**
	 * Returns the child nodes.
	 */
	public IModelNode[] getChildren();

	/**
	 * Returns all child nodes with a special type.
	 *
	 * @param nodeType The node type.
	 * @return The list of nodes or an empty list.
	 */
	public <T> List<T> getChildren(Class<T> nodeType);

	/**
	 * Returns true if node may have children.
	 */
	boolean hasChildren();

	/**
	 * Returns the current count of child nodes.
	 */
	public int size();

	/**
	 * Returns if or if not the given model node is a child of this container.
	 *
	 * @param node The model node.
	 * @return <code>true</code> if the given model node is a child of this container, <code>false</code> otherwise.
	 */
	public boolean contains(IModelNode node);
}

Back to the top