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