Skip to content

Package: ViewproxyItemProviderAdapterFactory

ViewproxyItemProviderAdapterFactory

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