Skip to content

Package: TaskItemProvider

TaskItemProvider

nameinstructionbranchcomplexitylinemethod
TaskItemProvider(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%
addAssigneePropertyDescriptor(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%
addDescriptionPropertyDescriptor(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%
addDonePropertyDescriptor(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%
addDueDatePropertyDescriptor(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%
addNamePropertyDescriptor(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: 6 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: 22 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getPropertyDescriptors(Object)
M: 25 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 8 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: 26 C: 0
0%
M: 4 C: 0
0%
M: 3 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-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: * EclipseSource Munich - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.makeithappen.model.task.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.EStructuralFeature;
23: import org.eclipse.emf.ecp.makeithappen.model.task.Task;
24: import org.eclipse.emf.ecp.makeithappen.model.task.TaskFactory;
25: import org.eclipse.emf.ecp.makeithappen.model.task.TaskPackage;
26: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
27: import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
28: import org.eclipse.emf.edit.provider.IItemLabelProvider;
29: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
30: import org.eclipse.emf.edit.provider.IItemPropertySource;
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:
36: /**
37: * This is the item provider adapter for a {@link org.eclipse.emf.ecp.makeithappen.model.task.Task} object.
38: * <!-- begin-user-doc -->
39: * <!-- end-user-doc -->
40: *
41: * @generated
42: */
43: public class TaskItemProvider
44:         extends ItemProviderAdapter
45:         implements
46:         IEditingDomainItemProvider,
47:         ITreeItemContentProvider,
48:         IItemLabelProvider,
49:         IItemPropertySource {
50:         /**
51:          * This constructs an instance from a factory and a notifier.
52:          * <!-- begin-user-doc -->
53:          * <!-- end-user-doc -->
54:          *
55:          * @generated
56:          */
57:         public TaskItemProvider(AdapterFactory adapterFactory) {
58:                 super(adapterFactory);
59:         }
60:
61:         /**
62:          * This returns the property descriptors for the adapted class.
63:          * <!-- begin-user-doc -->
64:          * <!-- end-user-doc -->
65:          *
66:          * @generated
67:          */
68:•        @Override
69:         public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
70:                 if (itemPropertyDescriptors == null) {
71:                         super.getPropertyDescriptors(object);
72:
73:                         addNamePropertyDescriptor(object);
74:                         addDescriptionPropertyDescriptor(object);
75:                         addAssigneePropertyDescriptor(object);
76:                         addDueDatePropertyDescriptor(object);
77:                         addDonePropertyDescriptor(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_Task_name_feature"), //$NON-NLS-1$
94:                                 getString("_UI_PropertyDescriptor_description", "_UI_Task_name_feature", "_UI_Task_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
95:                                 TaskPackage.Literals.TASK__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 Description feature.
106:          * <!-- begin-user-doc -->
107:          * <!-- end-user-doc -->
108:          *
109:          * @generated
110:          */
111:         protected void addDescriptionPropertyDescriptor(Object object) {
112:                 itemPropertyDescriptors
113:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
114:                                 getResourceLocator(),
115:                                 getString("_UI_Task_description_feature"), //$NON-NLS-1$
116:                                 getString("_UI_PropertyDescriptor_description", "_UI_Task_description_feature", "_UI_Task_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
117:                                 TaskPackage.Literals.TASK__DESCRIPTION,
118:                                 true,
119:                                 true,
120:                                 false,
121:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
122:                                 null,
123:                                 null));
124:         }
125:
126:         /**
127:          * This adds a property descriptor for the Assignee feature.
128:          * <!-- begin-user-doc -->
129:          * <!-- end-user-doc -->
130:          *
131:          * @generated
132:          */
133:         protected void addAssigneePropertyDescriptor(Object object) {
134:                 itemPropertyDescriptors
135:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
136:                                 getResourceLocator(),
137:                                 getString("_UI_Task_assignee_feature"), //$NON-NLS-1$
138:                                 getString("_UI_PropertyDescriptor_description", "_UI_Task_assignee_feature", "_UI_Task_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
139:                                 TaskPackage.Literals.TASK__ASSIGNEE,
140:                                 true,
141:                                 false,
142:                                 true,
143:                                 null,
144:                                 null,
145:                                 null));
146:         }
147:
148:         /**
149:          * This adds a property descriptor for the Due Date feature.
150:          * <!-- begin-user-doc -->
151:          * <!-- end-user-doc -->
152:          *
153:          * @generated
154:          */
155:         protected void addDueDatePropertyDescriptor(Object object) {
156:                 itemPropertyDescriptors
157:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
158:                                 getResourceLocator(),
159:                                 getString("_UI_Task_dueDate_feature"), //$NON-NLS-1$
160:                                 getString("_UI_PropertyDescriptor_description", "_UI_Task_dueDate_feature", "_UI_Task_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
161:                                 TaskPackage.Literals.TASK__DUE_DATE,
162:                                 true,
163:                                 false,
164:                                 false,
165:                                 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
166:                                 null,
167:                                 null));
168:         }
169:
170:         /**
171:          * This adds a property descriptor for the Done feature.
172:          * <!-- begin-user-doc -->
173:          * <!-- end-user-doc -->
174:          *
175:          * @generated
176:          */
177:         protected void addDonePropertyDescriptor(Object object) {
178:                 itemPropertyDescriptors
179:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
180:                                 getResourceLocator(),
181:                                 getString("_UI_Task_done_feature"), //$NON-NLS-1$
182:                                 getString("_UI_PropertyDescriptor_description", "_UI_Task_done_feature", "_UI_Task_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
183:                                 TaskPackage.Literals.TASK__DONE,
184:                                 true,
185:                                 false,
186:                                 false,
187:                                 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
188:                                 null,
189:                                 null));
190:         }
191:
192:         /**
193:          * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
194:          * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
195:          * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
196:          * <!-- begin-user-doc -->
197:          * <!-- end-user-doc -->
198:          *
199:          * @generated
200:          */
201:         @Override
202:         public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
203:                 if (childrenFeatures == null) {
204:                         super.getChildrenFeatures(object);
205:                         childrenFeatures.add(TaskPackage.Literals.TASK__SUB_TASKS);
206:                 }
207:•                return childrenFeatures;
208:         }
209:
210:         /**
211:          * <!-- begin-user-doc -->
212:          * <!-- end-user-doc -->
213:          *
214:          * @generated
215:          */
216:         @Override
217:         protected EStructuralFeature getChildFeature(Object object, Object child) {
218:                 // Check the type of the specified child object and return the proper feature to use for
219:                 // adding (see {@link AddCommand}) it as a child.
220:
221:                 return super.getChildFeature(object, child);
222:         }
223:
224:         /**
225:          * This returns Task.gif.
226:          * <!-- begin-user-doc -->
227:          * <!-- end-user-doc -->
228:          *
229:          * @param object the object.
230:          * @return the image.
231:          * @generated NOT
232:          */
233:         @Override
234:         public Object getImage(Object object) {
235:                 final Task task = (Task) object;
236:                 if (task.isDone()) {
237:                         return overlayImage(object, getResourceLocator().getImage("full/obj16/bullet_green.png")); //$NON-NLS-1$
238:                 }
239:                 return overlayImage(object, getResourceLocator().getImage("full/obj16/bullet_red.png")); //$NON-NLS-1$
240:         }
241:•
242:         /**
243:          * This returns the label text for the adapted class.
244:          * <!-- begin-user-doc -->
245:          * <!-- end-user-doc -->
246:          *
247:          * @generated
248:          */
249:         @Override
250:         public String getText(Object object) {
251:                 final String label = ((Task) object).getName();
252:                 return label == null || label.length() == 0 ? getString("_UI_Task_type") : //$NON-NLS-1$
253:                         getString("_UI_Task_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
254:         }
255:
256:         /**
257:•         * This handles model notifications by calling {@link #updateChildren} to update any cached
258:          * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
259:          * <!-- begin-user-doc -->
260:          * <!-- end-user-doc -->
261:          *
262:          * @generated
263:          */
264:         @Override
265:         public void notifyChanged(Notification notification) {
266:                 updateChildren(notification);
267:
268:                 switch (notification.getFeatureID(Task.class)) {
269:                 case TaskPackage.TASK__NAME:
270:                 case TaskPackage.TASK__DESCRIPTION:
271:                 case TaskPackage.TASK__DUE_DATE:
272:                 case TaskPackage.TASK__DONE:
273:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
274:•                        return;
275:                 case TaskPackage.TASK__SUB_TASKS:
276:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
277:                         return;
278:                 }
279:                 super.notifyChanged(notification);
280:         }
281:
282:         /**
283:          * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
284:          * that can be created under this object.
285:          * <!-- begin-user-doc -->
286:          * <!-- end-user-doc -->
287:          *
288:          * @generated
289:          */
290:         @Override
291:         protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
292:                 super.collectNewChildDescriptors(newChildDescriptors, object);
293:
294:                 newChildDescriptors.add(createChildParameter(TaskPackage.Literals.TASK__SUB_TASKS,
295:                         TaskFactory.eINSTANCE.createTask()));
296:         }
297:
298:         /**
299:          * Return the resource locator for this item provider's resources.
300:          * <!-- begin-user-doc -->
301:          * <!-- end-user-doc -->
302:          *
303:          * @generated
304:          */
305:         @Override
306:         public ResourceLocator getResourceLocator() {
307:                 return TaskEditPlugin.INSTANCE;
308:         }
309:
310: }