Skip to content

Package: CategorizationItemProvider

CategorizationItemProvider

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