Skip to content

Package: TemplateCollectionItemProvider

TemplateCollectionItemProvider

nameinstructionbranchcomplexitylinemethod
TemplateCollectionItemProvider(AdapterFactory)
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%
addTemplatesPropertyDescriptor(Object)
M: 28 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 14 C: 0
0%
M: 1 C: 0
0%
collectNewChildDescriptors(Collection, Object)
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getChildFeature(Object, 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%
getChildrenFeatures(Object)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getImage(Object)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPropertyDescriptors(Object)
M: 13 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getResourceLocator()
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%
getText(Object)
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%
notifyChanged(Notification)
M: 22 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /**
2: * Copyright (c) 2011-2019 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 Muenchen GmbH - initial API and implementation
13: * Christian W. Damus - bug 546974
14: */
15: package org.eclipse.emfforms.datatemplate.provider;
16:
17: import java.util.Collection;
18: import java.util.List;
19:
20: import org.eclipse.emf.common.notify.AdapterFactory;
21: import org.eclipse.emf.common.notify.Notification;
22: import org.eclipse.emf.common.util.ResourceLocator;
23: import org.eclipse.emf.ecore.EStructuralFeature;
24: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
25: import org.eclipse.emf.edit.provider.IChildCreationExtender;
26: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
27: import org.eclipse.emf.edit.provider.IItemLabelProvider;
28: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
29: import org.eclipse.emf.edit.provider.IItemPropertySource;
30: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
31: import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
32: import org.eclipse.emf.edit.provider.ItemProviderAdapter;
33: import org.eclipse.emf.edit.provider.ViewerNotification;
34: import org.eclipse.emfforms.datatemplate.DataTemplateFactory;
35: import org.eclipse.emfforms.datatemplate.DataTemplatePackage;
36: import org.eclipse.emfforms.datatemplate.TemplateCollection;
37:
38: /**
39: * This is the item provider adapter for a {@link org.eclipse.emfforms.datatemplate.TemplateCollection} object.
40: * <!-- begin-user-doc -->
41: * <!-- end-user-doc -->
42: *
43: * @generated
44: */
45: public class TemplateCollectionItemProvider
46:         extends ItemProviderAdapter
47:         implements
48:         IEditingDomainItemProvider,
49:         IStructuredItemContentProvider,
50:         ITreeItemContentProvider,
51:         IItemLabelProvider,
52:         IItemPropertySource {
53:         /**
54:          * This constructs an instance from a factory and a notifier.
55:          * <!-- begin-user-doc -->
56:          * <!-- end-user-doc -->
57:          *
58:          * @generated
59:          */
60:         public TemplateCollectionItemProvider(AdapterFactory adapterFactory) {
61:                 super(adapterFactory);
62:         }
63:
64:         /**
65:          * This returns the property descriptors for the adapted class.
66:          * <!-- begin-user-doc -->
67:          * <!-- end-user-doc -->
68:          *
69:          * @generated
70:          */
71:         @Override
72:         public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
73:•                if (itemPropertyDescriptors == null) {
74:                         super.getPropertyDescriptors(object);
75:
76:                         addTemplatesPropertyDescriptor(object);
77:                 }
78:                 return itemPropertyDescriptors;
79:         }
80:
81:         /**
82:          * This adds a property descriptor for the Templates feature.
83:          * <!-- begin-user-doc -->
84:          * <!-- end-user-doc -->
85:          *
86:          * @generated
87:          */
88:         protected void addTemplatesPropertyDescriptor(Object object) {
89:                 itemPropertyDescriptors
90:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
91:                                 getResourceLocator(),
92:                                 getString("_UI_TemplateCollection_templates_feature"), //$NON-NLS-1$
93:                                 getString("_UI_PropertyDescriptor_description", "_UI_TemplateCollection_templates_feature", //$NON-NLS-1$//$NON-NLS-2$
94:                                         "_UI_TemplateCollection_type"), //$NON-NLS-1$
95:                                 DataTemplatePackage.Literals.TEMPLATE_COLLECTION__TEMPLATES,
96:                                 true,
97:                                 false,
98:                                 false,
99:                                 null,
100:                                 null,
101:                                 null));
102:         }
103:
104:         /**
105:          * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
106:          * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
107:          * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
108:          * <!-- begin-user-doc -->
109:          * <!-- end-user-doc -->
110:          *
111:          * @generated
112:          */
113:         @Override
114:         public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
115:•                if (childrenFeatures == null) {
116:                         super.getChildrenFeatures(object);
117:                         childrenFeatures.add(DataTemplatePackage.Literals.TEMPLATE_COLLECTION__TEMPLATES);
118:                 }
119:                 return childrenFeatures;
120:         }
121:
122:         /**
123:          * <!-- begin-user-doc -->
124:          * <!-- end-user-doc -->
125:          *
126:          * @generated
127:          */
128:         @Override
129:         protected EStructuralFeature getChildFeature(Object object, Object child) {
130:                 // Check the type of the specified child object and return the proper feature to use for
131:                 // adding (see {@link AddCommand}) it as a child.
132:
133:                 return super.getChildFeature(object, child);
134:         }
135:
136:         /**
137:          * This returns TemplateCollection.gif.
138:          * <!-- begin-user-doc -->
139:          * <!-- end-user-doc -->
140:          *
141:          * @generated
142:          */
143:         @Override
144:         public Object getImage(Object object) {
145:                 return overlayImage(object, getResourceLocator().getImage("full/obj16/TemplateCollection")); //$NON-NLS-1$
146:         }
147:
148:         /**
149:          * This returns the label text for the adapted class.
150:          * <!-- begin-user-doc -->
151:          * <!-- end-user-doc -->
152:          *
153:          * @generated
154:          */
155:         @Override
156:         public String getText(Object object) {
157:                 return getString("_UI_TemplateCollection_type"); //$NON-NLS-1$
158:         }
159:
160:         /**
161:          * This handles model notifications by calling {@link #updateChildren} to update any cached
162:          * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
163:          * <!-- begin-user-doc -->
164:          * <!-- end-user-doc -->
165:          *
166:          * @generated
167:          */
168:         @Override
169:         public void notifyChanged(Notification notification) {
170:                 updateChildren(notification);
171:
172:•                switch (notification.getFeatureID(TemplateCollection.class)) {
173:                 case DataTemplatePackage.TEMPLATE_COLLECTION__TEMPLATES:
174:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
175:                         return;
176:                 }
177:                 super.notifyChanged(notification);
178:         }
179:
180:         /**
181:          * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
182:          * that can be created under this object.
183:          * <!-- begin-user-doc -->
184:          * <!-- end-user-doc -->
185:          *
186:          * @generated
187:          */
188:         @Override
189:         protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
190:                 super.collectNewChildDescriptors(newChildDescriptors, object);
191:
192:                 newChildDescriptors.add(createChildParameter(DataTemplatePackage.Literals.TEMPLATE_COLLECTION__TEMPLATES,
193:                         DataTemplateFactory.eINSTANCE.createTemplate()));
194:         }
195:
196:         /**
197:          * Return the resource locator for this item provider's resources.
198:          * <!-- begin-user-doc -->
199:          * <!-- end-user-doc -->
200:          *
201:          * @generated
202:          */
203:         @Override
204:         public ResourceLocator getResourceLocator() {
205:                 return ((IChildCreationExtender) adapterFactory).getResourceLocator();
206:         }
207:
208: }