Skip to content

Package: ElementItemProvider

ElementItemProvider

nameinstructionbranchcomplexitylinemethod
ElementItemProvider(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%
addEnabledPropertyDescriptor(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%
addLabelPropertyDescriptor(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%
addReadonlyPropertyDescriptor(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%
addUuidPropertyDescriptor(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%
addVisiblePropertyDescriptor(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: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getChildFeature(Object, 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%
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%
getPropertyDescriptors(Object)
M: 0 C: 28
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 9
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: 26 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
notifyChanged(Notification)
M: 0 C: 56
100%
M: 0 C: 4
100%
M: 0 C: 4
100%
M: 0 C: 12
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (c) 2011-2013 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: * Eugen Neufeld - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.view.spi.model.provider;
15:
16: import java.util.Collection;
17: import java.util.List;
18:
19: import org.eclipse.emf.common.notify.AdapterFactory;
20: import org.eclipse.emf.common.notify.Notification;
21: import org.eclipse.emf.common.util.ResourceLocator;
22: import org.eclipse.emf.ecore.EObject;
23: import org.eclipse.emf.ecore.EStructuralFeature;
24: import org.eclipse.emf.ecp.view.spi.model.VElement;
25: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
26: import org.eclipse.emf.ecp.view.spi.model.VViewPackage;
27: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
28: import org.eclipse.emf.edit.provider.IChildCreationExtender;
29: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
30: import org.eclipse.emf.edit.provider.IItemLabelProvider;
31: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
32: import org.eclipse.emf.edit.provider.IItemPropertySource;
33: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
34: import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
35: import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
36: import org.eclipse.emf.edit.provider.ItemProviderAdapter;
37: import org.eclipse.emf.edit.provider.ViewerNotification;
38:
39: /**
40: * This is the item provider adapter for a {@link org.eclipse.emf.ecp.view.spi.model.VElement} object.
41: * <!-- begin-user-doc -->
42: *
43: * @since 1.2
44: * <!-- end-user-doc -->
45: * @generated
46: */
47: public class ElementItemProvider
48:         extends ItemProviderAdapter
49:         implements
50:         IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider,
51:         IItemPropertySource {
52:         /**
53:          * This constructs an instance from a factory and a notifier.
54:          * <!-- begin-user-doc -->
55:          * <!-- end-user-doc -->
56:          *
57:          * @generated
58:          */
59:         public ElementItemProvider(AdapterFactory adapterFactory) {
60:                 super(adapterFactory);
61:         }
62:
63:         /**
64:          * This returns the property descriptors for the adapted class.
65:          * <!-- begin-user-doc -->
66:          * <!-- end-user-doc -->
67:          *
68:          * @generated
69:          */
70:         @Override
71:         public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
72:•                if (itemPropertyDescriptors == null) {
73:                         super.getPropertyDescriptors(object);
74:
75:                         addNamePropertyDescriptor(object);
76:                         addLabelPropertyDescriptor(object);
77:                         addVisiblePropertyDescriptor(object);
78:                         addEnabledPropertyDescriptor(object);
79:                         addReadonlyPropertyDescriptor(object);
80:                         addUuidPropertyDescriptor(object);
81:                 }
82:                 return itemPropertyDescriptors;
83:         }
84:
85:         /**
86:          * This adds a property descriptor for the Name feature.
87:          * <!-- begin-user-doc -->
88:          * <!-- end-user-doc -->
89:          *
90:          * @generated
91:          */
92:         protected void addNamePropertyDescriptor(Object object) {
93:                 itemPropertyDescriptors
94:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
95:                                 getResourceLocator(),
96:                                 getString("_UI_Element_name_feature"), //$NON-NLS-1$
97:                                 getString("_UI_PropertyDescriptor_description", "_UI_Element_name_feature", "_UI_Element_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
98:                                 VViewPackage.Literals.ELEMENT__NAME,
99:                                 true,
100:                                 false,
101:                                 false,
102:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
103:                                 null,
104:                                 null));
105:         }
106:
107:         /**
108:          * This adds a property descriptor for the Label feature.
109:          * <!-- begin-user-doc -->
110:          *
111:          * @since 1.6
112:          * <!-- end-user-doc -->
113:          * @generated
114:          */
115:         protected void addLabelPropertyDescriptor(Object object) {
116:                 itemPropertyDescriptors
117:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
118:                                 getResourceLocator(),
119:                                 getString("_UI_Element_label_feature"), //$NON-NLS-1$
120:                                 getString("_UI_PropertyDescriptor_description", "_UI_Element_label_feature", "_UI_Element_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
121:                                 VViewPackage.Literals.ELEMENT__LABEL,
122:                                 true,
123:                                 false,
124:                                 false,
125:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
126:                                 null,
127:                                 null));
128:         }
129:
130:         /**
131:          * This adds a property descriptor for the Visible feature.
132:          * <!-- begin-user-doc -->
133:          * <!-- end-user-doc -->
134:          *
135:          * @generated
136:          */
137:         protected void addVisiblePropertyDescriptor(Object object) {
138:                 itemPropertyDescriptors
139:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
140:                                 getResourceLocator(),
141:                                 getString("_UI_Element_visible_feature"), //$NON-NLS-1$
142:                                 getString("_UI_PropertyDescriptor_description", "_UI_Element_visible_feature", "_UI_Element_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
143:                                 VViewPackage.Literals.ELEMENT__VISIBLE,
144:                                 true,
145:                                 false,
146:                                 false,
147:                                 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
148:                                 null,
149:                                 null));
150:         }
151:
152:         /**
153:          * This adds a property descriptor for the Enabled feature.
154:          * <!-- begin-user-doc -->
155:          * <!-- end-user-doc -->
156:          *
157:          * @generated
158:          */
159:         protected void addEnabledPropertyDescriptor(Object object) {
160:                 itemPropertyDescriptors
161:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
162:                                 getResourceLocator(),
163:                                 getString("_UI_Element_enabled_feature"), //$NON-NLS-1$
164:                                 getString("_UI_PropertyDescriptor_description", "_UI_Element_enabled_feature", "_UI_Element_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
165:                                 VViewPackage.Literals.ELEMENT__ENABLED,
166:                                 true,
167:                                 false,
168:                                 false,
169:                                 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
170:                                 null,
171:                                 null));
172:         }
173:
174:         /**
175:          * This adds a property descriptor for the Readonly feature.
176:          * <!-- begin-user-doc -->
177:          * <!-- end-user-doc -->
178:          *
179:          * @generated
180:          */
181:         protected void addReadonlyPropertyDescriptor(Object object) {
182:                 itemPropertyDescriptors
183:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
184:                                 getResourceLocator(),
185:                                 getString("_UI_Element_readonly_feature"), //$NON-NLS-1$
186:                                 getString("_UI_PropertyDescriptor_description", "_UI_Element_readonly_feature", "_UI_Element_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
187:                                 VViewPackage.Literals.ELEMENT__READONLY,
188:                                 true,
189:                                 false,
190:                                 false,
191:                                 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
192:                                 null,
193:                                 null));
194:         }
195:
196:         /**
197:          * This adds a property descriptor for the Uuid feature.
198:          * <!-- begin-user-doc -->
199:          *
200:          * @since 1.9
201:          * <!-- end-user-doc -->
202:          * @generated
203:          */
204:         protected void addUuidPropertyDescriptor(Object object) {
205:                 itemPropertyDescriptors
206:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
207:                                 getResourceLocator(),
208:                                 getString("_UI_Element_uuid_feature"), //$NON-NLS-1$
209:                                 getString("_UI_PropertyDescriptor_description", "_UI_Element_uuid_feature", "_UI_Element_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
210:                                 VViewPackage.Literals.ELEMENT__UUID,
211:                                 true,
212:                                 false,
213:                                 false,
214:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
215:                                 null,
216:                                 null));
217:         }
218:
219:         /**
220:          * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
221:          * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
222:          * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
223:          * <!-- begin-user-doc -->
224:          * <!-- end-user-doc -->
225:          *
226:          * @generated
227:          */
228:         @Override
229:         public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
230:•                if (childrenFeatures == null) {
231:                         super.getChildrenFeatures(object);
232:                         childrenFeatures.add(VViewPackage.Literals.ELEMENT__ATTACHMENTS);
233:                 }
234:                 return childrenFeatures;
235:         }
236:
237:         /**
238:          * <!-- begin-user-doc -->
239:          * <!-- end-user-doc -->
240:          *
241:          * @generated
242:          */
243:         @Override
244:         protected EStructuralFeature getChildFeature(Object object, Object child) {
245:                 // Check the type of the specified child object and return the proper feature to use for
246:                 // adding (see {@link AddCommand}) it as a child.
247:
248:                 return super.getChildFeature(object, child);
249:         }
250:
251:         /**
252:          * This returns the label text for the adapted class.
253:          * <!-- begin-user-doc -->
254:          * <!-- end-user-doc -->
255:          *
256:          * @generated
257:          */
258:         @Override
259:         public String getText(Object object) {
260:                 final String label = ((VElement) object).getName();
261:•                return label == null || label.length() == 0 ? getString("_UI_Element_type") : //$NON-NLS-1$
262:                         getString("_UI_Element_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
263:         }
264:
265:         /**
266:          * This handles model notifications by calling {@link #updateChildren} to update any cached
267:          * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
268:          *
269:          * @param notification a description of the change
270:          * <!-- begin-user-doc -->
271:          * <!-- end-user-doc -->
272:          *
273:          * @generated NOT
274:          */
275:         @Override
276:         public void notifyChanged(Notification notification) {
277:                 updateChildren(notification);
278:
279:•                switch (notification.getFeatureID(VElement.class)) {
280:                 case VViewPackage.ELEMENT__NAME:
281:                 case VViewPackage.ELEMENT__ENABLED:
282:                 case VViewPackage.ELEMENT__READONLY:
283:                 case VViewPackage.ELEMENT__DIAGNOSTIC:
284:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
285:                         return;
286:
287:                 case VViewPackage.ELEMENT__VISIBLE:
288:                         // notify parent as else no update on tree will happen
289:                         fireNotifyChanged(new ViewerNotification(notification, ((EObject) notification.getNotifier()).eContainer(),
290:                                 true, false));
291:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
292:                         return;
293:                 case VViewPackage.ELEMENT__ATTACHMENTS:
294:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
295:                         return;
296:                 default:
297:                         break;
298:                 }
299:                 super.notifyChanged(notification);
300:         }
301:
302:         /**
303:          * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
304:          * that can be created under this object.
305:          * <!-- begin-user-doc -->
306:          * <!-- end-user-doc -->
307:          *
308:          * @generated
309:          */
310:         @Override
311:         protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
312:                 super.collectNewChildDescriptors(newChildDescriptors, object);
313:
314:                 newChildDescriptors.add(createChildParameter(VViewPackage.Literals.ELEMENT__ATTACHMENTS,
315:                         VViewFactory.eINSTANCE.createDateTimeDisplayAttachment()));
316:         }
317:
318:         /**
319:          * Return the resource locator for this item provider's resources.
320:          * <!-- begin-user-doc -->
321:          * <!-- end-user-doc -->
322:          *
323:          * @generated
324:          */
325:         @Override
326:         public ResourceLocator getResourceLocator() {
327:                 return ((IChildCreationExtender) adapterFactory).getResourceLocator();
328:         }
329:
330: }