1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.resourceenvironment.provider; |
7 | |
8 | |
9 | import java.util.Collection; |
10 | import java.util.List; |
11 | |
12 | import org.eclipse.emf.common.notify.AdapterFactory; |
13 | import org.eclipse.emf.common.notify.Notification; |
14 | import org.eclipse.emf.common.util.ResourceLocator; |
15 | import org.eclipse.emf.ecore.EStructuralFeature; |
16 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
17 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
18 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
19 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
20 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
21 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
22 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
23 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
24 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
25 | import org.eclipse.emf.edit.provider.ViewerNotification; |
26 | |
27 | import de.uka.ipd.sdq.pcm.core.CoreFactory; |
28 | import de.uka.ipd.sdq.pcm.core.provider.PalladioComponentModelEditPlugin; |
29 | import de.uka.ipd.sdq.pcm.resourceenvironment.ProcessingResourceSpecification; |
30 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage; |
31 | |
32 | /** |
33 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.resourceenvironment.ProcessingResourceSpecification} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class ProcessingResourceSpecificationItemProvider |
39 | extends ItemProviderAdapter |
40 | implements |
41 | IEditingDomainItemProvider, |
42 | IStructuredItemContentProvider, |
43 | ITreeItemContentProvider, |
44 | IItemLabelProvider, |
45 | IItemPropertySource { |
46 | /** |
47 | * <!-- begin-user-doc --> |
48 | * <!-- end-user-doc --> |
49 | * @generated |
50 | */ |
51 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
52 | |
53 | /** |
54 | * This constructs an instance from a factory and a notifier. |
55 | * <!-- begin-user-doc --> |
56 | * <!-- end-user-doc --> |
57 | * @generated |
58 | */ |
59 | public ProcessingResourceSpecificationItemProvider(AdapterFactory adapterFactory) { |
60 | super(adapterFactory); |
61 | } |
62 | |
63 | /** |
64 | * This returns the property descriptors for the adapted class. |
65 | * <!-- begin-user-doc --> |
66 | * <!-- end-user-doc --> |
67 | * @generated |
68 | */ |
69 | @Override |
70 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
71 | if (itemPropertyDescriptors == null) { |
72 | super.getPropertyDescriptors(object); |
73 | |
74 | addMTTRPropertyDescriptor(object); |
75 | addMTTFPropertyDescriptor(object); |
76 | addRequiredByContainerPropertyDescriptor(object); |
77 | addSchedulingPolicyPropertyDescriptor(object); |
78 | addActiveResourceType_ActiveResourceSpecificationPropertyDescriptor(object); |
79 | addNumberOfReplicasPropertyDescriptor(object); |
80 | } |
81 | return itemPropertyDescriptors; |
82 | } |
83 | |
84 | /** |
85 | * This adds a property descriptor for the MTTR feature. |
86 | * <!-- begin-user-doc --> |
87 | * <!-- end-user-doc --> |
88 | * @generated |
89 | */ |
90 | protected void addMTTRPropertyDescriptor(Object object) { |
91 | itemPropertyDescriptors.add |
92 | (createItemPropertyDescriptor |
93 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
94 | getResourceLocator(), |
95 | getString("_UI_ProcessingResourceSpecification_MTTR_feature"), |
96 | getString("_UI_PropertyDescriptor_description", "_UI_ProcessingResourceSpecification_MTTR_feature", "_UI_ProcessingResourceSpecification_type"), |
97 | ResourceenvironmentPackage.Literals.PROCESSING_RESOURCE_SPECIFICATION__MTTR, |
98 | true, |
99 | false, |
100 | false, |
101 | ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
102 | null, |
103 | null)); |
104 | } |
105 | |
106 | /** |
107 | * This adds a property descriptor for the MTTF feature. |
108 | * <!-- begin-user-doc --> |
109 | * <!-- end-user-doc --> |
110 | * @generated |
111 | */ |
112 | protected void addMTTFPropertyDescriptor(Object object) { |
113 | itemPropertyDescriptors.add |
114 | (createItemPropertyDescriptor |
115 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
116 | getResourceLocator(), |
117 | getString("_UI_ProcessingResourceSpecification_MTTF_feature"), |
118 | getString("_UI_PropertyDescriptor_description", "_UI_ProcessingResourceSpecification_MTTF_feature", "_UI_ProcessingResourceSpecification_type"), |
119 | ResourceenvironmentPackage.Literals.PROCESSING_RESOURCE_SPECIFICATION__MTTF, |
120 | true, |
121 | false, |
122 | false, |
123 | ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
124 | null, |
125 | null)); |
126 | } |
127 | |
128 | /** |
129 | * This adds a property descriptor for the Required By Container feature. |
130 | * <!-- begin-user-doc --> |
131 | * <!-- end-user-doc --> |
132 | * @generated |
133 | */ |
134 | protected void addRequiredByContainerPropertyDescriptor(Object object) { |
135 | itemPropertyDescriptors.add |
136 | (createItemPropertyDescriptor |
137 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
138 | getResourceLocator(), |
139 | getString("_UI_ProcessingResourceSpecification_requiredByContainer_feature"), |
140 | getString("_UI_PropertyDescriptor_description", "_UI_ProcessingResourceSpecification_requiredByContainer_feature", "_UI_ProcessingResourceSpecification_type"), |
141 | ResourceenvironmentPackage.Literals.PROCESSING_RESOURCE_SPECIFICATION__REQUIRED_BY_CONTAINER, |
142 | true, |
143 | false, |
144 | false, |
145 | ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, |
146 | null, |
147 | null)); |
148 | } |
149 | |
150 | /** |
151 | * This adds a property descriptor for the Scheduling Policy feature. |
152 | * <!-- begin-user-doc --> |
153 | * <!-- end-user-doc --> |
154 | * @generated |
155 | */ |
156 | protected void addSchedulingPolicyPropertyDescriptor(Object object) { |
157 | itemPropertyDescriptors.add |
158 | (createItemPropertyDescriptor |
159 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
160 | getResourceLocator(), |
161 | getString("_UI_ProcessingResourceSpecification_schedulingPolicy_feature"), |
162 | getString("_UI_PropertyDescriptor_description", "_UI_ProcessingResourceSpecification_schedulingPolicy_feature", "_UI_ProcessingResourceSpecification_type"), |
163 | ResourceenvironmentPackage.Literals.PROCESSING_RESOURCE_SPECIFICATION__SCHEDULING_POLICY, |
164 | true, |
165 | false, |
166 | false, |
167 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
168 | null, |
169 | null)); |
170 | } |
171 | |
172 | /** |
173 | * This adds a property descriptor for the Active Resource Type Active Resource Specification feature. |
174 | * <!-- begin-user-doc --> |
175 | * <!-- end-user-doc --> |
176 | * @generated |
177 | */ |
178 | protected void addActiveResourceType_ActiveResourceSpecificationPropertyDescriptor(Object object) { |
179 | itemPropertyDescriptors.add |
180 | (createItemPropertyDescriptor |
181 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
182 | getResourceLocator(), |
183 | getString("_UI_ProcessingResourceSpecification_activeResourceType_ActiveResourceSpecification_feature"), |
184 | getString("_UI_PropertyDescriptor_description", "_UI_ProcessingResourceSpecification_activeResourceType_ActiveResourceSpecification_feature", "_UI_ProcessingResourceSpecification_type"), |
185 | ResourceenvironmentPackage.Literals.PROCESSING_RESOURCE_SPECIFICATION__ACTIVE_RESOURCE_TYPE_ACTIVE_RESOURCE_SPECIFICATION, |
186 | true, |
187 | false, |
188 | true, |
189 | null, |
190 | null, |
191 | null)); |
192 | } |
193 | |
194 | /** |
195 | * This adds a property descriptor for the Number Of Replicas feature. |
196 | * <!-- begin-user-doc --> |
197 | * <!-- end-user-doc --> |
198 | * @generated |
199 | */ |
200 | protected void addNumberOfReplicasPropertyDescriptor(Object object) { |
201 | itemPropertyDescriptors.add |
202 | (createItemPropertyDescriptor |
203 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
204 | getResourceLocator(), |
205 | getString("_UI_ProcessingResourceSpecification_numberOfReplicas_feature"), |
206 | getString("_UI_PropertyDescriptor_description", "_UI_ProcessingResourceSpecification_numberOfReplicas_feature", "_UI_ProcessingResourceSpecification_type"), |
207 | ResourceenvironmentPackage.Literals.PROCESSING_RESOURCE_SPECIFICATION__NUMBER_OF_REPLICAS, |
208 | true, |
209 | false, |
210 | false, |
211 | ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, |
212 | null, |
213 | null)); |
214 | } |
215 | |
216 | /** |
217 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
218 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
219 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
220 | * <!-- begin-user-doc --> |
221 | * <!-- end-user-doc --> |
222 | * @generated |
223 | */ |
224 | @Override |
225 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
226 | if (childrenFeatures == null) { |
227 | super.getChildrenFeatures(object); |
228 | childrenFeatures.add(ResourceenvironmentPackage.Literals.PROCESSING_RESOURCE_SPECIFICATION__PROCESSING_RATE_PROCESSING_RESOURCE_SPECIFICATION); |
229 | } |
230 | return childrenFeatures; |
231 | } |
232 | |
233 | /** |
234 | * <!-- begin-user-doc --> |
235 | * <!-- end-user-doc --> |
236 | * @generated |
237 | */ |
238 | @Override |
239 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
240 | // Check the type of the specified child object and return the proper feature to use for |
241 | // adding (see {@link AddCommand}) it as a child. |
242 | |
243 | return super.getChildFeature(object, child); |
244 | } |
245 | |
246 | /** |
247 | * This returns ProcessingResourceSpecification.gif. |
248 | * <!-- begin-user-doc --> |
249 | * <!-- end-user-doc --> |
250 | * @generated |
251 | */ |
252 | @Override |
253 | public Object getImage(Object object) { |
254 | return overlayImage(object, getResourceLocator().getImage("full/obj16/ProcessingResourceSpecification")); |
255 | } |
256 | |
257 | /** |
258 | * This returns the label text for the adapted class. |
259 | * <!-- begin-user-doc --> |
260 | * <!-- end-user-doc --> |
261 | * @generated |
262 | */ |
263 | @Override |
264 | public String getText(Object object) { |
265 | ProcessingResourceSpecification processingResourceSpecification = (ProcessingResourceSpecification)object; |
266 | return getString("_UI_ProcessingResourceSpecification_type") + " " + processingResourceSpecification.getMTTR(); |
267 | } |
268 | |
269 | /** |
270 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
271 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
272 | * <!-- begin-user-doc --> |
273 | * <!-- end-user-doc --> |
274 | * @generated |
275 | */ |
276 | @Override |
277 | public void notifyChanged(Notification notification) { |
278 | updateChildren(notification); |
279 | |
280 | switch (notification.getFeatureID(ProcessingResourceSpecification.class)) { |
281 | case ResourceenvironmentPackage.PROCESSING_RESOURCE_SPECIFICATION__MTTR: |
282 | case ResourceenvironmentPackage.PROCESSING_RESOURCE_SPECIFICATION__MTTF: |
283 | case ResourceenvironmentPackage.PROCESSING_RESOURCE_SPECIFICATION__REQUIRED_BY_CONTAINER: |
284 | case ResourceenvironmentPackage.PROCESSING_RESOURCE_SPECIFICATION__SCHEDULING_POLICY: |
285 | case ResourceenvironmentPackage.PROCESSING_RESOURCE_SPECIFICATION__NUMBER_OF_REPLICAS: |
286 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
287 | return; |
288 | case ResourceenvironmentPackage.PROCESSING_RESOURCE_SPECIFICATION__PROCESSING_RATE_PROCESSING_RESOURCE_SPECIFICATION: |
289 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
290 | return; |
291 | } |
292 | super.notifyChanged(notification); |
293 | } |
294 | |
295 | /** |
296 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
297 | * that can be created under this object. |
298 | * <!-- begin-user-doc --> |
299 | * <!-- end-user-doc --> |
300 | * @generated |
301 | */ |
302 | @Override |
303 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
304 | super.collectNewChildDescriptors(newChildDescriptors, object); |
305 | |
306 | newChildDescriptors.add |
307 | (createChildParameter |
308 | (ResourceenvironmentPackage.Literals.PROCESSING_RESOURCE_SPECIFICATION__PROCESSING_RATE_PROCESSING_RESOURCE_SPECIFICATION, |
309 | CoreFactory.eINSTANCE.createPCMRandomVariable())); |
310 | } |
311 | |
312 | /** |
313 | * Return the resource locator for this item provider's resources. |
314 | * <!-- begin-user-doc --> |
315 | * <!-- end-user-doc --> |
316 | * @generated |
317 | */ |
318 | @Override |
319 | public ResourceLocator getResourceLocator() { |
320 | return PalladioComponentModelEditPlugin.INSTANCE; |
321 | } |
322 | |
323 | } |