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