Skip to content

Package: ValidationItemProviderAdapterFactory

ValidationItemProviderAdapterFactory

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