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