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.ViewerNotification; |
25 | |
26 | import de.uka.ipd.sdq.identifier.provider.IdentifierItemProvider; |
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.CommunicationLinkResourceSpecification; |
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.CommunicationLinkResourceSpecification} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class CommunicationLinkResourceSpecificationItemProvider |
39 | extends IdentifierItemProvider |
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 CommunicationLinkResourceSpecificationItemProvider(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 | addFailureProbabilityPropertyDescriptor(object); |
75 | addCommunicationLinkResourceType_CommunicationLinkResourceSpecificationPropertyDescriptor(object); |
76 | } |
77 | return itemPropertyDescriptors; |
78 | } |
79 | |
80 | /** |
81 | * This adds a property descriptor for the Failure Probability feature. |
82 | * <!-- begin-user-doc --> |
83 | * <!-- end-user-doc --> |
84 | * @generated |
85 | */ |
86 | protected void addFailureProbabilityPropertyDescriptor(Object object) { |
87 | itemPropertyDescriptors.add |
88 | (createItemPropertyDescriptor |
89 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
90 | getResourceLocator(), |
91 | getString("_UI_CommunicationLinkResourceSpecification_failureProbability_feature"), |
92 | getString("_UI_PropertyDescriptor_description", "_UI_CommunicationLinkResourceSpecification_failureProbability_feature", "_UI_CommunicationLinkResourceSpecification_type"), |
93 | ResourceenvironmentPackage.Literals.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__FAILURE_PROBABILITY, |
94 | true, |
95 | false, |
96 | false, |
97 | ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
98 | null, |
99 | null)); |
100 | } |
101 | |
102 | /** |
103 | * This adds a property descriptor for the Communication Link Resource Type Communication Link Resource Specification feature. |
104 | * <!-- begin-user-doc --> |
105 | * <!-- end-user-doc --> |
106 | * @generated |
107 | */ |
108 | protected void addCommunicationLinkResourceType_CommunicationLinkResourceSpecificationPropertyDescriptor(Object object) { |
109 | itemPropertyDescriptors.add |
110 | (createItemPropertyDescriptor |
111 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
112 | getResourceLocator(), |
113 | getString("_UI_CommunicationLinkResourceSpecification_communicationLinkResourceType_CommunicationLinkResourceSpecification_feature"), |
114 | getString("_UI_PropertyDescriptor_description", "_UI_CommunicationLinkResourceSpecification_communicationLinkResourceType_CommunicationLinkResourceSpecification_feature", "_UI_CommunicationLinkResourceSpecification_type"), |
115 | ResourceenvironmentPackage.Literals.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__COMMUNICATION_LINK_RESOURCE_TYPE_COMMUNICATION_LINK_RESOURCE_SPECIFICATION, |
116 | true, |
117 | false, |
118 | true, |
119 | null, |
120 | null, |
121 | null)); |
122 | } |
123 | |
124 | /** |
125 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
126 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
127 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
128 | * <!-- begin-user-doc --> |
129 | * <!-- end-user-doc --> |
130 | * @generated |
131 | */ |
132 | @Override |
133 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
134 | if (childrenFeatures == null) { |
135 | super.getChildrenFeatures(object); |
136 | childrenFeatures.add(ResourceenvironmentPackage.Literals.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__LATENCY_COMMUNICATION_LINK_RESOURCE_SPECIFICATION); |
137 | childrenFeatures.add(ResourceenvironmentPackage.Literals.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__THROUGHPUT_COMMUNICATION_LINK_RESOURCE_SPECIFICATION); |
138 | } |
139 | return childrenFeatures; |
140 | } |
141 | |
142 | /** |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | @Override |
148 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
149 | // Check the type of the specified child object and return the proper feature to use for |
150 | // adding (see {@link AddCommand}) it as a child. |
151 | |
152 | return super.getChildFeature(object, child); |
153 | } |
154 | |
155 | /** |
156 | * This returns CommunicationLinkResourceSpecification.gif. |
157 | * <!-- begin-user-doc --> |
158 | * <!-- end-user-doc --> |
159 | * @generated |
160 | */ |
161 | @Override |
162 | public Object getImage(Object object) { |
163 | return overlayImage(object, getResourceLocator().getImage("full/obj16/CommunicationLinkResourceSpecification")); |
164 | } |
165 | |
166 | /** |
167 | * This returns the label text for the adapted class. |
168 | * <!-- begin-user-doc --> |
169 | * FB: Adapted method to produce a more informative label for display in non-PCM editors. |
170 | * In PCM editors, display is not controlled by this method but through a more general |
171 | * mechanism (I'n not sure where it's actually controlled, maybe the |
172 | * de.uka.ipd.sdq.pcmbench.tabs.PropertyLabelProvider.getText() method?) |
173 | * <!-- end-user-doc --> |
174 | * @generated not |
175 | */ |
176 | @Override |
177 | public String getText(Object object) { |
178 | String linkingResourceName = "UNSPECIFIED"; |
179 | try { |
180 | linkingResourceName = ((CommunicationLinkResourceSpecification)object). |
181 | getLinkingResource_CommunicationLinkResourceSpecification().getEntityName(); |
182 | } catch(Exception e) {} |
183 | return "ResourceSpecification" |
184 | + " (" + linkingResourceName + ")" |
185 | + " [ID: " + ((CommunicationLinkResourceSpecification)object).getId() + "]" |
186 | + " <" + getString("_UI_CommunicationLinkResourceSpecification_type") + ">"; |
187 | } |
188 | |
189 | /** |
190 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
191 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
192 | * <!-- begin-user-doc --> |
193 | * <!-- end-user-doc --> |
194 | * @generated |
195 | */ |
196 | @Override |
197 | public void notifyChanged(Notification notification) { |
198 | updateChildren(notification); |
199 | |
200 | switch (notification.getFeatureID(CommunicationLinkResourceSpecification.class)) { |
201 | case ResourceenvironmentPackage.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__FAILURE_PROBABILITY: |
202 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
203 | return; |
204 | case ResourceenvironmentPackage.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__LATENCY_COMMUNICATION_LINK_RESOURCE_SPECIFICATION: |
205 | case ResourceenvironmentPackage.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__THROUGHPUT_COMMUNICATION_LINK_RESOURCE_SPECIFICATION: |
206 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
207 | return; |
208 | } |
209 | super.notifyChanged(notification); |
210 | } |
211 | |
212 | /** |
213 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
214 | * that can be created under this object. |
215 | * <!-- begin-user-doc --> |
216 | * <!-- end-user-doc --> |
217 | * @generated |
218 | */ |
219 | @Override |
220 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
221 | super.collectNewChildDescriptors(newChildDescriptors, object); |
222 | |
223 | newChildDescriptors.add |
224 | (createChildParameter |
225 | (ResourceenvironmentPackage.Literals.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__LATENCY_COMMUNICATION_LINK_RESOURCE_SPECIFICATION, |
226 | CoreFactory.eINSTANCE.createPCMRandomVariable())); |
227 | |
228 | newChildDescriptors.add |
229 | (createChildParameter |
230 | (ResourceenvironmentPackage.Literals.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__THROUGHPUT_COMMUNICATION_LINK_RESOURCE_SPECIFICATION, |
231 | CoreFactory.eINSTANCE.createPCMRandomVariable())); |
232 | } |
233 | |
234 | /** |
235 | * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. |
236 | * <!-- begin-user-doc --> |
237 | * <!-- end-user-doc --> |
238 | * @generated |
239 | */ |
240 | @Override |
241 | public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) { |
242 | Object childFeature = feature; |
243 | Object childObject = child; |
244 | |
245 | boolean qualify = |
246 | childFeature == ResourceenvironmentPackage.Literals.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__LATENCY_COMMUNICATION_LINK_RESOURCE_SPECIFICATION || |
247 | childFeature == ResourceenvironmentPackage.Literals.COMMUNICATION_LINK_RESOURCE_SPECIFICATION__THROUGHPUT_COMMUNICATION_LINK_RESOURCE_SPECIFICATION; |
248 | |
249 | if (qualify) { |
250 | return getString |
251 | ("_UI_CreateChild_text2", |
252 | new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); |
253 | } |
254 | return super.getCreateChildText(owner, feature, child, selection); |
255 | } |
256 | |
257 | /** |
258 | * Return the resource locator for this item provider's resources. |
259 | * <!-- begin-user-doc --> |
260 | * <!-- end-user-doc --> |
261 | * @generated |
262 | */ |
263 | @Override |
264 | public ResourceLocator getResourceLocator() { |
265 | return PalladioComponentModelEditPlugin.INSTANCE; |
266 | } |
267 | |
268 | } |