Skip to content

Package: CompoundcontrolItemProviderAdapterFactory$ViewChildCreationExtender$CreationSwitch

CompoundcontrolItemProviderAdapterFactory$ViewChildCreationExtender$CreationSwitch

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