1 | /* |
2 | * Copyright 2007, SDQ, IPD, U KA |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.allocation.part; |
5 | |
6 | import java.util.Collections; |
7 | import java.util.Iterator; |
8 | import java.util.LinkedList; |
9 | import java.util.List; |
10 | |
11 | import org.eclipse.emf.ecore.EObject; |
12 | import org.eclipse.emf.ecore.resource.Resource; |
13 | import org.eclipse.gmf.runtime.notation.View; |
14 | |
15 | import de.uka.ipd.sdq.pcm.allocation.Allocation; |
16 | import de.uka.ipd.sdq.pcm.allocation.AllocationContext; |
17 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationContextEditPart; |
18 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationEditPart; |
19 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerAllocationCompartmentEditPart; |
20 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerEditPart; |
21 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer; |
22 | |
23 | /** |
24 | * @generated |
25 | */ |
26 | public class PalladioComponentModelDiagramUpdater { |
27 | |
28 | /** |
29 | * @generated |
30 | */ |
31 | public static List getSemanticChildren(View view) { |
32 | switch (PalladioComponentModelVisualIDRegistry.getVisualID(view)) { |
33 | case ResourceContainerAllocationCompartmentEditPart.VISUAL_ID: |
34 | return getResourceContainerAllocationCompartment_7002SemanticChildren(view); |
35 | case AllocationEditPart.VISUAL_ID: |
36 | return getAllocation_1000SemanticChildren(view); |
37 | } |
38 | return Collections.EMPTY_LIST; |
39 | } |
40 | |
41 | /** |
42 | * @generated not |
43 | */ |
44 | public static List getResourceContainerAllocationCompartment_7002SemanticChildren( |
45 | View view) { |
46 | if (false == view.eContainer() instanceof View) { |
47 | return Collections.EMPTY_LIST; |
48 | } |
49 | View containerView = (View) view.eContainer(); |
50 | if (!containerView.isSetElement()) { |
51 | return Collections.EMPTY_LIST; |
52 | } |
53 | ResourceContainer modelElement = (ResourceContainer) containerView |
54 | .getElement(); |
55 | List result = new LinkedList(); |
56 | // Removed because of patched generator model |
57 | // for (Iterator it = modelElement.getAllocationContexts_Allocation() |
58 | // .iterator(); it.hasNext();) { |
59 | // AllocationContext childElement = (AllocationContext) it.next(); |
60 | // int visualID = PalladioComponentModelVisualIDRegistry |
61 | // .getNodeVisualID(view, childElement); |
62 | // if (visualID == AllocationContextEditPart.VISUAL_ID) { |
63 | // result.add(new PalladioComponentModelNodeDescriptor( |
64 | // childElement, visualID)); |
65 | // continue; |
66 | // } |
67 | // } |
68 | return result; |
69 | } |
70 | |
71 | /** |
72 | * @generated |
73 | */ |
74 | public static List getAllocation_1000SemanticChildren(View view) { |
75 | if (!view.isSetElement()) { |
76 | return Collections.EMPTY_LIST; |
77 | } |
78 | Allocation modelElement = (Allocation) view.getElement(); |
79 | List result = new LinkedList(); |
80 | Resource resource = modelElement.eResource(); |
81 | for (Iterator semanticIterator = getPhantomNodesIterator(resource); semanticIterator |
82 | .hasNext();) { |
83 | EObject childElement = (EObject) semanticIterator.next(); |
84 | if (childElement == modelElement) { |
85 | continue; |
86 | } |
87 | if (PalladioComponentModelVisualIDRegistry.getNodeVisualID(view, |
88 | childElement) == ResourceContainerEditPart.VISUAL_ID) { |
89 | result.add(new PalladioComponentModelNodeDescriptor( |
90 | childElement, ResourceContainerEditPart.VISUAL_ID)); |
91 | continue; |
92 | } |
93 | } |
94 | return result; |
95 | } |
96 | |
97 | /** |
98 | * @generated |
99 | */ |
100 | private static Iterator getPhantomNodesIterator(Resource resource) { |
101 | return resource.getAllContents(); |
102 | } |
103 | |
104 | /** |
105 | * @generated |
106 | */ |
107 | public static List getContainedLinks(View view) { |
108 | switch (PalladioComponentModelVisualIDRegistry.getVisualID(view)) { |
109 | case AllocationEditPart.VISUAL_ID: |
110 | return getAllocation_1000ContainedLinks(view); |
111 | case ResourceContainerEditPart.VISUAL_ID: |
112 | return getResourceContainer_2002ContainedLinks(view); |
113 | case AllocationContextEditPart.VISUAL_ID: |
114 | return getAllocationContext_3001ContainedLinks(view); |
115 | } |
116 | return Collections.EMPTY_LIST; |
117 | } |
118 | |
119 | /** |
120 | * @generated |
121 | */ |
122 | public static List getIncomingLinks(View view) { |
123 | switch (PalladioComponentModelVisualIDRegistry.getVisualID(view)) { |
124 | case ResourceContainerEditPart.VISUAL_ID: |
125 | return getResourceContainer_2002IncomingLinks(view); |
126 | case AllocationContextEditPart.VISUAL_ID: |
127 | return getAllocationContext_3001IncomingLinks(view); |
128 | } |
129 | return Collections.EMPTY_LIST; |
130 | } |
131 | |
132 | /** |
133 | * @generated |
134 | */ |
135 | public static List getOutgoingLinks(View view) { |
136 | switch (PalladioComponentModelVisualIDRegistry.getVisualID(view)) { |
137 | case ResourceContainerEditPart.VISUAL_ID: |
138 | return getResourceContainer_2002OutgoingLinks(view); |
139 | case AllocationContextEditPart.VISUAL_ID: |
140 | return getAllocationContext_3001OutgoingLinks(view); |
141 | } |
142 | return Collections.EMPTY_LIST; |
143 | } |
144 | |
145 | /** |
146 | * @generated |
147 | */ |
148 | public static List getAllocation_1000ContainedLinks(View view) { |
149 | return Collections.EMPTY_LIST; |
150 | } |
151 | |
152 | /** |
153 | * @generated |
154 | */ |
155 | public static List getResourceContainer_2002ContainedLinks(View view) { |
156 | return Collections.EMPTY_LIST; |
157 | } |
158 | |
159 | /** |
160 | * @generated |
161 | */ |
162 | public static List getAllocationContext_3001ContainedLinks(View view) { |
163 | return Collections.EMPTY_LIST; |
164 | } |
165 | |
166 | /** |
167 | * @generated |
168 | */ |
169 | public static List getResourceContainer_2002IncomingLinks(View view) { |
170 | return Collections.EMPTY_LIST; |
171 | } |
172 | |
173 | /** |
174 | * @generated |
175 | */ |
176 | public static List getAllocationContext_3001IncomingLinks(View view) { |
177 | return Collections.EMPTY_LIST; |
178 | } |
179 | |
180 | /** |
181 | * @generated |
182 | */ |
183 | public static List getResourceContainer_2002OutgoingLinks(View view) { |
184 | return Collections.EMPTY_LIST; |
185 | } |
186 | |
187 | /** |
188 | * @generated |
189 | */ |
190 | public static List getAllocationContext_3001OutgoingLinks(View view) { |
191 | return Collections.EMPTY_LIST; |
192 | } |
193 | |
194 | } |