Skip to content

Package: ControlgridItemProviderAdapterFactory

ControlgridItemProviderAdapterFactory

nameinstructionbranchcomplexitylinemethod
ControlgridItemProviderAdapterFactory()
M: 45 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
adapt(Notifier, Object)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
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%
createControlGridAdapter()
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
createControlGridCellAdapter()
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
createControlGridRowAdapter()
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
dispose()
M: 19 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 7 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: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
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: 13 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
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: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

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.controlgrid.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.VContainer;
26: import org.eclipse.emf.ecp.view.spi.model.VView;
27: import org.eclipse.emf.ecp.view.spi.model.VViewPackage;
28: import org.eclipse.emf.ecp.view.spi.model.util.ViewSwitch;
29: import org.eclipse.emf.edit.command.CommandParameter;
30: import org.eclipse.emf.edit.domain.EditingDomain;
31: import org.eclipse.emf.edit.provider.ChangeNotifier;
32: import org.eclipse.emf.edit.provider.ChildCreationExtenderManager;
33: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
34: import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
35: import org.eclipse.emf.edit.provider.IChangeNotifier;
36: import org.eclipse.emf.edit.provider.IChildCreationExtender;
37: import org.eclipse.emf.edit.provider.IDisposable;
38: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
39: import org.eclipse.emf.edit.provider.IItemLabelProvider;
40: import org.eclipse.emf.edit.provider.IItemPropertySource;
41: import org.eclipse.emf.edit.provider.INotifyChangedListener;
42: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
43: import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
44: import org.eclipse.emf.emfforms.spi.view.controlgrid.model.VControlgridFactory;
45: import org.eclipse.emf.emfforms.spi.view.controlgrid.model.VControlgridPackage;
46: import org.eclipse.emf.emfforms.spi.view.controlgrid.model.util.ControlgridAdapterFactory;
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 ControlgridItemProviderAdapterFactory extends ControlgridAdapterFactory
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:                 ControlgridEditPlugin.INSTANCE, VControlgridPackage.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 ControlgridItemProviderAdapterFactory() {
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.emfforms.spi.view.controlgrid.model.VControlGrid} instances.
116:          * <!-- begin-user-doc -->
117:          * <!-- end-user-doc -->
118:          *
119:          * @generated
120:          */
121:         protected ControlGridItemProvider controlGridItemProvider;
122:
123:         /**
124:          * This creates an adapter for a {@link org.eclipse.emf.emfforms.spi.view.controlgrid.model.VControlGrid}.
125:          * <!-- begin-user-doc -->
126:          * <!-- end-user-doc -->
127:          *
128:          * @generated
129:          */
130:         @Override
131:         public Adapter createControlGridAdapter() {
132:•                if (controlGridItemProvider == null) {
133:                         controlGridItemProvider = new ControlGridItemProvider(this);
134:                 }
135:
136:                 return controlGridItemProvider;
137:         }
138:
139:         /**
140:          * This keeps track of the one adapter used for all
141:          * {@link org.eclipse.emf.emfforms.spi.view.controlgrid.model.VControlGridRow} instances.
142:          * <!-- begin-user-doc -->
143:          * <!-- end-user-doc -->
144:          *
145:          * @generated
146:          */
147:         protected ControlGridRowItemProvider controlGridRowItemProvider;
148:
149:         /**
150:          * This creates an adapter for a {@link org.eclipse.emf.emfforms.spi.view.controlgrid.model.VControlGridRow}.
151:          * <!-- begin-user-doc -->
152:          * <!-- end-user-doc -->
153:          *
154:          * @generated
155:          */
156:         @Override
157:         public Adapter createControlGridRowAdapter() {
158:•                if (controlGridRowItemProvider == null) {
159:                         controlGridRowItemProvider = new ControlGridRowItemProvider(this);
160:                 }
161:
162:                 return controlGridRowItemProvider;
163:         }
164:
165:         /**
166:          * This keeps track of the one adapter used for all
167:          * {@link org.eclipse.emf.emfforms.spi.view.controlgrid.model.VControlGridCell} instances.
168:          * <!-- begin-user-doc -->
169:          * <!-- end-user-doc -->
170:          *
171:          * @generated
172:          */
173:         protected ControlGridCellItemProvider controlGridCellItemProvider;
174:
175:         /**
176:          * This creates an adapter for a {@link org.eclipse.emf.emfforms.spi.view.controlgrid.model.VControlGridCell}.
177:          * <!-- begin-user-doc -->
178:          * <!-- end-user-doc -->
179:          *
180:          * @generated
181:          */
182:         @Override
183:         public Adapter createControlGridCellAdapter() {
184:•                if (controlGridCellItemProvider == null) {
185:                         controlGridCellItemProvider = new ControlGridCellItemProvider(this);
186:                 }
187:
188:                 return controlGridCellItemProvider;
189:         }
190:
191:         /**
192:          * This returns the root adapter factory that contains this factory.
193:          * <!-- begin-user-doc -->
194:          * <!-- end-user-doc -->
195:          *
196:          * @generated
197:          */
198:         @Override
199:         public ComposeableAdapterFactory getRootAdapterFactory() {
200:•                return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
201:         }
202:
203:         /**
204:          * This sets the composed adapter factory that contains this factory.
205:          * <!-- begin-user-doc -->
206:          * <!-- end-user-doc -->
207:          *
208:          * @generated
209:          */
210:         @Override
211:         public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
212:                 this.parentAdapterFactory = parentAdapterFactory;
213:         }
214:
215:         /**
216:          * <!-- begin-user-doc -->
217:          * <!-- end-user-doc -->
218:          *
219:          * @generated
220:          */
221:         @Override
222:         public boolean isFactoryForType(Object type) {
223:•                return supportedTypes.contains(type) || super.isFactoryForType(type);
224:         }
225:
226:         /**
227:          * This implementation substitutes the factory itself as the key for the adapter.
228:          * <!-- begin-user-doc -->
229:          * <!-- end-user-doc -->
230:          *
231:          * @generated
232:          */
233:         @Override
234:         public Adapter adapt(Notifier notifier, Object type) {
235:                 return super.adapt(notifier, this);
236:         }
237:
238:         /**
239:          * <!-- begin-user-doc -->
240:          * <!-- end-user-doc -->
241:          *
242:          * @generated
243:          */
244:         @Override
245:         public Object adapt(Object object, Object type) {
246:•                if (isFactoryForType(type)) {
247:                         final Object adapter = super.adapt(object, type);
248:•                        if (!(type instanceof Class<?>) || ((Class<?>) type).isInstance(adapter)) {
249:                                 return adapter;
250:                         }
251:                 }
252:
253:                 return null;
254:         }
255:
256:         /**
257:          * <!-- begin-user-doc -->
258:          * <!-- end-user-doc -->
259:          *
260:          * @generated
261:          */
262:         public List<IChildCreationExtender> getChildCreationExtenders() {
263:                 return childCreationExtenderManager.getChildCreationExtenders();
264:         }
265:
266:         /**
267:          * <!-- begin-user-doc -->
268:          * <!-- end-user-doc -->
269:          *
270:          * @generated
271:          */
272:         @Override
273:         public Collection<?> getNewChildDescriptors(Object object, EditingDomain editingDomain) {
274:                 return childCreationExtenderManager.getNewChildDescriptors(object, editingDomain);
275:         }
276:
277:         /**
278:          * <!-- begin-user-doc -->
279:          * <!-- end-user-doc -->
280:          *
281:          * @generated
282:          */
283:         @Override
284:         public ResourceLocator getResourceLocator() {
285:                 return childCreationExtenderManager;
286:         }
287:
288:         /**
289:          * This adds a listener.
290:          * <!-- begin-user-doc -->
291:          * <!-- end-user-doc -->
292:          *
293:          * @generated
294:          */
295:         @Override
296:         public void addListener(INotifyChangedListener notifyChangedListener) {
297:                 changeNotifier.addListener(notifyChangedListener);
298:         }
299:
300:         /**
301:          * This removes a listener.
302:          * <!-- begin-user-doc -->
303:          * <!-- end-user-doc -->
304:          *
305:          * @generated
306:          */
307:         @Override
308:         public void removeListener(INotifyChangedListener notifyChangedListener) {
309:                 changeNotifier.removeListener(notifyChangedListener);
310:         }
311:
312:         /**
313:          * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
314:          * <!-- begin-user-doc -->
315:          * <!-- end-user-doc -->
316:          *
317:          * @generated
318:          */
319:         @Override
320:         public void fireNotifyChanged(Notification notification) {
321:                 changeNotifier.fireNotifyChanged(notification);
322:
323:•                if (parentAdapterFactory != null) {
324:                         parentAdapterFactory.fireNotifyChanged(notification);
325:                 }
326:         }
327:
328:         /**
329:          * This disposes all of the item providers created by this factory.
330:          * <!-- begin-user-doc -->
331:          * <!-- end-user-doc -->
332:          *
333:          * @generated
334:          */
335:         @Override
336:         public void dispose() {
337:•                if (controlGridItemProvider != null) {
338:                         controlGridItemProvider.dispose();
339:                 }
340:•                if (controlGridRowItemProvider != null) {
341:                         controlGridRowItemProvider.dispose();
342:                 }
343:•                if (controlGridCellItemProvider != null) {
344:                         controlGridCellItemProvider.dispose();
345:                 }
346:         }
347:
348:         /**
349:          * A child creation extender for the {@link VViewPackage}.
350:          * <!-- begin-user-doc -->
351:          * <!-- end-user-doc -->
352:          *
353:          * @generated
354:          */
355:         public static class ViewChildCreationExtender implements IChildCreationExtender {
356:                 /**
357:                  * The switch for creating child descriptors specific to each extended class.
358:                  * <!-- begin-user-doc -->
359:                  * <!-- end-user-doc -->
360:                  *
361:                  * @generated
362:                  */
363:                 protected static class CreationSwitch extends ViewSwitch<Object> {
364:                         /**
365:                          * The child descriptors being populated.
366:                          * <!-- begin-user-doc -->
367:                          * <!-- end-user-doc -->
368:                          *
369:                          * @generated
370:                          */
371:                         protected List<Object> newChildDescriptors;
372:
373:                         /**
374:                          * The domain in which to create the children.
375:                          * <!-- begin-user-doc -->
376:                          * <!-- end-user-doc -->
377:                          *
378:                          * @generated
379:                          */
380:                         protected EditingDomain editingDomain;
381:
382:                         /**
383:                          * Creates the a switch for populating child descriptors in the given domain.
384:                          * <!-- begin-user-doc -->
385:                          * <!-- end-user-doc -->
386:                          *
387:                          * @generated
388:                          */
389:                         CreationSwitch(List<Object> newChildDescriptors, EditingDomain editingDomain) {
390:                                 this.newChildDescriptors = newChildDescriptors;
391:                                 this.editingDomain = editingDomain;
392:                         }
393:
394:                         /**
395:                          * <!-- begin-user-doc -->
396:                          * <!-- end-user-doc -->
397:                          *
398:                          * @generated
399:                          */
400:                         @Override
401:                         public Object caseView(VView object) {
402:                                 newChildDescriptors.add(createChildParameter(VViewPackage.Literals.VIEW__CHILDREN,
403:                                         VControlgridFactory.eINSTANCE.createControlGrid()));
404:
405:                                 return null;
406:                         }
407:
408:                         /**
409:                          * <!-- begin-user-doc -->
410:                          * <!-- end-user-doc -->
411:                          *
412:                          * @generated
413:                          */
414:                         @Override
415:                         public Object caseContainer(VContainer object) {
416:                                 newChildDescriptors.add(createChildParameter(VViewPackage.Literals.CONTAINER__CHILDREN,
417:                                         VControlgridFactory.eINSTANCE.createControlGrid()));
418:
419:                                 return null;
420:                         }
421:
422:                         /**
423:                          * <!-- begin-user-doc -->
424:                          * <!-- end-user-doc -->
425:                          *
426:                          * @generated
427:                          */
428:                         protected CommandParameter createChildParameter(Object feature, Object child) {
429:                                 return new CommandParameter(null, feature, child);
430:                         }
431:
432:                 }
433:
434:                 /**
435:                  * <!-- begin-user-doc -->
436:                  * <!-- end-user-doc -->
437:                  *
438:                  * @generated
439:                  */
440:                 @Override
441:                 public Collection<Object> getNewChildDescriptors(Object object, EditingDomain editingDomain) {
442:                         final ArrayList<Object> result = new ArrayList<Object>();
443:                         new CreationSwitch(result, editingDomain).doSwitch((EObject) object);
444:                         return result;
445:                 }
446:
447:                 /**
448:                  * <!-- begin-user-doc -->
449:                  * <!-- end-user-doc -->
450:                  *
451:                  * @generated
452:                  */
453:                 @Override
454:                 public ResourceLocator getResourceLocator() {
455:                         return ControlgridEditPlugin.INSTANCE;
456:                 }
457:         }
458:
459: }