1 | /* |
2 | * Copyright 2009, SDQ, IPD, Uni Karlsruhe (TH) |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.resource.part; |
5 | |
6 | import java.util.Collection; |
7 | import java.util.Collections; |
8 | import java.util.Iterator; |
9 | import java.util.LinkedList; |
10 | import java.util.List; |
11 | import java.util.Map; |
12 | |
13 | import org.eclipse.emf.ecore.EStructuralFeature; |
14 | import org.eclipse.emf.ecore.util.EcoreUtil; |
15 | import org.eclipse.gmf.runtime.notation.View; |
16 | |
17 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.CommunicationLinkResourceSpecificationEditPart; |
18 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.LinkingResource2EditPart; |
19 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.LinkingResourceConnectedResourceContainers_LinkingResourceEditPart; |
20 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.LinkingResourceNetworkSwitchCompartmentEditPart; |
21 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ProcessingResourceSpecificationEditPart; |
22 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ResourceContainerEditPart; |
23 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ResourceContainerResourceContainerCompartmentEditPart; |
24 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ResourceEnvironmentEditPart; |
25 | import de.uka.ipd.sdq.pcm.gmf.resource.providers.PalladioComponentModelElementTypes; |
26 | import de.uka.ipd.sdq.pcm.resourceenvironment.CommunicationLinkResourceSpecification; |
27 | import de.uka.ipd.sdq.pcm.resourceenvironment.LinkingResource; |
28 | import de.uka.ipd.sdq.pcm.resourceenvironment.ProcessingResourceSpecification; |
29 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer; |
30 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceEnvironment; |
31 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage; |
32 | |
33 | /** |
34 | * @generated |
35 | */ |
36 | public class PalladioComponentModelDiagramUpdater { |
37 | |
38 | /** |
39 | * @generated |
40 | */ |
41 | public static List getSemanticChildren(View view) { |
42 | switch (PalladioComponentModelVisualIDRegistry.getVisualID(view)) { |
43 | case ResourceContainerResourceContainerCompartmentEditPart.VISUAL_ID: |
44 | return getResourceContainerResourceContainerCompartment_7001SemanticChildren(view); |
45 | case LinkingResourceNetworkSwitchCompartmentEditPart.VISUAL_ID: |
46 | return getLinkingResourceNetworkSwitchCompartment_7003SemanticChildren(view); |
47 | case ResourceEnvironmentEditPart.VISUAL_ID: |
48 | return getResourceEnvironment_1000SemanticChildren(view); |
49 | } |
50 | return Collections.EMPTY_LIST; |
51 | } |
52 | |
53 | /** |
54 | * @generated |
55 | */ |
56 | public static List getResourceContainerResourceContainerCompartment_7001SemanticChildren( |
57 | View view) { |
58 | if (false == view.eContainer() instanceof View) { |
59 | return Collections.EMPTY_LIST; |
60 | } |
61 | View containerView = (View) view.eContainer(); |
62 | if (!containerView.isSetElement()) { |
63 | return Collections.EMPTY_LIST; |
64 | } |
65 | ResourceContainer modelElement = (ResourceContainer) containerView |
66 | .getElement(); |
67 | List result = new LinkedList(); |
68 | for (Iterator it = modelElement |
69 | .getActiveResourceSpecifications_ResourceContainer().iterator(); it |
70 | .hasNext();) { |
71 | ProcessingResourceSpecification childElement = (ProcessingResourceSpecification) it |
72 | .next(); |
73 | int visualID = PalladioComponentModelVisualIDRegistry |
74 | .getNodeVisualID(view, childElement); |
75 | if (visualID == ProcessingResourceSpecificationEditPart.VISUAL_ID) { |
76 | result.add(new PalladioComponentModelNodeDescriptor( |
77 | childElement, visualID)); |
78 | continue; |
79 | } |
80 | } |
81 | return result; |
82 | } |
83 | |
84 | /** |
85 | * @generated |
86 | */ |
87 | public static List getLinkingResourceNetworkSwitchCompartment_7003SemanticChildren( |
88 | View view) { |
89 | if (false == view.eContainer() instanceof View) { |
90 | return Collections.EMPTY_LIST; |
91 | } |
92 | View containerView = (View) view.eContainer(); |
93 | if (!containerView.isSetElement()) { |
94 | return Collections.EMPTY_LIST; |
95 | } |
96 | LinkingResource modelElement = (LinkingResource) containerView |
97 | .getElement(); |
98 | List result = new LinkedList(); |
99 | { |
100 | CommunicationLinkResourceSpecification childElement = modelElement |
101 | .getCommunicationLinkResourceSpecifications_LinkingResource(); |
102 | int visualID = PalladioComponentModelVisualIDRegistry |
103 | .getNodeVisualID(view, childElement); |
104 | if (visualID == CommunicationLinkResourceSpecificationEditPart.VISUAL_ID) { |
105 | result.add(new PalladioComponentModelNodeDescriptor( |
106 | childElement, visualID)); |
107 | } |
108 | } |
109 | return result; |
110 | } |
111 | |
112 | /** |
113 | * @generated |
114 | */ |
115 | public static List getResourceEnvironment_1000SemanticChildren(View view) { |
116 | if (!view.isSetElement()) { |
117 | return Collections.EMPTY_LIST; |
118 | } |
119 | ResourceEnvironment modelElement = (ResourceEnvironment) view |
120 | .getElement(); |
121 | List result = new LinkedList(); |
122 | for (Iterator it = modelElement |
123 | .getResourceContainer_ResourceEnvironment().iterator(); it |
124 | .hasNext();) { |
125 | ResourceContainer childElement = (ResourceContainer) it.next(); |
126 | int visualID = PalladioComponentModelVisualIDRegistry |
127 | .getNodeVisualID(view, childElement); |
128 | if (visualID == ResourceContainerEditPart.VISUAL_ID) { |
129 | result.add(new PalladioComponentModelNodeDescriptor( |
130 | childElement, visualID)); |
131 | continue; |
132 | } |
133 | } |
134 | for (Iterator it = modelElement |
135 | .getLinkingResources__ResourceEnvironment().iterator(); it |
136 | .hasNext();) { |
137 | LinkingResource childElement = (LinkingResource) it.next(); |
138 | int visualID = PalladioComponentModelVisualIDRegistry |
139 | .getNodeVisualID(view, childElement); |
140 | if (visualID == LinkingResource2EditPart.VISUAL_ID) { |
141 | result.add(new PalladioComponentModelNodeDescriptor( |
142 | childElement, visualID)); |
143 | continue; |
144 | } |
145 | } |
146 | return result; |
147 | } |
148 | |
149 | /** |
150 | * @generated |
151 | */ |
152 | public static List getContainedLinks(View view) { |
153 | switch (PalladioComponentModelVisualIDRegistry.getVisualID(view)) { |
154 | case ResourceEnvironmentEditPart.VISUAL_ID: |
155 | return getResourceEnvironment_1000ContainedLinks(view); |
156 | case ResourceContainerEditPart.VISUAL_ID: |
157 | return getResourceContainer_2001ContainedLinks(view); |
158 | case LinkingResource2EditPart.VISUAL_ID: |
159 | return getLinkingResource_2003ContainedLinks(view); |
160 | case ProcessingResourceSpecificationEditPart.VISUAL_ID: |
161 | return getProcessingResourceSpecification_3001ContainedLinks(view); |
162 | case CommunicationLinkResourceSpecificationEditPart.VISUAL_ID: |
163 | return getCommunicationLinkResourceSpecification_3002ContainedLinks(view); |
164 | } |
165 | return Collections.EMPTY_LIST; |
166 | } |
167 | |
168 | /** |
169 | * @generated |
170 | */ |
171 | public static List getIncomingLinks(View view) { |
172 | switch (PalladioComponentModelVisualIDRegistry.getVisualID(view)) { |
173 | case ResourceContainerEditPart.VISUAL_ID: |
174 | return getResourceContainer_2001IncomingLinks(view); |
175 | case LinkingResource2EditPart.VISUAL_ID: |
176 | return getLinkingResource_2003IncomingLinks(view); |
177 | case ProcessingResourceSpecificationEditPart.VISUAL_ID: |
178 | return getProcessingResourceSpecification_3001IncomingLinks(view); |
179 | case CommunicationLinkResourceSpecificationEditPart.VISUAL_ID: |
180 | return getCommunicationLinkResourceSpecification_3002IncomingLinks(view); |
181 | } |
182 | return Collections.EMPTY_LIST; |
183 | } |
184 | |
185 | /** |
186 | * @generated |
187 | */ |
188 | public static List getOutgoingLinks(View view) { |
189 | switch (PalladioComponentModelVisualIDRegistry.getVisualID(view)) { |
190 | case ResourceContainerEditPart.VISUAL_ID: |
191 | return getResourceContainer_2001OutgoingLinks(view); |
192 | case LinkingResource2EditPart.VISUAL_ID: |
193 | return getLinkingResource_2003OutgoingLinks(view); |
194 | case ProcessingResourceSpecificationEditPart.VISUAL_ID: |
195 | return getProcessingResourceSpecification_3001OutgoingLinks(view); |
196 | case CommunicationLinkResourceSpecificationEditPart.VISUAL_ID: |
197 | return getCommunicationLinkResourceSpecification_3002OutgoingLinks(view); |
198 | } |
199 | return Collections.EMPTY_LIST; |
200 | } |
201 | |
202 | /** |
203 | * @generated |
204 | */ |
205 | public static List getResourceEnvironment_1000ContainedLinks(View view) { |
206 | return Collections.EMPTY_LIST; |
207 | } |
208 | |
209 | /** |
210 | * @generated |
211 | */ |
212 | public static List getResourceContainer_2001ContainedLinks(View view) { |
213 | return Collections.EMPTY_LIST; |
214 | } |
215 | |
216 | /** |
217 | * @generated |
218 | */ |
219 | public static List getLinkingResource_2003ContainedLinks(View view) { |
220 | LinkingResource modelElement = (LinkingResource) view.getElement(); |
221 | List result = new LinkedList(); |
222 | result |
223 | .addAll(getOutgoingFeatureModelFacetLinks_LinkingResource_ConnectedResourceContainers_LinkingResource_4002(modelElement)); |
224 | return result; |
225 | } |
226 | |
227 | /** |
228 | * @generated |
229 | */ |
230 | public static List getProcessingResourceSpecification_3001ContainedLinks( |
231 | View view) { |
232 | return Collections.EMPTY_LIST; |
233 | } |
234 | |
235 | /** |
236 | * @generated |
237 | */ |
238 | public static List getCommunicationLinkResourceSpecification_3002ContainedLinks( |
239 | View view) { |
240 | return Collections.EMPTY_LIST; |
241 | } |
242 | |
243 | /** |
244 | * @generated |
245 | */ |
246 | public static List getResourceContainer_2001IncomingLinks(View view) { |
247 | ResourceContainer modelElement = (ResourceContainer) view.getElement(); |
248 | Map crossReferences = EcoreUtil.CrossReferencer.find(view.eResource() |
249 | .getResourceSet().getResources()); |
250 | List result = new LinkedList(); |
251 | result |
252 | .addAll(getIncomingFeatureModelFacetLinks_LinkingResource_ConnectedResourceContainers_LinkingResource_4002( |
253 | modelElement, crossReferences)); |
254 | return result; |
255 | } |
256 | |
257 | /** |
258 | * @generated |
259 | */ |
260 | public static List getLinkingResource_2003IncomingLinks(View view) { |
261 | return Collections.EMPTY_LIST; |
262 | } |
263 | |
264 | /** |
265 | * @generated |
266 | */ |
267 | public static List getProcessingResourceSpecification_3001IncomingLinks( |
268 | View view) { |
269 | return Collections.EMPTY_LIST; |
270 | } |
271 | |
272 | /** |
273 | * @generated |
274 | */ |
275 | public static List getCommunicationLinkResourceSpecification_3002IncomingLinks( |
276 | View view) { |
277 | return Collections.EMPTY_LIST; |
278 | } |
279 | |
280 | /** |
281 | * @generated |
282 | */ |
283 | public static List getResourceContainer_2001OutgoingLinks(View view) { |
284 | return Collections.EMPTY_LIST; |
285 | } |
286 | |
287 | /** |
288 | * @generated |
289 | */ |
290 | public static List getLinkingResource_2003OutgoingLinks(View view) { |
291 | LinkingResource modelElement = (LinkingResource) view.getElement(); |
292 | List result = new LinkedList(); |
293 | result |
294 | .addAll(getOutgoingFeatureModelFacetLinks_LinkingResource_ConnectedResourceContainers_LinkingResource_4002(modelElement)); |
295 | return result; |
296 | } |
297 | |
298 | /** |
299 | * @generated |
300 | */ |
301 | public static List getProcessingResourceSpecification_3001OutgoingLinks( |
302 | View view) { |
303 | return Collections.EMPTY_LIST; |
304 | } |
305 | |
306 | /** |
307 | * @generated |
308 | */ |
309 | public static List getCommunicationLinkResourceSpecification_3002OutgoingLinks( |
310 | View view) { |
311 | return Collections.EMPTY_LIST; |
312 | } |
313 | |
314 | /** |
315 | * @generated |
316 | */ |
317 | private static Collection getIncomingFeatureModelFacetLinks_LinkingResource_ConnectedResourceContainers_LinkingResource_4002( |
318 | ResourceContainer target, Map crossReferences) { |
319 | Collection result = new LinkedList(); |
320 | Collection settings = (Collection) crossReferences.get(target); |
321 | for (Iterator it = settings.iterator(); it.hasNext();) { |
322 | EStructuralFeature.Setting setting = (EStructuralFeature.Setting) it |
323 | .next(); |
324 | if (setting.getEStructuralFeature() == ResourceenvironmentPackage.eINSTANCE |
325 | .getLinkingResource_ConnectedResourceContainers_LinkingResource()) { |
326 | result |
327 | .add(new PalladioComponentModelLinkDescriptor( |
328 | setting.getEObject(), |
329 | target, |
330 | PalladioComponentModelElementTypes.LinkingResourceConnectedResourceContainers_LinkingResource_4002, |
331 | LinkingResourceConnectedResourceContainers_LinkingResourceEditPart.VISUAL_ID)); |
332 | } |
333 | } |
334 | return result; |
335 | } |
336 | |
337 | /** |
338 | * @generated |
339 | */ |
340 | private static Collection getOutgoingFeatureModelFacetLinks_LinkingResource_ConnectedResourceContainers_LinkingResource_4002( |
341 | LinkingResource source) { |
342 | Collection result = new LinkedList(); |
343 | for (Iterator destinations = source |
344 | .getConnectedResourceContainers_LinkingResource().iterator(); destinations |
345 | .hasNext();) { |
346 | ResourceContainer destination = (ResourceContainer) destinations |
347 | .next(); |
348 | result |
349 | .add(new PalladioComponentModelLinkDescriptor( |
350 | source, |
351 | destination, |
352 | PalladioComponentModelElementTypes.LinkingResourceConnectedResourceContainers_LinkingResource_4002, |
353 | LinkingResourceConnectedResourceContainers_LinkingResourceEditPart.VISUAL_ID)); |
354 | } |
355 | return result; |
356 | } |
357 | |
358 | } |