Debian Codegraph @

plugins/org.eclipse.emf.gwt.edit/src/org/eclipse/emf/edit/tree/impl/TreeNodeImpl.java

raw
1 /**
2 * Copyright (c) 2002-2010 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v2.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v20.html
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 */
11 package org.eclipse.emf.edit.tree.impl;
12
13
14 import com.google.gwt.user.client.rpc.GwtTransient;
15 import java.util.Collection;
16
17 import org.eclipse.emf.common.notify.Notification;
18 import org.eclipse.emf.common.notify.NotificationChain;
19 import org.eclipse.emf.common.util.EList;
20 import org.eclipse.emf.ecore.EClass;
21 import org.eclipse.emf.ecore.EObject;
22 import org.eclipse.emf.ecore.InternalEObject;
23 import org.eclipse.emf.ecore.impl.ENotificationImpl;
24 import org.eclipse.emf.ecore.impl.EObjectImpl;
25 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
26 import org.eclipse.emf.ecore.util.EcoreUtil;
27 import org.eclipse.emf.ecore.util.InternalEList;
28 import org.eclipse.emf.edit.tree.TreeNode;
29 import org.eclipse.emf.edit.tree.TreePackage;
30
31
32 /**
33 * <!-- begin-user-doc -->
34 * An implementation of the model object '<em><b>Node</b></em>'.
35 * <!-- end-user-doc -->
36 * <p>
37 * The following features are implemented:
38 * </p>
39 * <ul>
40 * <li>{@link org.eclipse.emf.edit.tree.impl.TreeNodeImpl#getParent <em>Parent</em>}</li>
41 * <li>{@link org.eclipse.emf.edit.tree.impl.TreeNodeImpl#getChildren <em>Children</em>}</li>
42 * <li>{@link org.eclipse.emf.edit.tree.impl.TreeNodeImpl#getData <em>Data</em>}</li>
43 * </ul>
44 *
45 * @generated
46 */
47 public class TreeNodeImpl extends EObjectImpl implements TreeNode
48 {
49 /**
50 * The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list.
51 * <!-- begin-user-doc -->
52 * <!-- end-user-doc -->
53 * @see #getChildren()
54 * @generated
55 * @ordered
56 */
57 @GwtTransient
58 protected EList<TreeNode> children;
59
60 /**
61 * The cached value of the '{@link #getData() <em>Data</em>}' reference.
62 * <!-- begin-user-doc -->
63 * <!-- end-user-doc -->
64 * @see #getData()
65 * @generated
66 * @ordered
67 */
68 @GwtTransient
69 protected EObject data;
70
71 /**
72 * <!-- begin-user-doc -->
73 * <!-- end-user-doc -->
74 * @generated modifiable
75 */
76 protected TreeNodeImpl()
77 {
78 super();
79 }
80
81 /**
82 * <!-- begin-user-doc -->
83 * <!-- end-user-doc -->
84 * @generated
85 */
86 @Override
87 protected EClass eStaticClass()
88 {
89 return TreePackage.Literals.TREE_NODE;
90 }
91
92 /**
93 * <!-- begin-user-doc -->
94 * <!-- end-user-doc -->
95 * @generated
96 */
97 @Override
98 public TreeNode getParent()
99 {
100 if (eContainerFeatureID() != TreePackage.TREE_NODE__PARENT) return null;
101 return (TreeNode)eInternalContainer();
102 }
103
104 /**
105 * <!-- begin-user-doc -->
106 * <!-- end-user-doc -->
107 * @generated
108 */
109 public NotificationChain basicSetParent(TreeNode newParent, NotificationChain msgs)
110 {
111 msgs = eBasicSetContainer((InternalEObject)newParent, TreePackage.TREE_NODE__PARENT, msgs);
112 return msgs;
113 }
114
115 /**
116 * <!-- begin-user-doc -->
117 * <!-- end-user-doc -->
118 * @generated
119 */
120 @Override
121 public void setParent(TreeNode newParent)
122 {
123 if (newParent != eInternalContainer() || (eContainerFeatureID() != TreePackage.TREE_NODE__PARENT && newParent != null))
124 {
125 if (EcoreUtil.isAncestor(this, newParent))
126 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
127 NotificationChain msgs = null;
128 if (eInternalContainer() != null)
129 msgs = eBasicRemoveFromContainer(msgs);
130 if (newParent != null)
131 msgs = ((InternalEObject)newParent).eInverseAdd(this, TreePackage.TREE_NODE__CHILDREN, TreeNode.class, msgs);
132 msgs = basicSetParent(newParent, msgs);
133 if (msgs != null) msgs.dispatch();
134 }
135 else if (eNotificationRequired())
136 eNotify(new ENotificationImpl(this, Notification.SET, TreePackage.TREE_NODE__PARENT, newParent, newParent));
137 }
138
139 /**
140 * <!-- begin-user-doc -->
141 * <!-- end-user-doc -->
142 * @generated
143 */
144 @Override
145 public EList<TreeNode> getChildren()
146 {
147 if (children == null)
148 {
149 children = new EObjectContainmentWithInverseEList<TreeNode>(TreeNode.class, this, TreePackage.TREE_NODE__CHILDREN, TreePackage.TREE_NODE__PARENT);
150 }
151 return children;
152 }
153
154 /**
155 * <!-- begin-user-doc -->
156 * <!-- end-user-doc -->
157 * @generated
158 */
159 @Override
160 public EObject getData()
161 {
162 if (data != null && data.eIsProxy())
163 {
164 InternalEObject oldData = (InternalEObject)data;
165 data = eResolveProxy(oldData);
166 if (data != oldData)
167 {
168 if (eNotificationRequired())
169 eNotify(new ENotificationImpl(this, Notification.RESOLVE, TreePackage.TREE_NODE__DATA, oldData, data));
170 }
171 }
172 return data;
173 }
174
175 /**
176 * <!-- begin-user-doc -->
177 * <!-- end-user-doc -->
178 * @generated
179 */
180 public EObject basicGetData()
181 {
182 return data;
183 }
184
185 /**
186 * <!-- begin-user-doc -->
187 * <!-- end-user-doc -->
188 * @generated
189 */
190 @Override
191 public void setData(EObject newData)
192 {
193 EObject oldData = data;
194 data = newData;
195 if (eNotificationRequired())
196 eNotify(new ENotificationImpl(this, Notification.SET, TreePackage.TREE_NODE__DATA, oldData, data));
197 }
198
199 /**
200 * <!-- begin-user-doc -->
201 * <!-- end-user-doc -->
202 * @generated
203 */
204 @SuppressWarnings("unchecked")
205 @Override
206 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
207 {
208 switch (featureID)
209 {
210 case TreePackage.TREE_NODE__PARENT:
211 if (eInternalContainer() != null)
212 msgs = eBasicRemoveFromContainer(msgs);
213 return basicSetParent((TreeNode)otherEnd, msgs);
214 case TreePackage.TREE_NODE__CHILDREN:
215 return ((InternalEList<InternalEObject>)(InternalEList<?>)getChildren()).basicAdd(otherEnd, msgs);
216 }
217 return super.eInverseAdd(otherEnd, featureID, msgs);
218 }
219
220 /**
221 * <!-- begin-user-doc -->
222 * <!-- end-user-doc -->
223 * @generated
224 */
225 @Override
226 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
227 {
228 switch (featureID)
229 {
230 case TreePackage.TREE_NODE__PARENT:
231 return basicSetParent(null, msgs);
232 case TreePackage.TREE_NODE__CHILDREN:
233 return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs);
234 }
235 return super.eInverseRemove(otherEnd, featureID, msgs);
236 }
237
238 /**
239 * <!-- begin-user-doc -->
240 * <!-- end-user-doc -->
241 * @generated
242 */
243 @Override
244 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs)
245 {
246 switch (eContainerFeatureID())
247 {
248 case TreePackage.TREE_NODE__PARENT:
249 return eInternalContainer().eInverseRemove(this, TreePackage.TREE_NODE__CHILDREN, TreeNode.class, msgs);
250 }
251 return super.eBasicRemoveFromContainerFeature(msgs);
252 }
253
254 /**
255 * <!-- begin-user-doc -->
256 * <!-- end-user-doc -->
257 * @generated
258 */
259 @Override
260 public Object eGet(int featureID, boolean resolve, boolean coreType)
261 {
262 switch (featureID)
263 {
264 case TreePackage.TREE_NODE__PARENT:
265 return getParent();
266 case TreePackage.TREE_NODE__CHILDREN:
267 return getChildren();
268 case TreePackage.TREE_NODE__DATA:
269 if (resolve) return getData();
270 return basicGetData();
271 }
272 return super.eGet(featureID, resolve, coreType);
273 }
274
275 /**
276 * <!-- begin-user-doc -->
277 * <!-- end-user-doc -->
278 * @generated
279 */
280 @SuppressWarnings("unchecked")
281 @Override
282 public void eSet(int featureID, Object newValue)
283 {
284 switch (featureID)
285 {
286 case TreePackage.TREE_NODE__PARENT:
287 setParent((TreeNode)newValue);
288 return;
289 case TreePackage.TREE_NODE__CHILDREN:
290 getChildren().clear();
291 getChildren().addAll((Collection<? extends TreeNode>)newValue);
292 return;
293 case TreePackage.TREE_NODE__DATA:
294 setData((EObject)newValue);
295 return;
296 }
297 super.eSet(featureID, newValue);
298 }
299
300 /**
301 * <!-- begin-user-doc -->
302 * <!-- end-user-doc -->
303 * @generated
304 */
305 @Override
306 public void eUnset(int featureID)
307 {
308 switch (featureID)
309 {
310 case TreePackage.TREE_NODE__PARENT:
311 setParent((TreeNode)null);
312 return;
313 case TreePackage.TREE_NODE__CHILDREN:
314 getChildren().clear();
315 return;
316 case TreePackage.TREE_NODE__DATA:
317 setData((EObject)null);
318 return;
319 }
320 super.eUnset(featureID);
321 }
322
323 /**
324 * <!-- begin-user-doc -->
325 * <!-- end-user-doc -->
326 * @generated
327 */
328 @Override
329 public boolean eIsSet(int featureID)
330 {
331 switch (featureID)
332 {
333 case TreePackage.TREE_NODE__PARENT:
334 return getParent() != null;
335 case TreePackage.TREE_NODE__CHILDREN:
336 return children != null && !children.isEmpty();
337 case TreePackage.TREE_NODE__DATA:
338 return data != null;
339 }
340 return super.eIsSet(featureID);
341 }
342
343 } //TreeNodeImpl