1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.fzi.se.quality.parameters.provider; |
8 | |
9 | |
10 | import de.fzi.se.quality.parameters.CallInstance; |
11 | import de.fzi.se.quality.parameters.ParametersFactory; |
12 | import de.fzi.se.quality.parameters.ParametersPackage; |
13 | |
14 | import de.fzi.se.quality.parameters.pcm.PCMFactory; |
15 | |
16 | import de.fzi.se.quality.provider.QualityEditPlugin; |
17 | |
18 | import de.uka.ipd.sdq.identifier.provider.IdentifierItemProvider; |
19 | |
20 | import java.util.Collection; |
21 | import java.util.List; |
22 | |
23 | import org.eclipse.emf.common.notify.AdapterFactory; |
24 | import org.eclipse.emf.common.notify.Notification; |
25 | |
26 | import org.eclipse.emf.common.util.ResourceLocator; |
27 | |
28 | import org.eclipse.emf.ecore.EStructuralFeature; |
29 | |
30 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
31 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
32 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
33 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
34 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
35 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
36 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
37 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
38 | import org.eclipse.emf.edit.provider.ViewerNotification; |
39 | |
40 | /** |
41 | * This is the item provider adapter for a {@link de.fzi.se.quality.parameters.CallInstance} object. |
42 | * <!-- begin-user-doc --> |
43 | * <!-- end-user-doc --> |
44 | * @generated |
45 | */ |
46 | public class CallInstanceItemProvider |
47 | extends IdentifierItemProvider |
48 | implements |
49 | IEditingDomainItemProvider, |
50 | IStructuredItemContentProvider, |
51 | ITreeItemContentProvider, |
52 | IItemLabelProvider, |
53 | IItemPropertySource { |
54 | /** |
55 | * This constructs an instance from a factory and a notifier. |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @generated |
59 | */ |
60 | public CallInstanceItemProvider(AdapterFactory adapterFactory) { |
61 | super(adapterFactory); |
62 | } |
63 | |
64 | /** |
65 | * This returns the property descriptors for the adapted class. |
66 | * <!-- begin-user-doc --> |
67 | * <!-- end-user-doc --> |
68 | * @generated |
69 | */ |
70 | @Override |
71 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
72 | if (itemPropertyDescriptors == null) { |
73 | super.getPropertyDescriptors(object); |
74 | |
75 | addNumberOfCallsPropertyDescriptor(object); |
76 | } |
77 | return itemPropertyDescriptors; |
78 | } |
79 | |
80 | /** |
81 | * This adds a property descriptor for the Number Of Calls feature. |
82 | * <!-- begin-user-doc --> |
83 | * <!-- end-user-doc --> |
84 | * @generated |
85 | */ |
86 | protected void addNumberOfCallsPropertyDescriptor(Object object) { |
87 | itemPropertyDescriptors.add |
88 | (createItemPropertyDescriptor |
89 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
90 | getResourceLocator(), |
91 | getString("_UI_CallInstance_numberOfCalls_feature"), |
92 | getString("_UI_PropertyDescriptor_description", "_UI_CallInstance_numberOfCalls_feature", "_UI_CallInstance_type"), |
93 | ParametersPackage.Literals.CALL_INSTANCE__NUMBER_OF_CALLS, |
94 | true, |
95 | false, |
96 | false, |
97 | ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, |
98 | null, |
99 | null)); |
100 | } |
101 | |
102 | /** |
103 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
104 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
105 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
106 | * <!-- begin-user-doc --> |
107 | * <!-- end-user-doc --> |
108 | * @generated |
109 | */ |
110 | @Override |
111 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
112 | if (childrenFeatures == null) { |
113 | super.getChildrenFeatures(object); |
114 | childrenFeatures.add(ParametersPackage.Literals.CALL_INSTANCE__OPERATION_REFERENCE); |
115 | childrenFeatures.add(ParametersPackage.Literals.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES); |
116 | childrenFeatures.add(ParametersPackage.Literals.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES); |
117 | } |
118 | return childrenFeatures; |
119 | } |
120 | |
121 | /** |
122 | * <!-- begin-user-doc --> |
123 | * <!-- end-user-doc --> |
124 | * @generated |
125 | */ |
126 | @Override |
127 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
128 | // Check the type of the specified child object and return the proper feature to use for |
129 | // adding (see {@link AddCommand}) it as a child. |
130 | |
131 | return super.getChildFeature(object, child); |
132 | } |
133 | |
134 | /** |
135 | * This returns CallInstance.gif. |
136 | * <!-- begin-user-doc --> |
137 | * <!-- end-user-doc --> |
138 | * @generated |
139 | */ |
140 | @Override |
141 | public Object getImage(Object object) { |
142 | return overlayImage(object, getResourceLocator().getImage("full/obj16/CallInstance")); |
143 | } |
144 | |
145 | /** |
146 | * This returns the label text for the adapted class. |
147 | * <!-- begin-user-doc --> |
148 | * <!-- end-user-doc --> |
149 | * @generated |
150 | */ |
151 | @Override |
152 | public String getText(Object object) { |
153 | String label = ((CallInstance)object).getId(); |
154 | return label == null || label.length() == 0 ? |
155 | getString("_UI_CallInstance_type") : |
156 | getString("_UI_CallInstance_type") + " " + label; |
157 | } |
158 | |
159 | /** |
160 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
161 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
162 | * <!-- begin-user-doc --> |
163 | * <!-- end-user-doc --> |
164 | * @generated |
165 | */ |
166 | @Override |
167 | public void notifyChanged(Notification notification) { |
168 | updateChildren(notification); |
169 | |
170 | switch (notification.getFeatureID(CallInstance.class)) { |
171 | case ParametersPackage.CALL_INSTANCE__NUMBER_OF_CALLS: |
172 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
173 | return; |
174 | case ParametersPackage.CALL_INSTANCE__OPERATION_REFERENCE: |
175 | case ParametersPackage.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES: |
176 | case ParametersPackage.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES: |
177 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
178 | return; |
179 | } |
180 | super.notifyChanged(notification); |
181 | } |
182 | |
183 | /** |
184 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
185 | * that can be created under this object. |
186 | * <!-- begin-user-doc --> |
187 | * <!-- end-user-doc --> |
188 | * @generated |
189 | */ |
190 | @Override |
191 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
192 | super.collectNewChildDescriptors(newChildDescriptors, object); |
193 | |
194 | newChildDescriptors.add |
195 | (createChildParameter |
196 | (ParametersPackage.Literals.CALL_INSTANCE__OPERATION_REFERENCE, |
197 | PCMFactory.eINSTANCE.createPCMInfrastructureOperationReference())); |
198 | |
199 | newChildDescriptors.add |
200 | (createChildParameter |
201 | (ParametersPackage.Literals.CALL_INSTANCE__OPERATION_REFERENCE, |
202 | PCMFactory.eINSTANCE.createPCMBusinessOperationReference())); |
203 | |
204 | newChildDescriptors.add |
205 | (createChildParameter |
206 | (ParametersPackage.Literals.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES, |
207 | ParametersFactory.eINSTANCE.createParameterInstance())); |
208 | |
209 | newChildDescriptors.add |
210 | (createChildParameter |
211 | (ParametersPackage.Literals.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES, |
212 | ParametersFactory.eINSTANCE.createParameterInstance())); |
213 | } |
214 | |
215 | /** |
216 | * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. |
217 | * <!-- begin-user-doc --> |
218 | * <!-- end-user-doc --> |
219 | * @generated |
220 | */ |
221 | @Override |
222 | public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) { |
223 | Object childFeature = feature; |
224 | Object childObject = child; |
225 | |
226 | boolean qualify = |
227 | childFeature == ParametersPackage.Literals.CALL_INSTANCE__OUTPUT_PARAMETER_INSTANCES || |
228 | childFeature == ParametersPackage.Literals.CALL_INSTANCE__INPUT_PARAMETER_INSTANCES; |
229 | |
230 | if (qualify) { |
231 | return getString |
232 | ("_UI_CreateChild_text2", |
233 | new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); |
234 | } |
235 | return super.getCreateChildText(owner, feature, child, selection); |
236 | } |
237 | |
238 | /** |
239 | * Return the resource locator for this item provider's resources. |
240 | * <!-- begin-user-doc --> |
241 | * <!-- end-user-doc --> |
242 | * @generated |
243 | */ |
244 | @Override |
245 | public ResourceLocator getResourceLocator() { |
246 | return QualityEditPlugin.INSTANCE; |
247 | } |
248 | |
249 | } |