Skip to content

Package: StackLayoutItemProvider

StackLayoutItemProvider

nameinstructionbranchcomplexitylinemethod
StackLayoutItemProvider(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%
addDomainModelReferencePropertyDescriptor(Object)
M: 28 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 15 C: 0
0%
M: 1 C: 0
0%
addTopElementPropertyDescriptor(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: 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: 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: 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: 16 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getText(Object)
M: 34 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
notifyChanged(Notification)
M: 22 C: 11
33%
M: 2 C: 1
33%
M: 2 C: 1
33%
M: 4 C: 4
50%
M: 0 C: 1
100%

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