Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a1754e87d0d468e32fc52f2b85ac4af62799cb51 (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
/**
 * Copyright (c) 2012 Mia-Software.
 * 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:
 *    Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
 *    Gregoire Dupe (Mia-Software) - Bug 386387 - [CustomizedTreeContentProvider] The TreeElements are not preserved between two calls to getElements()
 */
package org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.impl;

import java.util.LinkedList;
import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EStructuralFeatureTreeElement;

/**
 * An implementation of the model object '<em><b>EObject Tree Element</b></em>'.
 * <p>
 * The following features are implemented:
 * <ul>
 * <li>{@link org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.impl.EObjectTreeElementImpl#getEObject <em>EObject</em>}</li>
 * <li>{@link org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.impl.EObjectTreeElementImpl#getSfTreeElmement <em>Sf Tree
 * Elmement</em>}</li>
 * <li>{@link org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.impl.EObjectTreeElementImpl#getParent <em>Parent</em>}</li>
 * </ul>
 * </p>
 *
 */
public class EObjectTreeElementImpl extends TreeElementImpl implements EObjectTreeElement {

	/**
	 * The cached value of the '{@link #getEObject() <em>EObject</em>}' reference.
	 *
	 * @see #getEObject()
	 */
	protected EObject eObject;

	/**
	 * The cached value of the '{@link #getSfTreeElmement() <em>Sf Tree Elmement</em>}' containment reference list.
	 *
	 * @see #getSfTreeElmement()
	 */
	protected List<EStructuralFeatureTreeElement> sfTreeElmement;

	protected EObjectTreeElementImpl() {
		super();
	}

	public EObject getEObject() {
		return eObject;
	}

	public EObject basicGetEObject() {
		return eObject;
	}

	public void setEObject(EObject newEObject) {
		eObject = newEObject;
	}

	public List<EStructuralFeatureTreeElement> getSfTreeElmement() {
		if(sfTreeElmement == null) {
			sfTreeElmement = new LinkedList<EStructuralFeatureTreeElement>();
		}
		return sfTreeElmement;
	}

	/**
	 * Try to adapt this object to the requested type.
	 * Check if the underlying EObject ({@link #getEObject()}) can be adapted to the requested type.
	 *
	 * @param key
	 * @return
	 */
	public Object getAdapter(Class key) {
		// Check if the underlying EObject can request to the adaptation
		Object model = getEObject();

		if(key.isInstance(model)) {
			return model;
		} else {
			// Try the platform process
			//			return Platform.getAdapterManager().getAdapter(model, key);
			return null;
		}
	}

} //EObjectTreeElementImpl

Back to the top