Skip to content

Package: SimpleTestObjectItemProvider

SimpleTestObjectItemProvider

nameinstructionbranchcomplexitylinemethod
SimpleTestObjectItemProvider(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%
addDatePropertyDescriptor(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%
addMyEnumPropertyDescriptor(Object)
M: 30 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 14 C: 0
0%
M: 1 C: 0
0%
addXmlDatePropertyDescriptor(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: 19 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getResourceLocator()
M: 2 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: 33 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
notifyChanged(Notification)
M: 33 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 8 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: * Eugen Neufeld - initial API and implementation
13: * Lucas Koehler - extension for EnumComboViewerRenderer_PTest
14: */
15: package org.eclipse.emf.ecp.view.core.swt.test.model.provider;
16:
17: import java.util.Collection;
18: import java.util.Date;
19: import java.util.List;
20: import java.util.Set;
21: import java.util.stream.Collectors;
22:
23: import org.eclipse.emf.common.notify.AdapterFactory;
24: import org.eclipse.emf.common.notify.Notification;
25: import org.eclipse.emf.common.util.Enumerator;
26: import org.eclipse.emf.common.util.ResourceLocator;
27: import org.eclipse.emf.ecore.EEnumLiteral;
28: import org.eclipse.emf.ecore.EStructuralFeature;
29: import org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject;
30: import org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum;
31: import org.eclipse.emf.ecp.view.core.swt.test.model.TestFactory;
32: import org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage;
33: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
34: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
35: import org.eclipse.emf.edit.provider.IItemLabelProvider;
36: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
37: import org.eclipse.emf.edit.provider.IItemPropertySource;
38: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
39: import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
40: import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
41: import org.eclipse.emf.edit.provider.ItemProviderAdapter;
42: import org.eclipse.emf.edit.provider.ViewerNotification;
43:
44: /**
45: * This is the item provider adapter for a {@link org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject} object.
46: * <!-- begin-user-doc -->
47: * <!-- end-user-doc -->
48: *
49: * @generated
50: */
51: public class SimpleTestObjectItemProvider
52:         extends ItemProviderAdapter
53:         implements
54:         IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider,
55:         IItemPropertySource {
56:         /**
57:          * This constructs an instance from a factory and a notifier.
58:          * <!-- begin-user-doc -->
59:          * <!-- end-user-doc -->
60:          *
61:          * @generated
62:          */
63:         public SimpleTestObjectItemProvider(AdapterFactory adapterFactory) {
64:                 super(adapterFactory);
65:         }
66:
67:         /**
68:          * This returns the property descriptors for the adapted class.
69:          * <!-- begin-user-doc -->
70:          * <!-- end-user-doc -->
71:          *
72:          * @generated
73:          */
74:         @Override
75:         public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
76:•                if (itemPropertyDescriptors == null) {
77:                         super.getPropertyDescriptors(object);
78:
79:                         addDatePropertyDescriptor(object);
80:                         addXmlDatePropertyDescriptor(object);
81:                         addMyEnumPropertyDescriptor(object);
82:                 }
83:                 return itemPropertyDescriptors;
84:         }
85:
86:         /**
87:          * This adds a property descriptor for the Date feature.
88:          * <!-- begin-user-doc -->
89:          * <!-- end-user-doc -->
90:          *
91:          * @generated
92:          */
93:         protected void addDatePropertyDescriptor(Object object) {
94:                 itemPropertyDescriptors
95:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
96:                                 getResourceLocator(),
97:                                 getString("_UI_SimpleTestObject_date_feature"), //$NON-NLS-1$
98:                                 getString("_UI_PropertyDescriptor_description", "_UI_SimpleTestObject_date_feature", //$NON-NLS-1$//$NON-NLS-2$
99:                                         "_UI_SimpleTestObject_type"), //$NON-NLS-1$
100:                                 TestPackage.Literals.SIMPLE_TEST_OBJECT__DATE,
101:                                 true,
102:                                 false,
103:                                 false,
104:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
105:                                 null,
106:                                 null));
107:         }
108:
109:         /**
110:          * This adds a property descriptor for the Xml Date feature.
111:          * <!-- begin-user-doc -->
112:          * <!-- end-user-doc -->
113:          *
114:          * @generated
115:          */
116:         protected void addXmlDatePropertyDescriptor(Object object) {
117:                 itemPropertyDescriptors
118:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
119:                                 getResourceLocator(),
120:                                 getString("_UI_SimpleTestObject_xmlDate_feature"), //$NON-NLS-1$
121:                                 getString("_UI_PropertyDescriptor_description", "_UI_SimpleTestObject_xmlDate_feature", //$NON-NLS-1$//$NON-NLS-2$
122:                                         "_UI_SimpleTestObject_type"), //$NON-NLS-1$
123:                                 TestPackage.Literals.SIMPLE_TEST_OBJECT__XML_DATE,
124:                                 true,
125:                                 false,
126:                                 false,
127:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
128:                                 null,
129:                                 null));
130:         }
131:
132:         /**
133:          * This adds a property descriptor for the My Enum feature.
134:          * <!-- begin-user-doc -->
135:          * <!-- end-user-doc -->
136:          *
137:          * @generated NOT
138:          */
139:         protected void addMyEnumPropertyDescriptor(Object object) {
140:                 itemPropertyDescriptors
141:                         .add(new ItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
142:                                 getResourceLocator(),
143:                                 getString("_UI_SimpleTestObject_myEnum_feature"), //$NON-NLS-1$
144:                                 getString("_UI_PropertyDescriptor_description", "_UI_SimpleTestObject_myEnum_feature", //$NON-NLS-1$//$NON-NLS-2$
145:                                         "_UI_SimpleTestObject_type"), //$NON-NLS-1$
146:                                 TestPackage.Literals.SIMPLE_TEST_OBJECT__MY_ENUM,
147:                                 true,
148:                                 false,
149:                                 false,
150:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
151:                                 null,
152:                                 null) {
153:
154:                                 @Override
155:                                 public Collection<?> getChoiceOfValues(Object object) {
156:                                         final Set<Enumerator> set = TestPackage.Literals.TEST_ENUM.getELiterals().stream()
157:                                                 .map(EEnumLiteral::getInstance).collect(Collectors.toSet());
158:                                         set.remove(TestEnum.D);
159:                                         return set;
160:                                 }
161:                         });
162:         }
163:
164:         /**
165:          * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
166:          * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
167:          * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
168:          * <!-- begin-user-doc -->
169:          * <!-- end-user-doc -->
170:          *
171:          * @generated
172:          */
173:         @Override
174:         public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
175:•                if (childrenFeatures == null) {
176:                         super.getChildrenFeatures(object);
177:                         childrenFeatures.add(TestPackage.Literals.SIMPLE_TEST_OBJECT__INNER);
178:                 }
179:                 return childrenFeatures;
180:         }
181:
182:         /**
183:          * <!-- begin-user-doc -->
184:          * <!-- end-user-doc -->
185:          *
186:          * @generated
187:          */
188:         @Override
189:         protected EStructuralFeature getChildFeature(Object object, Object child) {
190:                 // Check the type of the specified child object and return the proper feature to use for
191:                 // adding (see {@link AddCommand}) it as a child.
192:
193:                 return super.getChildFeature(object, child);
194:         }
195:
196:         /**
197:          * This returns SimpleTestObject.gif.
198:          * <!-- begin-user-doc -->
199:          * <!-- end-user-doc -->
200:          *
201:          * @generated
202:          */
203:         @Override
204:         public Object getImage(Object object) {
205:                 return overlayImage(object, getResourceLocator().getImage("full/obj16/SimpleTestObject")); //$NON-NLS-1$
206:         }
207:
208:         /**
209:          * This returns the label text for the adapted class.
210:          * <!-- begin-user-doc -->
211:          * <!-- end-user-doc -->
212:          *
213:          * @generated
214:          */
215:         @Override
216:         public String getText(Object object) {
217:                 final Date labelValue = ((SimpleTestObject) object).getDate();
218:•                final String label = labelValue == null ? null : labelValue.toString();
219:•                return label == null || label.length() == 0 ? getString("_UI_SimpleTestObject_type") : //$NON-NLS-1$
220:                         getString("_UI_SimpleTestObject_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
221:         }
222:
223:         /**
224:          * This handles model notifications by calling {@link #updateChildren} to update any cached
225:          * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
226:          * <!-- begin-user-doc -->
227:          * <!-- end-user-doc -->
228:          *
229:          * @generated
230:          */
231:         @Override
232:         public void notifyChanged(Notification notification) {
233:                 updateChildren(notification);
234:
235:•                switch (notification.getFeatureID(SimpleTestObject.class)) {
236:                 case TestPackage.SIMPLE_TEST_OBJECT__DATE:
237:                 case TestPackage.SIMPLE_TEST_OBJECT__XML_DATE:
238:                 case TestPackage.SIMPLE_TEST_OBJECT__MY_ENUM:
239:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
240:                         return;
241:                 case TestPackage.SIMPLE_TEST_OBJECT__INNER:
242:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
243:                         return;
244:                 }
245:                 super.notifyChanged(notification);
246:         }
247:
248:         /**
249:          * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
250:          * that can be created under this object.
251:          * <!-- begin-user-doc -->
252:          * <!-- end-user-doc -->
253:          *
254:          * @generated
255:          */
256:         @Override
257:         protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
258:                 super.collectNewChildDescriptors(newChildDescriptors, object);
259:
260:                 newChildDescriptors.add(createChildParameter(TestPackage.Literals.SIMPLE_TEST_OBJECT__INNER,
261:                         TestFactory.eINSTANCE.createInnerObject()));
262:         }
263:
264:         /**
265:          * Return the resource locator for this item provider's resources.
266:          * <!-- begin-user-doc -->
267:          * <!-- end-user-doc -->
268:          *
269:          * @generated
270:          */
271:         @Override
272:         public ResourceLocator getResourceLocator() {
273:                 return TestEditPlugin.INSTANCE;
274:         }
275:
276: }