Skip to content

Package: VTDomainModelReferenceSelectorImpl

VTDomainModelReferenceSelectorImpl

nameinstructionbranchcomplexitylinemethod
VTDomainModelReferenceSelectorImpl()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
basicGetRootEClass()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
basicSetDomainModelReference(VDomainModelReference, NotificationChain)
M: 4 C: 25
86%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 10
91%
M: 0 C: 1
100%
eGet(int, boolean, boolean)
M: 14 C: 5
26%
M: 4 C: 1
20%
M: 3 C: 1
25%
M: 4 C: 2
33%
M: 0 C: 1
100%
eInverseRemove(InternalEObject, int, NotificationChain)
M: 13 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
eIsSet(int)
M: 6 C: 14
70%
M: 2 C: 5
71%
M: 2 C: 3
60%
M: 1 C: 3
75%
M: 0 C: 1
100%
eSet(int, Object)
M: 5 C: 12
71%
M: 1 C: 2
67%
M: 1 C: 2
67%
M: 2 C: 5
71%
M: 0 C: 1
100%
eStaticClass()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
eUnset(int)
M: 4 C: 10
71%
M: 1 C: 2
67%
M: 1 C: 2
67%
M: 2 C: 5
71%
M: 0 C: 1
100%
getDomainModelReference()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRootEClass()
M: 28 C: 10
26%
M: 5 C: 3
38%
M: 3 C: 2
40%
M: 7 C: 2
22%
M: 0 C: 1
100%
isApplicable(VElement, ViewModelContext)
M: 0 C: 108
100%
M: 0 C: 12
100%
M: 0 C: 7
100%
M: 0 C: 31
100%
M: 0 C: 1
100%
setDomainModelReference(VDomainModelReference)
M: 13 C: 39
75%
M: 3 C: 7
70%
M: 2 C: 4
67%
M: 3 C: 15
83%
M: 0 C: 1
100%
setRootEClass(EClass)
M: 0 C: 21
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * EclipseSource Munich - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.view.template.selector.domainmodelreference.model.impl;
15:
16: import org.eclipse.core.databinding.observable.IObserving;
17: import org.eclipse.core.databinding.observable.value.IObservableValue;
18: import org.eclipse.emf.common.notify.Notification;
19: import org.eclipse.emf.common.notify.NotificationChain;
20: import org.eclipse.emf.ecore.EClass;
21: import org.eclipse.emf.ecore.EObject;
22: import org.eclipse.emf.ecore.EStructuralFeature;
23: import org.eclipse.emf.ecore.InternalEObject;
24: import org.eclipse.emf.ecore.impl.ENotificationImpl;
25: import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
26: import org.eclipse.emf.ecp.common.spi.UniqueSetting;
27: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
28: import org.eclipse.emf.ecp.view.spi.model.VControl;
29: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
30: import org.eclipse.emf.ecp.view.spi.model.VElement;
31: import org.eclipse.emf.ecp.view.template.selector.domainmodelreference.model.VTDomainModelReferenceSelector;
32: import org.eclipse.emf.ecp.view.template.selector.domainmodelreference.model.VTDomainmodelreferencePackage;
33: import org.eclipse.emfforms.spi.common.report.ReportService;
34: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
35: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedReport;
36: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
37:
38: /**
39: * <!-- begin-user-doc -->
40: * An implementation of the model object '<em><b>Domain Model Reference Selector</b></em>'.
41: * <!-- end-user-doc -->
42: * <p>
43: * The following features are implemented:
44: * </p>
45: * <ul>
46: * <li>{@link org.eclipse.emf.ecp.view.template.selector.domainmodelreference.model.impl.VTDomainModelReferenceSelectorImpl#getDomainModelReference
47: * <em>Domain Model Reference</em>}</li>
48: * <li>{@link org.eclipse.emf.ecp.view.template.selector.domainmodelreference.model.impl.VTDomainModelReferenceSelectorImpl#getRootEClass
49: * <em>Root EClass</em>}</li>
50: * </ul>
51: *
52: * @generated
53: */
54: public class VTDomainModelReferenceSelectorImpl extends MinimalEObjectImpl.Container implements
55:         VTDomainModelReferenceSelector {
56:         /**
57:          * The cached value of the '{@link #getDomainModelReference() <em>Domain Model Reference</em>}' containment
58:          * reference.
59:          * <!-- begin-user-doc -->
60:          * <!-- end-user-doc -->
61:          *
62:          * @see #getDomainModelReference()
63:          * @generated
64:          * @ordered
65:          */
66:         protected VDomainModelReference domainModelReference;
67:
68:         /**
69:          * The cached value of the '{@link #getRootEClass() <em>Root EClass</em>}' reference.
70:          * <!-- begin-user-doc -->
71:          * <!-- end-user-doc -->
72:          *
73:          * @see #getRootEClass()
74:          * @generated
75:          * @ordered
76:          */
77:         protected EClass rootEClass;
78:
79:         /**
80:          * <!-- begin-user-doc -->
81:          * <!-- end-user-doc -->
82:          *
83:          * @generated
84:          */
85:         protected VTDomainModelReferenceSelectorImpl() {
86:                 super();
87:         }
88:
89:         /**
90:          * <!-- begin-user-doc -->
91:          * <!-- end-user-doc -->
92:          *
93:          * @generated
94:          */
95:         @Override
96:         protected EClass eStaticClass() {
97:                 return VTDomainmodelreferencePackage.Literals.DOMAIN_MODEL_REFERENCE_SELECTOR;
98:         }
99:
100:         /**
101:          * <!-- begin-user-doc -->
102:          * <!-- end-user-doc -->
103:          *
104:          * @generated
105:          */
106:         @Override
107:         public VDomainModelReference getDomainModelReference() {
108:                 return domainModelReference;
109:         }
110:
111:         /**
112:          * <!-- begin-user-doc -->
113:          * <!-- end-user-doc -->
114:          *
115:          * @generated
116:          */
117:         public NotificationChain basicSetDomainModelReference(VDomainModelReference newDomainModelReference,
118:                 NotificationChain msgs) {
119:                 final VDomainModelReference oldDomainModelReference = domainModelReference;
120:                 domainModelReference = newDomainModelReference;
121:•                if (eNotificationRequired()) {
122:                         final ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
123:                                 VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__DOMAIN_MODEL_REFERENCE,
124:                                 oldDomainModelReference, newDomainModelReference);
125:•                        if (msgs == null) {
126:                                 msgs = notification;
127:                         } else {
128:                                 msgs.add(notification);
129:                         }
130:                 }
131:                 return msgs;
132:         }
133:
134:         /**
135:          * <!-- begin-user-doc -->
136:          * <!-- end-user-doc -->
137:          *
138:          * @generated
139:          */
140:         @Override
141:         public void setDomainModelReference(VDomainModelReference newDomainModelReference) {
142:•                if (newDomainModelReference != domainModelReference) {
143:                         NotificationChain msgs = null;
144:•                        if (domainModelReference != null) {
145:                                 msgs = ((InternalEObject) domainModelReference).eInverseRemove(this,
146:                                         EOPPOSITE_FEATURE_BASE
147:                                                 - VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__DOMAIN_MODEL_REFERENCE,
148:                                         null, msgs);
149:                         }
150:•                        if (newDomainModelReference != null) {
151:                                 msgs = ((InternalEObject) newDomainModelReference).eInverseAdd(this,
152:                                         EOPPOSITE_FEATURE_BASE
153:                                                 - VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__DOMAIN_MODEL_REFERENCE,
154:                                         null, msgs);
155:                         }
156:                         msgs = basicSetDomainModelReference(newDomainModelReference, msgs);
157:•                        if (msgs != null) {
158:                                 msgs.dispatch();
159:                         }
160:•                } else if (eNotificationRequired()) {
161:                         eNotify(new ENotificationImpl(this, Notification.SET,
162:                                 VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__DOMAIN_MODEL_REFERENCE,
163:                                 newDomainModelReference, newDomainModelReference));
164:                 }
165:         }
166:
167:         /**
168:          * <!-- begin-user-doc -->
169:          * <!-- end-user-doc -->
170:          *
171:          * @generated
172:          */
173:         @Override
174:         public EClass getRootEClass() {
175:•                if (rootEClass != null && rootEClass.eIsProxy()) {
176:                         final InternalEObject oldRootEClass = (InternalEObject) rootEClass;
177:                         rootEClass = (EClass) eResolveProxy(oldRootEClass);
178:•                        if (rootEClass != oldRootEClass) {
179:•                                if (eNotificationRequired()) {
180:                                         eNotify(new ENotificationImpl(this, Notification.RESOLVE,
181:                                                 VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__ROOT_ECLASS, oldRootEClass,
182:                                                 rootEClass));
183:                                 }
184:                         }
185:                 }
186:                 return rootEClass;
187:         }
188:
189:         /**
190:          * <!-- begin-user-doc -->
191:          * <!-- end-user-doc -->
192:          *
193:          * @generated
194:          */
195:         public EClass basicGetRootEClass() {
196:                 return rootEClass;
197:         }
198:
199:         /**
200:          * <!-- begin-user-doc -->
201:          * <!-- end-user-doc -->
202:          *
203:          * @generated
204:          */
205:         @Override
206:         public void setRootEClass(EClass newRootEClass) {
207:                 final EClass oldRootEClass = rootEClass;
208:                 rootEClass = newRootEClass;
209:•                if (eNotificationRequired()) {
210:                         eNotify(new ENotificationImpl(this, Notification.SET,
211:                                 VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__ROOT_ECLASS, oldRootEClass, rootEClass));
212:                 }
213:         }
214:
215:         /**
216:          * <!-- begin-user-doc -->
217:          * <!-- end-user-doc -->
218:          *
219:          * @generated
220:          */
221:         @Override
222:         public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
223:•                switch (featureID) {
224:                 case VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__DOMAIN_MODEL_REFERENCE:
225:                         return basicSetDomainModelReference(null, msgs);
226:                 }
227:                 return super.eInverseRemove(otherEnd, featureID, msgs);
228:         }
229:
230:         /**
231:          * <!-- begin-user-doc -->
232:          * <!-- end-user-doc -->
233:          *
234:          * @generated
235:          */
236:         @Override
237:         public Object eGet(int featureID, boolean resolve, boolean coreType) {
238:•                switch (featureID) {
239:                 case VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__DOMAIN_MODEL_REFERENCE:
240:                         return getDomainModelReference();
241:                 case VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__ROOT_ECLASS:
242:•                        if (resolve) {
243:                                 return getRootEClass();
244:                         }
245:                         return basicGetRootEClass();
246:                 }
247:                 return super.eGet(featureID, resolve, coreType);
248:         }
249:
250:         /**
251:          * <!-- begin-user-doc -->
252:          * <!-- end-user-doc -->
253:          *
254:          * @generated
255:          */
256:         @Override
257:         public void eSet(int featureID, Object newValue) {
258:•                switch (featureID) {
259:                 case VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__DOMAIN_MODEL_REFERENCE:
260:                         setDomainModelReference((VDomainModelReference) newValue);
261:                         return;
262:                 case VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__ROOT_ECLASS:
263:                         setRootEClass((EClass) newValue);
264:                         return;
265:                 }
266:                 super.eSet(featureID, newValue);
267:         }
268:
269:         /**
270:          * <!-- begin-user-doc -->
271:          * <!-- end-user-doc -->
272:          *
273:          * @generated
274:          */
275:         @Override
276:         public void eUnset(int featureID) {
277:•                switch (featureID) {
278:                 case VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__DOMAIN_MODEL_REFERENCE:
279:                         setDomainModelReference((VDomainModelReference) null);
280:                         return;
281:                 case VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__ROOT_ECLASS:
282:                         setRootEClass((EClass) null);
283:                         return;
284:                 }
285:                 super.eUnset(featureID);
286:         }
287:
288:         /**
289:          * <!-- begin-user-doc -->
290:          * <!-- end-user-doc -->
291:          *
292:          * @generated
293:          */
294:         @Override
295:         public boolean eIsSet(int featureID) {
296:•                switch (featureID) {
297:                 case VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__DOMAIN_MODEL_REFERENCE:
298:•                        return domainModelReference != null;
299:                 case VTDomainmodelreferencePackage.DOMAIN_MODEL_REFERENCE_SELECTOR__ROOT_ECLASS:
300:•                        return rootEClass != null;
301:                 }
302:                 return super.eIsSet(featureID);
303:         }
304:
305:         @Override
306:         public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
307:•                if (!VControl.class.isInstance(vElement)) {
308:                         return NOT_APPLICABLE;
309:                 }
310:                 final VDomainModelReference controlDomainModelReference = VControl.class.cast(vElement)
311:                         .getDomainModelReference();
312:•                if (controlDomainModelReference == null) {
313:                         return NOT_APPLICABLE;
314:                 }
315:•                if (getRootEClass() != null) {
316:•                        if (!getRootEClass().isSuperTypeOf(viewModelContext.getDomainModel().eClass())) {
317:                                 return NOT_APPLICABLE;
318:                         }
319:•                } else if (!getDomainModelReference().getSegments().isEmpty()) {
320:                         // TODO report warning or error?
321:                         return NOT_APPLICABLE;
322:                 }
323:
324:                 IObservableValue<?> controlObservableValue;
325:                 IObservableValue<?> selectorObservableValue;
326:                 try {
327:                         final EMFFormsDatabinding emfFormsDatabinding = viewModelContext.getService(EMFFormsDatabinding.class);
328:                         controlObservableValue = emfFormsDatabinding
329:                                 .getObservableValue(controlDomainModelReference, viewModelContext.getDomainModel());
330:                         selectorObservableValue = emfFormsDatabinding
331:                                 .getObservableValue(getDomainModelReference(), viewModelContext.getDomainModel());
332:                 } catch (final DatabindingFailedException ex) {
333:                         viewModelContext.getService(ReportService.class).report(new DatabindingFailedReport(ex));
334:                         return NOT_APPLICABLE;
335:                 }
336:                 final EObject controlEObject = (EObject) ((IObserving) controlObservableValue).getObserved();
337:                 final EStructuralFeature controlStructuralFeature = (EStructuralFeature) controlObservableValue.getValueType();
338:                 final EObject selectorEObject = (EObject) ((IObserving) selectorObservableValue).getObserved();
339:                 final EStructuralFeature selectorStructuralFeature = (EStructuralFeature) selectorObservableValue
340:                         .getValueType();
341:                 controlObservableValue.dispose();
342:                 selectorObservableValue.dispose();
343:
344:                 final boolean equal = UniqueSetting.createSetting(selectorEObject, selectorStructuralFeature).equals(
345:                         UniqueSetting.createSetting(controlEObject, controlStructuralFeature));
346:•                if (!equal) {
347:                         return NOT_APPLICABLE;
348:                 }
349:
350:                 return 10;
351:         }
352:
353: } // VTDomainModelReferenceSelectorImpl