Skip to content

Package: ViewItemProvider

ViewItemProvider

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