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