0
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
package com.nokia.s60tools.appdep.core.data;
|
|
20 |
|
|
21 |
import java.util.ArrayList;
|
|
22 |
|
|
23 |
import com.nokia.s60tools.appdep.core.ITargetPlatform;
|
|
24 |
import com.nokia.s60tools.appdep.ui.views.data.IVisitor;
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Class representing component parent node in component tree.
|
|
28 |
*/
|
|
29 |
public class ComponentParentNode extends ComponentNode {
|
|
30 |
|
|
31 |
/**
|
|
32 |
* Binding type enumerator.
|
|
33 |
*/
|
|
34 |
public static enum CompBindType{NONE, AUTO_BIND, USER_BIND};
|
|
35 |
|
|
36 |
/**
|
|
37 |
* Node name.
|
|
38 |
*/
|
|
39 |
private String name = null;
|
|
40 |
|
|
41 |
/**
|
|
42 |
* Node's children
|
|
43 |
*/
|
|
44 |
private ArrayList<ComponentNode> children = null;
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Node listener.
|
|
48 |
*/
|
|
49 |
private IComponentParentNodeListener listener = null;
|
|
50 |
|
|
51 |
/**
|
|
52 |
* This information is used to select the correct icon
|
|
53 |
* by the label provider for the root component node.
|
|
54 |
*/
|
|
55 |
private boolean isRootComponent = false;
|
|
56 |
|
|
57 |
/**
|
|
58 |
* This flag is set to true if information for
|
|
59 |
* this component cannot be found from cache.
|
|
60 |
*/
|
|
61 |
private boolean isMissing = false;
|
|
62 |
|
|
63 |
/**
|
|
64 |
* This boolean flag is set to <code>true</code> after
|
|
65 |
* all direct children of this component are resolved.
|
|
66 |
*/
|
|
67 |
private boolean isDirectChildrensResolved = false;
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Original name of node, if concrete name was set
|
|
71 |
*/
|
|
72 |
private String originalName = null;
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Bind type of node, used when concrete name was set
|
|
76 |
*/
|
|
77 |
private CompBindType compBindType = CompBindType.NONE;
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Target platform for the component node, or <code>null</code> if not set.
|
|
81 |
*/
|
|
82 |
private ITargetPlatform targetPlatform = null;
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Constructor.
|
|
86 |
* @param name Node name.
|
|
87 |
*/
|
|
88 |
public ComponentParentNode(String name) {
|
|
89 |
super();
|
|
90 |
this.name = name;
|
|
91 |
children = new ArrayList<ComponentNode>();
|
|
92 |
}
|
|
93 |
|
|
94 |
/* (non-Javadoc)
|
|
95 |
* @see com.nokia.s60tools.appdep.core.data.ComponentNode#toString()
|
|
96 |
*/
|
|
97 |
public String toString() {
|
|
98 |
return getName();
|
|
99 |
}
|
|
100 |
|
|
101 |
/* (non-Javadoc)
|
|
102 |
* @see com.nokia.s60tools.appdep.core.data.ComponentNode#getName()
|
|
103 |
*/
|
|
104 |
public String getName() {
|
|
105 |
return name;
|
|
106 |
}
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Adds new child node.
|
|
110 |
* @param child child node to add
|
|
111 |
*/
|
|
112 |
public void addChild(ComponentNode child) {
|
|
113 |
addChild(child, children.size());
|
|
114 |
}
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Removes given child node.
|
|
118 |
* @param child child node to remove
|
|
119 |
*/
|
|
120 |
public void removeChild(ComponentNode child) {
|
|
121 |
children.remove(child);
|
|
122 |
child.setParent(null);
|
|
123 |
if(listener != null){
|
|
124 |
listener.childRemoved(child);
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Replaces a child node.
|
|
130 |
* @param childToBeRemoved child node to replace to
|
|
131 |
* @param childToBeAdded child node to replace with
|
|
132 |
*/
|
|
133 |
public void replaceChild(ComponentNode childToBeRemoved, ComponentNode childToBeAdded){
|
|
134 |
int index = children.indexOf(childToBeRemoved);
|
|
135 |
removeChild(childToBeRemoved);
|
|
136 |
addChild(childToBeAdded, index);
|
|
137 |
}
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Adds child to the specified index.
|
|
141 |
* @param childToBeAdded child node to be added.
|
|
142 |
* @param index index for addition.
|
|
143 |
*/
|
|
144 |
private void addChild(ComponentNode childToBeAdded, int index) {
|
|
145 |
children.add(index, childToBeAdded);
|
|
146 |
childToBeAdded.setParent(this);
|
|
147 |
if(listener != null){
|
|
148 |
listener.childAdded(childToBeAdded);
|
|
149 |
}
|
|
150 |
}
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Gets node's children.
|
|
154 |
* @return node's children.
|
|
155 |
*/
|
|
156 |
public ComponentNode [] getChildren() {
|
|
157 |
return (ComponentNode [])children.toArray(new ComponentNode[children.size()]);
|
|
158 |
}
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Checks if node has any children.
|
|
162 |
* @return <code>true</code> in case has children, otherwise <code>false</code>.
|
|
163 |
*/
|
|
164 |
public boolean hasChildren() {
|
|
165 |
return children.size()>0;
|
|
166 |
}
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Checks if node is root component.
|
|
170 |
* @return <code>true</code> if node is root component, otherwise <code>false</code>.
|
|
171 |
*/
|
|
172 |
public boolean isRootComponent() {
|
|
173 |
return isRootComponent;
|
|
174 |
}
|
|
175 |
|
|
176 |
/**
|
|
177 |
* Sets root component property.
|
|
178 |
* @param isRootComponent <code>true</code> if node is set to root component, otherwise <code>false</code>.
|
|
179 |
*/
|
|
180 |
public void setRootComponent(boolean isRootComponent) {
|
|
181 |
this.isRootComponent = isRootComponent;
|
|
182 |
}
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Checks missing status.
|
|
186 |
* @return Returns the isMissing.
|
|
187 |
*/
|
|
188 |
public boolean isMissing() {
|
|
189 |
return isMissing;
|
|
190 |
}
|
|
191 |
|
|
192 |
/**
|
|
193 |
* Sets missing status.
|
|
194 |
* @param isMissing The isMissing to set.
|
|
195 |
*/
|
|
196 |
public void setMissing(boolean isMissing) {
|
|
197 |
this.isMissing = isMissing;
|
|
198 |
}
|
|
199 |
|
|
200 |
/**
|
|
201 |
* Checks if direct dependencies for the node has been resolved.
|
|
202 |
* @return Returns the isDirectChildrensResolved.
|
|
203 |
*/
|
|
204 |
public boolean isDirectChildrensResolved() {
|
|
205 |
return isDirectChildrensResolved;
|
|
206 |
}
|
|
207 |
|
|
208 |
/**
|
|
209 |
* Sets status of direct dependencies resolvance.
|
|
210 |
* @param isDirectChildrensResolved The isDirectChildrensResolved to set.
|
|
211 |
*/
|
|
212 |
public void setDirectChildrensResolved(boolean isDirectChildrensResolved) {
|
|
213 |
this.isDirectChildrensResolved = isDirectChildrensResolved;
|
|
214 |
}
|
|
215 |
|
|
216 |
/**
|
|
217 |
* Removes all children nodes.
|
|
218 |
*/
|
|
219 |
public void removeAllChildren(){
|
|
220 |
children.clear();
|
|
221 |
if(listener != null){
|
|
222 |
listener.allChildrensRemoved();
|
|
223 |
}
|
|
224 |
}
|
|
225 |
|
|
226 |
/**
|
|
227 |
* Sets node listener.
|
|
228 |
* @param listener Listener to set.
|
|
229 |
*/
|
|
230 |
public void setNodeListener(IComponentParentNodeListener listener){
|
|
231 |
this.listener = listener;
|
|
232 |
}
|
|
233 |
|
|
234 |
/**
|
|
235 |
* Gets root node.
|
|
236 |
* @return root node.
|
|
237 |
*/
|
|
238 |
public ComponentParentNode getRootNode(){
|
|
239 |
if(this.isRootComponent){
|
|
240 |
return this;
|
|
241 |
}
|
|
242 |
else{
|
|
243 |
return getParent().getRootNode();
|
|
244 |
}
|
|
245 |
}
|
|
246 |
|
|
247 |
/* (non-Javadoc)
|
|
248 |
* @see com.nokia.s60tools.appdep.ui.views.data.IVisitable#accept(com.nokia.s60tools.appdep.ui.views.data.IVisitor)
|
|
249 |
*/
|
|
250 |
public void accept(IVisitor visitor) {
|
|
251 |
visitor.visit(this);
|
|
252 |
|
|
253 |
}
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Sets generic component name to concrete component name.
|
|
257 |
* Use only when found component that is generic a component, e.g. <code>hal.dll</code>
|
|
258 |
* and there is user selected or automatically selected concrete name for component.
|
|
259 |
* When component is missing {@link ComponentParentNode.isMissing()}
|
|
260 |
* component can be generic component.
|
|
261 |
* @param concreteComponentName Concrete component name.
|
|
262 |
* @param bindType of component, if it was user selected, then set {@link CompBindType.USER_BIND}
|
|
263 |
* if it was set automatically by preferences, then set {@link CompBindType.AUTO_BIND}
|
|
264 |
*/
|
|
265 |
public void setConcreteName(String concreteComponentName, CompBindType bindType) {
|
|
266 |
this.originalName = this.name;
|
|
267 |
this.name = concreteComponentName;
|
|
268 |
this.compBindType = bindType;
|
|
269 |
}
|
|
270 |
|
|
271 |
/**
|
|
272 |
* Return the original name of the component, if concrete name was set.
|
|
273 |
* @return the original name of component or <code>null</code> if component does not have a concrete name.
|
|
274 |
*/
|
|
275 |
public String getOriginalName() {
|
|
276 |
return originalName;
|
|
277 |
}
|
|
278 |
|
|
279 |
/**
|
|
280 |
* Check if component was a generic component originally and a concrete component
|
|
281 |
* was found to replacing it. To get original component name use @see ComponentParentNode.getOriginalName().
|
|
282 |
* @return <code>true</code> if component was a generic component and
|
|
283 |
* a concrete component was set to replace it, <code>false</code> otherwise.
|
|
284 |
*/
|
|
285 |
public boolean wasGenericComponent(){
|
|
286 |
return getOriginalName() == null ? false : true;
|
|
287 |
}
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Get bind type of component.
|
|
291 |
* @return <code>CompBindType.NONE</code> if this component is a concrete component by its own
|
|
292 |
* or it has not been set to concrete component,
|
|
293 |
* <code>CompBindType.AUTO_BIND</code> if component was set to concrete automatically by preference list,
|
|
294 |
* <code>CompBindType.USER_BIND</code> if component was set to concrete by user action with dialog.
|
|
295 |
*/
|
|
296 |
public CompBindType getGenericComponentBindType() {
|
|
297 |
return compBindType ;
|
|
298 |
}
|
|
299 |
|
|
300 |
/* (non-Javadoc)
|
|
301 |
* @see com.nokia.s60tools.appdep.core.data.ComponentNode#getTargetPlatform()
|
|
302 |
*/
|
|
303 |
@Override
|
|
304 |
public ITargetPlatform getTargetPlatform() {
|
|
305 |
return targetPlatform;
|
|
306 |
}
|
|
307 |
|
|
308 |
/**
|
|
309 |
* Sets target platform for the component node, or <code>null</code> if not set.
|
|
310 |
* @param targetPlatform target platform for the component node
|
|
311 |
*/
|
|
312 |
public void setTargetPlatform(ITargetPlatform targetPlatform) {
|
|
313 |
this.targetPlatform = targetPlatform;
|
|
314 |
}
|
|
315 |
|
|
316 |
} |