Skip to content

Package: TemplateItemProvider

TemplateItemProvider

nameinstructionbranchcomplexitylinemethod
TemplateItemProvider(AdapterFactory)
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%
addInstancePropertyDescriptor(Object)
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
addNamePropertyDescriptor(Object)
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
collectNewChildDescriptors(Collection, Object)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
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: 0 C: 15
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getImage(Object)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPropertyDescriptors(Object)
M: 0 C: 16
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getResourceLocator()
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%
getText(Object)
M: 0 C: 15
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 2
100%
M: 0 C: 1
100%
notifyChanged(Notification)
M: 11 C: 22
67%
M: 1 C: 2
67%
M: 1 C: 2
67%
M: 2 C: 6
75%
M: 0 C: 1
100%

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.ItemPropertyDescriptor;
33: import org.eclipse.emf.edit.provider.ItemProviderAdapter;
34: import org.eclipse.emf.edit.provider.ViewerNotification;
35: import org.eclipse.emfforms.datatemplate.DataTemplatePackage;
36: import org.eclipse.emfforms.datatemplate.Template;
37:
38: /**
39: * This is the item provider adapter for a {@link org.eclipse.emfforms.datatemplate.Template} object.
40: * <!-- begin-user-doc -->
41: * <!-- end-user-doc -->
42: *
43: * @generated
44: */
45: public class TemplateItemProvider
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 TemplateItemProvider(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:                         addNamePropertyDescriptor(object);
77:                         addInstancePropertyDescriptor(object);
78:                 }
79:                 return itemPropertyDescriptors;
80:         }
81:
82:         /**
83:          * This adds a property descriptor for the Name feature.
84:          * <!-- begin-user-doc -->
85:          * <!-- end-user-doc -->
86:          *
87:          * @generated
88:          */
89:         protected void addNamePropertyDescriptor(Object object) {
90:                 itemPropertyDescriptors
91:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
92:                                 getResourceLocator(),
93:                                 getString("_UI_Template_name_feature"), //$NON-NLS-1$
94:                                 getString("_UI_PropertyDescriptor_description", "_UI_Template_name_feature", "_UI_Template_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
95:                                 DataTemplatePackage.Literals.TEMPLATE__NAME,
96:                                 true,
97:                                 false,
98:                                 false,
99:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
100:                                 null,
101:                                 null));
102:         }
103:
104:         /**
105:          * This adds a property descriptor for the Instance feature.
106:          * <!-- begin-user-doc -->
107:          * <!-- end-user-doc -->
108:          *
109:          * @generated
110:          */
111:         protected void addInstancePropertyDescriptor(Object object) {
112:                 itemPropertyDescriptors
113:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
114:                                 getResourceLocator(),
115:                                 getString("_UI_Template_instance_feature"), //$NON-NLS-1$
116:                                 getString("_UI_PropertyDescriptor_description", "_UI_Template_instance_feature", "_UI_Template_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
117:                                 DataTemplatePackage.Literals.TEMPLATE__INSTANCE,
118:                                 true,
119:                                 false,
120:                                 false,
121:                                 null,
122:                                 null,
123:                                 null));
124:         }
125:
126:         /**
127:          * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
128:          * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
129:          * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
130:          * <!-- begin-user-doc -->
131:          * <!-- end-user-doc -->
132:          *
133:          * @generated
134:          */
135:         @Override
136:         public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
137:•                if (childrenFeatures == null) {
138:                         super.getChildrenFeatures(object);
139:                         childrenFeatures.add(DataTemplatePackage.Literals.TEMPLATE__INSTANCE);
140:                 }
141:                 return childrenFeatures;
142:         }
143:
144:         /**
145:          * <!-- begin-user-doc -->
146:          * <!-- end-user-doc -->
147:          *
148:          * @generated
149:          */
150:         @Override
151:         protected EStructuralFeature getChildFeature(Object object, Object child) {
152:                 // Check the type of the specified child object and return the proper feature to use for
153:                 // adding (see {@link AddCommand}) it as a child.
154:
155:                 return super.getChildFeature(object, child);
156:         }
157:
158:         /**
159:          * This returns Template.gif.
160:          * <!-- begin-user-doc -->
161:          * <!-- end-user-doc -->
162:          *
163:          * @generated
164:          */
165:         @Override
166:         public Object getImage(Object object) {
167:                 return overlayImage(object, getResourceLocator().getImage("full/obj16/Template")); //$NON-NLS-1$
168:         }
169:
170:         /**
171:          * This returns the label text for the adapted class.
172:          * <!-- begin-user-doc -->
173:          * <!-- end-user-doc -->
174:          *
175:          * @generated NOT
176:          */
177:         @Override
178:         public String getText(Object object) {
179:                 final String label = ((Template) object).getName();
180:•                return label == null || label.length() == 0 ? getString("_UI_Template_type") : label; //$NON-NLS-1$
181:         }
182:
183:         /**
184:          * This handles model notifications by calling {@link #updateChildren} to update any cached
185:          * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
186:          * <!-- begin-user-doc -->
187:          * <!-- end-user-doc -->
188:          *
189:          * @generated
190:          */
191:         @Override
192:         public void notifyChanged(Notification notification) {
193:                 updateChildren(notification);
194:
195:•                switch (notification.getFeatureID(Template.class)) {
196:                 case DataTemplatePackage.TEMPLATE__NAME:
197:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
198:                         return;
199:                 case DataTemplatePackage.TEMPLATE__INSTANCE:
200:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
201:                         return;
202:                 }
203:                 super.notifyChanged(notification);
204:         }
205:
206:         /**
207:          * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
208:          * that can be created under this object.
209:          * <!-- begin-user-doc -->
210:          * <!-- end-user-doc -->
211:          *
212:          * @generated
213:          */
214:         @Override
215:         protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
216:                 super.collectNewChildDescriptors(newChildDescriptors, object);
217:         }
218:
219:         /**
220:          * Return the resource locator for this item provider's resources.
221:          * <!-- begin-user-doc -->
222:          * <!-- end-user-doc -->
223:          *
224:          * @generated
225:          */
226:         @Override
227:         public ResourceLocator getResourceLocator() {
228:                 return ((IChildCreationExtender) adapterFactory).getResourceLocator();
229:         }
230:
231: }