Skip to content

Package: AnnotationItemProviderAdapterFactory

AnnotationItemProviderAdapterFactory

nameinstructionbranchcomplexitylinemethod
AnnotationItemProviderAdapterFactory()
M: 0 C: 45
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 11
100%
M: 0 C: 1
100%
adapt(Notifier, Object)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
adapt(Object, Object)
M: 21 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
addListener(INotifyChangedListener)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
createAnnotationAdapter()
M: 0 C: 12
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
dispose()
M: 0 C: 7
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
fireNotifyChanged(Notification)
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getChildCreationExtenders()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getNewChildDescriptors(Object, EditingDomain)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getResourceLocator()
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%
getRootAdapterFactory()
M: 2 C: 7
78%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
100%
M: 0 C: 1
100%
isFactoryForType(Object)
M: 0 C: 13
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
removeListener(INotifyChangedListener)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setParentAdapterFactory(ComposedAdapterFactory)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (c) 2011-2015 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: * Johannes Faltermeier - initial API and implementation
13: */
14: package org.eclipse.emf.emfforms.spi.view.annotation.model.provider;
15:
16: import java.util.ArrayList;
17: import java.util.Collection;
18: import java.util.List;
19:
20: import org.eclipse.emf.common.notify.Adapter;
21: import org.eclipse.emf.common.notify.Notification;
22: import org.eclipse.emf.common.notify.Notifier;
23: import org.eclipse.emf.common.util.ResourceLocator;
24: import org.eclipse.emf.ecore.EObject;
25: import org.eclipse.emf.ecp.view.spi.model.VElement;
26: import org.eclipse.emf.ecp.view.spi.model.VViewPackage;
27: import org.eclipse.emf.ecp.view.spi.model.util.ViewSwitch;
28: import org.eclipse.emf.edit.command.CommandParameter;
29: import org.eclipse.emf.edit.domain.EditingDomain;
30: import org.eclipse.emf.edit.provider.ChangeNotifier;
31: import org.eclipse.emf.edit.provider.ChildCreationExtenderManager;
32: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
33: import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
34: import org.eclipse.emf.edit.provider.IChangeNotifier;
35: import org.eclipse.emf.edit.provider.IChildCreationExtender;
36: import org.eclipse.emf.edit.provider.IDisposable;
37: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
38: import org.eclipse.emf.edit.provider.IItemLabelProvider;
39: import org.eclipse.emf.edit.provider.IItemPropertySource;
40: import org.eclipse.emf.edit.provider.INotifyChangedListener;
41: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
42: import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
43: import org.eclipse.emf.emfforms.spi.view.annotation.model.VAnnotationFactory;
44: import org.eclipse.emf.emfforms.spi.view.annotation.model.VAnnotationPackage;
45: import org.eclipse.emf.emfforms.spi.view.annotation.model.util.AnnotationAdapterFactory;
46:
47: /**
48: * This is the factory that is used to provide the interfaces needed to support
49: * Viewers. The adapters generated by this factory convert EMF adapter
50: * notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}. The
51: * adapters also support Eclipse property sheets. Note that most of the adapters
52: * are shared among multiple instances. <!-- begin-user-doc --> <!--
53: * end-user-doc -->
54: *
55: * @generated
56: */
57: public class AnnotationItemProviderAdapterFactory extends AnnotationAdapterFactory
58:         implements ComposeableAdapterFactory, IChangeNotifier, IDisposable, IChildCreationExtender {
59:         /**
60:          * This keeps track of the root adapter factory that delegates to this
61:          * adapter factory. <!-- begin-user-doc --> <!-- end-user-doc -->
62:          *
63:          * @generated
64:          */
65:         protected ComposedAdapterFactory parentAdapterFactory;
66:
67:         /**
68:          * This is used to implement
69:          * {@link org.eclipse.emf.edit.provider.IChangeNotifier}. <!--
70:          * begin-user-doc --> <!-- end-user-doc -->
71:          *
72:          * @generated
73:          */
74:         protected IChangeNotifier changeNotifier = new ChangeNotifier();
75:
76:         /**
77:          * This helps manage the child creation extenders. <!-- begin-user-doc -->
78:          * <!-- end-user-doc -->
79:          *
80:          * @generated
81:          */
82:         protected ChildCreationExtenderManager childCreationExtenderManager = new ChildCreationExtenderManager(
83:                 AnnotationEditPlugin.INSTANCE, VAnnotationPackage.eNS_URI);
84:
85:         /**
86:          * This keeps track of all the supported types checked by
87:          * {@link #isFactoryForType isFactoryForType}. <!-- begin-user-doc --> <!--
88:          * end-user-doc -->
89:          *
90:          * @generated
91:          */
92:         protected Collection<Object> supportedTypes = new ArrayList<Object>();
93:
94:         /**
95:          * This constructs an instance. <!-- begin-user-doc --> <!-- end-user-doc
96:          * -->
97:          *
98:          * @generated
99:          */
100:         public AnnotationItemProviderAdapterFactory() {
101:                 supportedTypes.add(IEditingDomainItemProvider.class);
102:                 supportedTypes.add(IStructuredItemContentProvider.class);
103:                 supportedTypes.add(ITreeItemContentProvider.class);
104:                 supportedTypes.add(IItemLabelProvider.class);
105:                 supportedTypes.add(IItemPropertySource.class);
106:         }
107:
108:         /**
109:          * This keeps track of the one adapter used for all
110:          * {@link org.eclipse.emf.emfforms.spi.view.annotation.model.VAnnotation}
111:          * instances. <!-- begin-user-doc --> <!-- end-user-doc -->
112:          *
113:          * @generated
114:          */
115:         protected AnnotationItemProvider annotationItemProvider;
116:
117:         /**
118:          * This creates an adapter for a
119:          * {@link org.eclipse.emf.emfforms.spi.view.annotation.model.VAnnotation}.
120:          * <!-- begin-user-doc --> <!-- end-user-doc -->
121:          *
122:          * @generated
123:          */
124:         @Override
125:         public Adapter createAnnotationAdapter() {
126:•                if (annotationItemProvider == null) {
127:                         annotationItemProvider = new AnnotationItemProvider(this);
128:                 }
129:
130:                 return annotationItemProvider;
131:         }
132:
133:         /**
134:          * This returns the root adapter factory that contains this factory. <!--
135:          * begin-user-doc --> <!-- end-user-doc -->
136:          *
137:          * @generated
138:          */
139:         @Override
140:         public ComposeableAdapterFactory getRootAdapterFactory() {
141:•                return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
142:         }
143:
144:         /**
145:          * This sets the composed adapter factory that contains this factory. <!--
146:          * begin-user-doc --> <!-- end-user-doc -->
147:          *
148:          * @generated
149:          */
150:         @Override
151:         public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
152:                 this.parentAdapterFactory = parentAdapterFactory;
153:         }
154:
155:         /**
156:          * <!-- begin-user-doc --> <!-- end-user-doc -->
157:          *
158:          * @generated
159:          */
160:         @Override
161:         public boolean isFactoryForType(Object type) {
162:•                return supportedTypes.contains(type) || super.isFactoryForType(type);
163:         }
164:
165:         /**
166:          * This implementation substitutes the factory itself as the key for the
167:          * adapter. <!-- begin-user-doc --> <!-- end-user-doc -->
168:          *
169:          * @generated
170:          */
171:         @Override
172:         public Adapter adapt(Notifier notifier, Object type) {
173:                 return super.adapt(notifier, this);
174:         }
175:
176:         /**
177:          * <!-- begin-user-doc --> <!-- end-user-doc -->
178:          *
179:          * @generated
180:          */
181:         @Override
182:         public Object adapt(Object object, Object type) {
183:•                if (isFactoryForType(type)) {
184:                         final Object adapter = super.adapt(object, type);
185:•                        if (!(type instanceof Class<?>) || ((Class<?>) type).isInstance(adapter)) {
186:                                 return adapter;
187:                         }
188:                 }
189:
190:                 return null;
191:         }
192:
193:         /**
194:          * <!-- begin-user-doc --> <!-- end-user-doc -->
195:          *
196:          * @generated
197:          */
198:         public List<IChildCreationExtender> getChildCreationExtenders() {
199:                 return childCreationExtenderManager.getChildCreationExtenders();
200:         }
201:
202:         /**
203:          * <!-- begin-user-doc --> <!-- end-user-doc -->
204:          *
205:          * @generated
206:          */
207:         @Override
208:         public Collection<?> getNewChildDescriptors(Object object, EditingDomain editingDomain) {
209:                 return childCreationExtenderManager.getNewChildDescriptors(object, editingDomain);
210:         }
211:
212:         /**
213:          * <!-- begin-user-doc --> <!-- end-user-doc -->
214:          *
215:          * @generated
216:          */
217:         @Override
218:         public ResourceLocator getResourceLocator() {
219:                 return childCreationExtenderManager;
220:         }
221:
222:         /**
223:          * This adds a listener. <!-- begin-user-doc --> <!-- end-user-doc -->
224:          *
225:          * @generated
226:          */
227:         @Override
228:         public void addListener(INotifyChangedListener notifyChangedListener) {
229:                 changeNotifier.addListener(notifyChangedListener);
230:         }
231:
232:         /**
233:          * This removes a listener. <!-- begin-user-doc --> <!-- end-user-doc -->
234:          *
235:          * @generated
236:          */
237:         @Override
238:         public void removeListener(INotifyChangedListener notifyChangedListener) {
239:                 changeNotifier.removeListener(notifyChangedListener);
240:         }
241:
242:         /**
243:          * This delegates to {@link #changeNotifier} and to
244:          * {@link #parentAdapterFactory}. <!-- begin-user-doc --> <!-- end-user-doc
245:          * -->
246:          *
247:          * @generated
248:          */
249:         @Override
250:         public void fireNotifyChanged(Notification notification) {
251:                 changeNotifier.fireNotifyChanged(notification);
252:
253:•                if (parentAdapterFactory != null) {
254:                         parentAdapterFactory.fireNotifyChanged(notification);
255:                 }
256:         }
257:
258:         /**
259:          * This disposes all of the item providers created by this factory. <!--
260:          * begin-user-doc --> <!-- end-user-doc -->
261:          *
262:          * @generated
263:          */
264:         @Override
265:         public void dispose() {
266:•                if (annotationItemProvider != null) {
267:                         annotationItemProvider.dispose();
268:                 }
269:         }
270:
271:         /**
272:          * A child creation extender for the {@link VViewPackage}. <!--
273:          * begin-user-doc --> <!-- end-user-doc -->
274:          *
275:          * @generated
276:          */
277:         public static class ViewChildCreationExtender implements IChildCreationExtender {
278:                 /**
279:                  * The switch for creating child descriptors specific to each extended
280:                  * class. <!-- begin-user-doc --> <!-- end-user-doc -->
281:                  *
282:                  * @generated
283:                  */
284:                 protected static class CreationSwitch extends ViewSwitch<Object> {
285:                         /**
286:                          * The child descriptors being populated. <!-- begin-user-doc -->
287:                          * <!-- end-user-doc -->
288:                          *
289:                          * @generated
290:                          */
291:                         protected List<Object> newChildDescriptors;
292:
293:                         /**
294:                          * The domain in which to create the children. <!-- begin-user-doc
295:                          * --> <!-- end-user-doc -->
296:                          *
297:                          * @generated
298:                          */
299:                         protected EditingDomain editingDomain;
300:
301:                         /**
302:                          * Creates the a switch for populating child descriptors in the
303:                          * given domain. <!-- begin-user-doc --> <!-- end-user-doc -->
304:                          *
305:                          * @generated
306:                          */
307:                         CreationSwitch(List<Object> newChildDescriptors, EditingDomain editingDomain) {
308:                                 this.newChildDescriptors = newChildDescriptors;
309:                                 this.editingDomain = editingDomain;
310:                         }
311:
312:                         /**
313:                          * <!-- begin-user-doc --> <!-- end-user-doc -->
314:                          *
315:                          * @generated
316:                          */
317:                         @Override
318:                         public Object caseElement(VElement object) {
319:                                 newChildDescriptors.add(createChildParameter(VViewPackage.Literals.ELEMENT__ATTACHMENTS,
320:                                         VAnnotationFactory.eINSTANCE.createAnnotation()));
321:
322:                                 return null;
323:                         }
324:
325:                         /**
326:                          * <!-- begin-user-doc --> <!-- end-user-doc -->
327:                          *
328:                          * @generated
329:                          */
330:                         protected CommandParameter createChildParameter(Object feature, Object child) {
331:                                 return new CommandParameter(null, feature, child);
332:                         }
333:
334:                 }
335:
336:                 /**
337:                  * <!-- begin-user-doc --> <!-- end-user-doc -->
338:                  *
339:                  * @generated
340:                  */
341:                 @Override
342:                 public Collection<Object> getNewChildDescriptors(Object object, EditingDomain editingDomain) {
343:                         final ArrayList<Object> result = new ArrayList<Object>();
344:                         new CreationSwitch(result, editingDomain).doSwitch((EObject) object);
345:                         return result;
346:                 }
347:
348:                 /**
349:                  * <!-- begin-user-doc --> <!-- end-user-doc -->
350:                  *
351:                  * @generated
352:                  */
353:                 @Override
354:                 public ResourceLocator getResourceLocator() {
355:                         return AnnotationEditPlugin.INSTANCE;
356:                 }
357:         }
358:
359: }