Skip to content

Package: CategorizationElementItemProvider

CategorizationElementItemProvider

nameinstructionbranchcomplexitylinemethod
CategorizationElementItemProvider(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%
addMainCategoryDepthPropertyDescriptor(Object)
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 14
100%
M: 0 C: 1
100%
collectNewChildDescriptors(Collection, Object)
M: 0 C: 21
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
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%
getChildren(Object)
M: 0 C: 23
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
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%
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: 13
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getText(Object)
M: 4 C: 19
83%
M: 4 C: 2
33%
M: 3 C: 1
25%
M: 0 C: 4
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-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: * EclipseSource Munich - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.view.spi.categorization.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.EList;
22: import org.eclipse.emf.ecore.EStructuralFeature;
23: import org.eclipse.emf.ecp.view.spi.categorization.model.VAbstractCategorization;
24: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorizableElement;
25: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorizationElement;
26: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorizationFactory;
27: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorizationPackage;
28: import org.eclipse.emf.ecp.view.spi.model.VElement;
29: import org.eclipse.emf.ecp.view.spi.model.VElementUtil;
30: import org.eclipse.emf.ecp.view.spi.model.provider.ContainedElementItemProvider;
31: import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
32: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
33: import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
34: import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
35: import org.eclipse.emf.edit.provider.ViewerNotification;
36:
37: /**
38: * This is the item provider adapter for a
39: * {@link org.eclipse.emf.ecp.view.spi.categorization.model.VCategorizationElement} object.
40: * <!-- begin-user-doc -->
41: * <!-- end-user-doc -->
42: *
43: * @generated
44: */
45: public class CategorizationElementItemProvider
46:         extends ContainedElementItemProvider {
47:         /**
48:          * This constructs an instance from a factory and a notifier.
49:          * <!-- begin-user-doc -->
50:          * <!-- end-user-doc -->
51:          *
52:          * @generated
53:          */
54:         public CategorizationElementItemProvider(AdapterFactory adapterFactory) {
55:                 super(adapterFactory);
56:         }
57:
58:         /**
59:          * This returns the property descriptors for the adapted class.
60:          * <!-- begin-user-doc -->
61:          * <!-- end-user-doc -->
62:          *
63:          * @generated
64:          */
65:         @Override
66:         public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
67:•                if (itemPropertyDescriptors == null) {
68:                         super.getPropertyDescriptors(object);
69:
70:                         addMainCategoryDepthPropertyDescriptor(object);
71:                 }
72:                 return itemPropertyDescriptors;
73:         }
74:
75:         /**
76:          * This adds a property descriptor for the Main Category Depth feature.
77:          * <!-- begin-user-doc -->
78:          * <!-- end-user-doc -->
79:          *
80:          * @generated
81:          */
82:         protected void addMainCategoryDepthPropertyDescriptor(Object object) {
83:                 itemPropertyDescriptors
84:                         .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
85:                                 getResourceLocator(),
86:                                 getString("_UI_CategorizationElement_mainCategoryDepth_feature"), //$NON-NLS-1$
87:                                 getString("_UI_PropertyDescriptor_description", "_UI_CategorizationElement_mainCategoryDepth_feature", //$NON-NLS-1$ //$NON-NLS-2$
88:                                         "_UI_CategorizationElement_type"), //$NON-NLS-1$
89:                                 VCategorizationPackage.Literals.CATEGORIZATION_ELEMENT__MAIN_CATEGORY_DEPTH,
90:                                 true,
91:                                 false,
92:                                 false,
93:                                 ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE,
94:                                 null,
95:                                 null));
96:         }
97:
98:         /**
99:          * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
100:          * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
101:          * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
102:          * <!-- begin-user-doc -->
103:          * <!-- end-user-doc -->
104:          *
105:          * @generated
106:          */
107:         @Override
108:         public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
109:•                if (childrenFeatures == null) {
110:                         super.getChildrenFeatures(object);
111:                         childrenFeatures.add(VCategorizationPackage.Literals.CATEGORIZATION_ELEMENT__CATEGORIZATIONS);
112:                 }
113:                 return childrenFeatures;
114:         }
115:
116:         /**
117:          * <!-- begin-user-doc -->
118:          * <!-- end-user-doc -->
119:          *
120:          * @generated
121:          */
122:         @Override
123:         protected EStructuralFeature getChildFeature(Object object, Object child) {
124:                 // Check the type of the specified child object and return the proper feature to use for
125:                 // adding (see {@link AddCommand}) it as a child.
126:
127:                 return super.getChildFeature(object, child);
128:         }
129:
130:         /**
131:          * This returns CategorizationElement.gif.
132:          * <!-- begin-user-doc -->
133:          * <!-- end-user-doc -->
134:          *
135:          * @generated
136:          */
137:         @Override
138:         public Object getImage(Object object) {
139:                 return overlayImage(object, getResourceLocator().getImage("full/obj16/CategorizationElement")); //$NON-NLS-1$
140:         }
141:
142:         /**
143:          * This returns the label text for the adapted class.
144:          * <!-- begin-user-doc -->
145:          * <!-- end-user-doc -->
146:          *
147:          * @generated NOT
148:          */
149:         @Override
150:         public String getText(Object object) {
151:                 String label = ((VCategorizationElement) object).getLabel();
152:•                if (label == null) {
153:                         label = VElementUtil.getCleanName(VElement.class.cast(object));
154:                 }
155:•                return label == null || label.length() == 0 ? getString("_UI_CategorizationElement_type") : label; //$NON-NLS-1$
156:         }
157:
158:         /**
159:          * This handles model notifications by calling {@link #updateChildren} to update any cached
160:          * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
161:          * <!-- begin-user-doc -->
162:          * <!-- end-user-doc -->
163:          *
164:          * @generated
165:          */
166:         @Override
167:         public void notifyChanged(Notification notification) {
168:                 updateChildren(notification);
169:
170:•                switch (notification.getFeatureID(VCategorizationElement.class)) {
171:                 case VCategorizationPackage.CATEGORIZATION_ELEMENT__MAIN_CATEGORY_DEPTH:
172:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
173:                         return;
174:                 case VCategorizationPackage.CATEGORIZATION_ELEMENT__CATEGORIZATIONS:
175:                         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
176:                         return;
177:                 }
178:                 super.notifyChanged(notification);
179:         }
180:
181:         /**
182:          * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
183:          * that can be created under this object.
184:          * <!-- begin-user-doc -->
185:          * <!-- end-user-doc -->
186:          *
187:          * @generated
188:          */
189:         @Override
190:         protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
191:                 super.collectNewChildDescriptors(newChildDescriptors, object);
192:
193:                 newChildDescriptors
194:                         .add(createChildParameter(VCategorizationPackage.Literals.CATEGORIZATION_ELEMENT__CATEGORIZATIONS,
195:                                 VCategorizationFactory.eINSTANCE.createCategorization()));
196:
197:                 newChildDescriptors
198:                         .add(createChildParameter(VCategorizationPackage.Literals.CATEGORIZATION_ELEMENT__CATEGORIZATIONS,
199:                                 VCategorizationFactory.eINSTANCE.createCategory()));
200:         }
201:
202:         @Override
203:         public Collection<?> getChildren(Object object) {
204:                 final EList<VAbstractCategorization> children = ((VCategorizationElement) object)
205:                         .getCategorizations();
206:
207:•                for (final VCategorizableElement element : children) {
208:                         adapterFactory.adapt(element, IStructuredItemContentProvider.class);
209:                 }
210:                 return children;
211:         }
212:
213: }