Skip to content

Package: SectionItemProviderAdapterFactory

SectionItemProviderAdapterFactory

nameinstructionbranchcomplexitylinemethod
SectionItemProviderAdapterFactory()
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%
createSectionAdapter()
M: 0 C: 12
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
createSectionedAreaAdapter()
M: 0 C: 12
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
dispose()
M: 13 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 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: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
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: 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: * Johannes Faltermeier - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.view.spi.section.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.ecp.view.spi.section.model.VSectionFactory;
30: import org.eclipse.emf.ecp.view.spi.section.model.VSectionPackage;
31: import org.eclipse.emf.ecp.view.spi.section.model.util.SectionAdapterFactory;
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 SectionItemProviderAdapterFactory extends SectionAdapterFactory
60:         implements ComposeableAdapterFactory, IChangeNotifier, IDisposable,
61:         IChildCreationExtender {
62:         /**
63:          * This keeps track of the root adapter factory that delegates to this adapter factory.
64:          * <!-- begin-user-doc --> <!-- 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 --> <!-- 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:                 SectionEditPlugin.INSTANCE, VSectionPackage.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. <!-- begin-user-doc --> <!-- end-user-doc
99:          * -->
100:          *
101:          * @generated
102:          */
103:         public SectionItemProviderAdapterFactory() {
104:                 supportedTypes.add(IEditingDomainItemProvider.class);
105:                 supportedTypes.add(IStructuredItemContentProvider.class);
106:                 supportedTypes.add(ITreeItemContentProvider.class);
107:                 supportedTypes.add(IItemLabelProvider.class);
108:                 supportedTypes.add(IItemPropertySource.class);
109:         }
110:
111:         /**
112:          * This keeps track of the one adapter used for all
113:          * {@link org.eclipse.emf.ecp.view.spi.section.model.VSectionedArea} instances.
114:          * <!-- begin-user-doc -->
115:          * <!-- end-user-doc -->
116:          *
117:          * @generated
118:          */
119:         protected SectionedAreaItemProvider sectionedAreaItemProvider;
120:
121:         /**
122:          * This creates an adapter for a {@link org.eclipse.emf.ecp.view.spi.section.model.VSectionedArea}.
123:          * <!-- begin-user-doc -->
124:          * <!-- end-user-doc -->
125:          *
126:          * @generated
127:          */
128:         @Override
129:         public Adapter createSectionedAreaAdapter() {
130:•                if (sectionedAreaItemProvider == null) {
131:                         sectionedAreaItemProvider = new SectionedAreaItemProvider(this);
132:                 }
133:
134:                 return sectionedAreaItemProvider;
135:         }
136:
137:         /**
138:          * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecp.view.spi.section.model.VSection}
139:          * instances.
140:          * <!-- begin-user-doc --> <!-- end-user-doc -->
141:          *
142:          * @generated
143:          */
144:         protected SectionItemProvider sectionItemProvider;
145:
146:         /**
147:          * This creates an adapter for a {@link org.eclipse.emf.ecp.view.spi.section.model.VSection}. <!--
148:          * begin-user-doc --> <!-- end-user-doc -->
149:          *
150:          * @generated
151:          */
152:         @Override
153:         public Adapter createSectionAdapter() {
154:•                if (sectionItemProvider == null) {
155:                         sectionItemProvider = new SectionItemProvider(this);
156:                 }
157:
158:                 return sectionItemProvider;
159:         }
160:
161:         /**
162:          * This returns the root adapter factory that contains this factory. <!--
163:          * begin-user-doc --> <!-- end-user-doc -->
164:          *
165:          * @generated
166:          */
167:         @Override
168:         public ComposeableAdapterFactory getRootAdapterFactory() {
169:•                return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
170:         }
171:
172:         /**
173:          * This sets the composed adapter factory that contains this factory. <!--
174:          * begin-user-doc --> <!-- end-user-doc -->
175:          *
176:          * @generated
177:          */
178:         @Override
179:         public void setParentAdapterFactory(
180:                 ComposedAdapterFactory parentAdapterFactory) {
181:                 this.parentAdapterFactory = parentAdapterFactory;
182:         }
183:
184:         /**
185:          * <!-- begin-user-doc --> <!-- end-user-doc -->
186:          *
187:          * @generated
188:          */
189:         @Override
190:         public boolean isFactoryForType(Object type) {
191:•                return supportedTypes.contains(type) || super.isFactoryForType(type);
192:         }
193:
194:         /**
195:          * This implementation substitutes the factory itself as the key for the adapter.
196:          * <!-- begin-user-doc --> <!-- end-user-doc -->
197:          *
198:          * @generated
199:          */
200:         @Override
201:         public Adapter adapt(Notifier notifier, Object type) {
202:                 return super.adapt(notifier, this);
203:         }
204:
205:         /**
206:          * <!-- begin-user-doc --> <!-- end-user-doc -->
207:          *
208:          * @generated
209:          */
210:         @Override
211:         public Object adapt(Object object, Object type) {
212:•                if (isFactoryForType(type)) {
213:                         Object adapter = super.adapt(object, type);
214:•                        if (!(type instanceof Class<?>) || (((Class<?>) type).isInstance(adapter))) {
215:                                 return adapter;
216:                         }
217:                 }
218:
219:                 return null;
220:         }
221:
222:         /**
223:          * <!-- begin-user-doc --> <!-- end-user-doc -->
224:          *
225:          * @generated
226:          */
227:         public List<IChildCreationExtender> getChildCreationExtenders() {
228:                 return childCreationExtenderManager.getChildCreationExtenders();
229:         }
230:
231:         /**
232:          * <!-- begin-user-doc --> <!-- end-user-doc -->
233:          *
234:          * @generated
235:          */
236:         @Override
237:         public Collection<?> getNewChildDescriptors(Object object,
238:                 EditingDomain editingDomain) {
239:                 return childCreationExtenderManager.getNewChildDescriptors(object, editingDomain);
240:         }
241:
242:         /**
243:          * <!-- begin-user-doc --> <!-- end-user-doc -->
244:          *
245:          * @generated
246:          */
247:         @Override
248:         public ResourceLocator getResourceLocator() {
249:                 return childCreationExtenderManager;
250:         }
251:
252:         /**
253:          * This adds a listener.
254:          * <!-- begin-user-doc --> <!-- end-user-doc -->
255:          *
256:          * @generated
257:          */
258:         @Override
259:         public void addListener(INotifyChangedListener notifyChangedListener) {
260:                 changeNotifier.addListener(notifyChangedListener);
261:         }
262:
263:         /**
264:          * This removes a listener.
265:          * <!-- begin-user-doc --> <!-- end-user-doc -->
266:          *
267:          * @generated
268:          */
269:         @Override
270:         public void removeListener(INotifyChangedListener notifyChangedListener) {
271:                 changeNotifier.removeListener(notifyChangedListener);
272:         }
273:
274:         /**
275:          * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. <!-- begin-user-doc --> <!--
276:          * end-user-doc
277:          * -->
278:          *
279:          * @generated
280:          */
281:         @Override
282:         public void fireNotifyChanged(Notification notification) {
283:                 changeNotifier.fireNotifyChanged(notification);
284:
285:•                if (parentAdapterFactory != null) {
286:                         parentAdapterFactory.fireNotifyChanged(notification);
287:                 }
288:         }
289:
290:         /**
291:          * This disposes all of the item providers created by this factory. <!--
292:          * begin-user-doc --> <!-- end-user-doc -->
293:          *
294:          * @generated
295:          */
296:         @Override
297:         public void dispose() {
298:•                if (sectionedAreaItemProvider != null)
299:                         sectionedAreaItemProvider.dispose();
300:•                if (sectionItemProvider != null)
301:                         sectionItemProvider.dispose();
302:         }
303:
304:         /**
305:          * A child creation extender for the {@link VViewPackage}. <!--
306:          * begin-user-doc --> <!-- end-user-doc -->
307:          *
308:          * @generated
309:          */
310:         public static class ViewChildCreationExtender implements
311:                 IChildCreationExtender {
312:                 /**
313:                  * The switch for creating child descriptors specific to each extended class.
314:                  * <!-- begin-user-doc --> <!-- end-user-doc -->
315:                  *
316:                  * @generated
317:                  */
318:                 protected static class CreationSwitch extends ViewSwitch<Object> {
319:                         /**
320:                          * The child descriptors being populated.
321:                          * <!-- begin-user-doc -->
322:                          * <!-- end-user-doc -->
323:                          *
324:                          * @generated
325:                          */
326:                         protected List<Object> newChildDescriptors;
327:
328:                         /**
329:                          * The domain in which to create the children.
330:                          * <!-- begin-user-doc
331:                          * --> <!-- end-user-doc -->
332:                          *
333:                          * @generated
334:                          */
335:                         protected EditingDomain editingDomain;
336:
337:                         /**
338:                          * Creates the a switch for populating child descriptors in the given domain.
339:                          * <!-- begin-user-doc --> <!-- end-user-doc -->
340:                          *
341:                          * @generated
342:                          */
343:                         CreationSwitch(List<Object> newChildDescriptors,
344:                                 EditingDomain editingDomain) {
345:                                 this.newChildDescriptors = newChildDescriptors;
346:                                 this.editingDomain = editingDomain;
347:                         }
348:
349:                         /**
350:                          * <!-- begin-user-doc --> <!-- end-user-doc -->
351:                          *
352:                          * @generated
353:                          */
354:                         @Override
355:                         public Object caseView(VView object) {
356:                                 newChildDescriptors.add(createChildParameter(VViewPackage.Literals.VIEW__CHILDREN,
357:                                         VSectionFactory.eINSTANCE.createSectionedArea()));
358:
359:                                 return null;
360:                         }
361:
362:                         /**
363:                          * <!-- begin-user-doc --> <!-- end-user-doc -->
364:                          *
365:                          * @generated
366:                          */
367:                         @Override
368:                         public Object caseContainer(VContainer object) {
369:                                 newChildDescriptors.add(createChildParameter(VViewPackage.Literals.CONTAINER__CHILDREN,
370:                                         VSectionFactory.eINSTANCE.createSectionedArea()));
371:
372:                                 return null;
373:                         }
374:
375:                         /**
376:                          * <!-- begin-user-doc --> <!-- end-user-doc -->
377:                          *
378:                          * @generated
379:                          */
380:                         protected CommandParameter createChildParameter(Object feature,
381:                                 Object child) {
382:                                 return new CommandParameter(null, feature, child);
383:                         }
384:
385:                 }
386:
387:                 /**
388:                  * <!-- begin-user-doc --> <!-- end-user-doc -->
389:                  *
390:                  * @generated
391:                  */
392:                 @Override
393:                 public Collection<Object> getNewChildDescriptors(Object object,
394:                         EditingDomain editingDomain) {
395:                         ArrayList<Object> result = new ArrayList<Object>();
396:                         new CreationSwitch(result, editingDomain).doSwitch((EObject) object);
397:                         return result;
398:                 }
399:
400:                 /**
401:                  * <!-- begin-user-doc --> <!-- end-user-doc -->
402:                  *
403:                  * @generated
404:                  */
405:                 @Override
406:                 public ResourceLocator getResourceLocator() {
407:                         return SectionEditPlugin.INSTANCE;
408:                 }
409:         }
410:
411: }