EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.pcm.gmf.composite.part]

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelVisualIDRegistry.java]

nameclass, %method, %block, %line, %
PalladioComponentModelVisualIDRegistry.java0%   (0/1)0%   (0/10)0%   (0/386)0%   (0/152)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelVisualIDRegistry0%   (0/1)0%   (0/10)0%   (0/386)0%   (0/152)
PalladioComponentModelVisualIDRegistry (): void 0%   (0/1)0%   (0/3)0%   (0/1)
canCreateNode (View, int): boolean 0%   (0/1)0%   (0/134)0%   (0/56)
getDiagramVisualID (EObject): int 0%   (0/1)0%   (0/18)0%   (0/7)
getLinkWithClassVisualID (EObject): int 0%   (0/1)0%   (0/46)0%   (0/18)
getModelID (View): String 0%   (0/1)0%   (0/30)0%   (0/7)
getNodeVisualID (View, EObject): int 0%   (0/1)0%   (0/113)0%   (0/46)
getType (int): String 0%   (0/1)0%   (0/3)0%   (0/1)
getVisualID (String): int 0%   (0/1)0%   (0/21)0%   (0/8)
getVisualID (View): int 0%   (0/1)0%   (0/16)0%   (0/7)
isDiagram (ComposedProvidingRequiringEntity): boolean 0%   (0/1)0%   (0/2)0%   (0/1)

1/*
2 *Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.composite.part;
5 
6import org.eclipse.core.runtime.Platform;
7import org.eclipse.emf.ecore.EAnnotation;
8import org.eclipse.emf.ecore.EObject;
9import org.eclipse.gmf.runtime.notation.Diagram;
10import org.eclipse.gmf.runtime.notation.View;
11 
12import de.uka.ipd.sdq.pcm.core.composition.CompositionPackage;
13import de.uka.ipd.sdq.pcm.core.entity.ComposedProvidingRequiringEntity;
14import de.uka.ipd.sdq.pcm.core.entity.EntityPackage;
15import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyConnectorEditPart;
16import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyContextEditPart;
17import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyContextEntityNameEditPart;
18import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyEventConnectorEditPart;
19import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyInfrastructureConnectorEditPart;
20import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ComposedProvidingRequiringEntity2EditPart;
21import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ComposedProvidingRequiringEntityCompositeStructureInnerCompartmentEditPart;
22import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ComposedProvidingRequiringEntityEditPart;
23import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ComposedProvidingRequiringEntityEntityNameEditPart;
24import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.InfrastructureProvidedRoleEditPart;
25import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.InfrastructureProvidedRoleEntityNameEditPart;
26import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.InfrastructureRequiredRoleEditPart;
27import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.InfrastructureRequiredRoleEntityNameEditPart;
28import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationProvidedRole2EditPart;
29import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationProvidedRoleEditPart;
30import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationProvidedRoleEntityName2EditPart;
31import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationProvidedRoleEntityNameEditPart;
32import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationRequiredRole2EditPart;
33import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationRequiredRoleEditPart;
34import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationRequiredRoleEntityName2EditPart;
35import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationRequiredRoleEntityNameEditPart;
36import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ProvidedDelegationConnectorEditPart;
37import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.RequiredDelegationConnectorEditPart;
38import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.SinkRoleEditPart;
39import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.SinkRoleEntityNameEditPart;
40import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.SourceRoleEditPart;
41import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.SourceRoleEntityNameEditPart;
42import de.uka.ipd.sdq.pcm.repository.RepositoryPackage;
43 
44/**
45 * This registry is used to determine which type of visual object should be
46 * created for the corresponding Diagram, Node, ChildNode or Link represented 
47 * by a domain model object.
48 *
49 * @generated
50 */
51public class PalladioComponentModelVisualIDRegistry {
52 
53        /**
54         * @generated
55         */
56        private static final String DEBUG_KEY = "de.uka.ipd.sdq.pcm.gmf.composite/debug/visualID"; //$NON-NLS-1$
57 
58        /**
59         * @generated
60         */
61        public static int getVisualID(View view) {
62                if (view instanceof Diagram) {
63                        if (ComposedProvidingRequiringEntityEditPart.MODEL_ID.equals(view
64                                        .getType())) {
65                                return ComposedProvidingRequiringEntityEditPart.VISUAL_ID;
66                        } else {
67                                return -1;
68                        }
69                }
70                return de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelVisualIDRegistry
71                                .getVisualID(view.getType());
72        }
73 
74        /**
75         * @generated
76         */
77        public static String getModelID(View view) {
78                View diagram = view.getDiagram();
79                while (view != diagram) {
80                        EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
81                        if (annotation != null) {
82                                return (String) annotation.getDetails().get("modelID"); //$NON-NLS-1$
83                        }
84                        view = (View) view.eContainer();
85                }
86                return diagram != null ? diagram.getType() : null;
87        }
88 
89        /**
90         * @generated
91         */
92        public static int getVisualID(String type) {
93                try {
94                        return Integer.parseInt(type);
95                } catch (NumberFormatException e) {
96                        if (Boolean.TRUE.toString().equalsIgnoreCase(
97                                        Platform.getDebugOption(DEBUG_KEY))) {
98                                PalladioComponentModelComposedStructureDiagramEditorPlugin
99                                                .getInstance().logError(
100                                                                "Unable to parse view type as a visualID number: "
101                                                                                + type);
102                        }
103                }
104                return -1;
105        }
106 
107        /**
108         * @generated
109         */
110        public static String getType(int visualID) {
111                return String.valueOf(visualID);
112        }
113 
114        /**
115         * @generated
116         */
117        public static int getDiagramVisualID(EObject domainElement) {
118                if (domainElement == null) {
119                        return -1;
120                }
121                if (EntityPackage.eINSTANCE.getComposedProvidingRequiringEntity()
122                                .isSuperTypeOf(domainElement.eClass())
123                                && isDiagram((ComposedProvidingRequiringEntity) domainElement)) {
124                        return ComposedProvidingRequiringEntityEditPart.VISUAL_ID;
125                }
126                return -1;
127        }
128 
129        /**
130         * @generated
131         */
132        public static int getNodeVisualID(View containerView, EObject domainElement) {
133                if (domainElement == null) {
134                        return -1;
135                }
136                String containerModelID = de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelVisualIDRegistry
137                                .getModelID(containerView);
138                if (!ComposedProvidingRequiringEntityEditPart.MODEL_ID
139                                .equals(containerModelID)) {
140                        return -1;
141                }
142                int containerVisualID;
143                if (ComposedProvidingRequiringEntityEditPart.MODEL_ID
144                                .equals(containerModelID)) {
145                        containerVisualID = de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelVisualIDRegistry
146                                        .getVisualID(containerView);
147                } else {
148                        if (containerView instanceof Diagram) {
149                                containerVisualID = ComposedProvidingRequiringEntityEditPart.VISUAL_ID;
150                        } else {
151                                return -1;
152                        }
153                }
154                switch (containerVisualID) {
155                case ComposedProvidingRequiringEntity2EditPart.VISUAL_ID:
156                        if (RepositoryPackage.eINSTANCE.getOperationProvidedRole()
157                                        .isSuperTypeOf(domainElement.eClass())) {
158                                return OperationProvidedRole2EditPart.VISUAL_ID;
159                        }
160                        if (RepositoryPackage.eINSTANCE.getOperationRequiredRole()
161                                        .isSuperTypeOf(domainElement.eClass())) {
162                                return OperationRequiredRole2EditPart.VISUAL_ID;
163                        }
164                        break;
165                case AssemblyContextEditPart.VISUAL_ID:
166                        if (RepositoryPackage.eINSTANCE.getOperationProvidedRole()
167                                        .isSuperTypeOf(domainElement.eClass())) {
168                                return OperationProvidedRoleEditPart.VISUAL_ID;
169                        }
170                        if (RepositoryPackage.eINSTANCE.getOperationRequiredRole()
171                                        .isSuperTypeOf(domainElement.eClass())) {
172                                return OperationRequiredRoleEditPart.VISUAL_ID;
173                        }
174                        if (RepositoryPackage.eINSTANCE.getSourceRole().isSuperTypeOf(
175                                        domainElement.eClass())) {
176                                return SourceRoleEditPart.VISUAL_ID;
177                        }
178                        if (RepositoryPackage.eINSTANCE.getSinkRole().isSuperTypeOf(
179                                        domainElement.eClass())) {
180                                return SinkRoleEditPart.VISUAL_ID;
181                        }
182                        if (RepositoryPackage.eINSTANCE.getInfrastructureProvidedRole()
183                                        .isSuperTypeOf(domainElement.eClass())) {
184                                return InfrastructureProvidedRoleEditPart.VISUAL_ID;
185                        }
186                        if (RepositoryPackage.eINSTANCE.getInfrastructureRequiredRole()
187                                        .isSuperTypeOf(domainElement.eClass())) {
188                                return InfrastructureRequiredRoleEditPart.VISUAL_ID;
189                        }
190                        break;
191                case ComposedProvidingRequiringEntityCompositeStructureInnerCompartmentEditPart.VISUAL_ID:
192                        if (CompositionPackage.eINSTANCE.getAssemblyContext()
193                                        .isSuperTypeOf(domainElement.eClass())) {
194                                return AssemblyContextEditPart.VISUAL_ID;
195                        }
196                        break;
197                case ComposedProvidingRequiringEntityEditPart.VISUAL_ID:
198                        if (EntityPackage.eINSTANCE.getComposedProvidingRequiringEntity()
199                                        .isSuperTypeOf(domainElement.eClass())) {
200                                return ComposedProvidingRequiringEntity2EditPart.VISUAL_ID;
201                        }
202                        break;
203                }
204                return -1;
205        }
206 
207        /**
208         * @generated
209         */
210        public static boolean canCreateNode(View containerView, int nodeVisualID) {
211                String containerModelID = de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelVisualIDRegistry
212                                .getModelID(containerView);
213                if (!ComposedProvidingRequiringEntityEditPart.MODEL_ID
214                                .equals(containerModelID)) {
215                        return false;
216                }
217                int containerVisualID;
218                if (ComposedProvidingRequiringEntityEditPart.MODEL_ID
219                                .equals(containerModelID)) {
220                        containerVisualID = de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelVisualIDRegistry
221                                        .getVisualID(containerView);
222                } else {
223                        if (containerView instanceof Diagram) {
224                                containerVisualID = ComposedProvidingRequiringEntityEditPart.VISUAL_ID;
225                        } else {
226                                return false;
227                        }
228                }
229                switch (containerVisualID) {
230                case ComposedProvidingRequiringEntity2EditPart.VISUAL_ID:
231                        if (ComposedProvidingRequiringEntityEntityNameEditPart.VISUAL_ID == nodeVisualID) {
232                                return true;
233                        }
234                        if (ComposedProvidingRequiringEntityCompositeStructureInnerCompartmentEditPart.VISUAL_ID == nodeVisualID) {
235                                return true;
236                        }
237                        if (OperationProvidedRole2EditPart.VISUAL_ID == nodeVisualID) {
238                                return true;
239                        }
240                        if (OperationRequiredRole2EditPart.VISUAL_ID == nodeVisualID) {
241                                return true;
242                        }
243                        break;
244                case AssemblyContextEditPart.VISUAL_ID:
245                        if (AssemblyContextEntityNameEditPart.VISUAL_ID == nodeVisualID) {
246                                return true;
247                        }
248                        if (OperationProvidedRoleEditPart.VISUAL_ID == nodeVisualID) {
249                                return true;
250                        }
251                        if (OperationRequiredRoleEditPart.VISUAL_ID == nodeVisualID) {
252                                return true;
253                        }
254                        if (SourceRoleEditPart.VISUAL_ID == nodeVisualID) {
255                                return true;
256                        }
257                        if (SinkRoleEditPart.VISUAL_ID == nodeVisualID) {
258                                return true;
259                        }
260                        if (InfrastructureProvidedRoleEditPart.VISUAL_ID == nodeVisualID) {
261                                return true;
262                        }
263                        if (InfrastructureRequiredRoleEditPart.VISUAL_ID == nodeVisualID) {
264                                return true;
265                        }
266                        break;
267                case OperationProvidedRoleEditPart.VISUAL_ID:
268                        if (OperationProvidedRoleEntityNameEditPart.VISUAL_ID == nodeVisualID) {
269                                return true;
270                        }
271                        break;
272                case OperationRequiredRoleEditPart.VISUAL_ID:
273                        if (OperationRequiredRoleEntityNameEditPart.VISUAL_ID == nodeVisualID) {
274                                return true;
275                        }
276                        break;
277                case SourceRoleEditPart.VISUAL_ID:
278                        if (SourceRoleEntityNameEditPart.VISUAL_ID == nodeVisualID) {
279                                return true;
280                        }
281                        break;
282                case SinkRoleEditPart.VISUAL_ID:
283                        if (SinkRoleEntityNameEditPart.VISUAL_ID == nodeVisualID) {
284                                return true;
285                        }
286                        break;
287                case InfrastructureProvidedRoleEditPart.VISUAL_ID:
288                        if (InfrastructureProvidedRoleEntityNameEditPart.VISUAL_ID == nodeVisualID) {
289                                return true;
290                        }
291                        break;
292                case InfrastructureRequiredRoleEditPart.VISUAL_ID:
293                        if (InfrastructureRequiredRoleEntityNameEditPart.VISUAL_ID == nodeVisualID) {
294                                return true;
295                        }
296                        break;
297                case OperationProvidedRole2EditPart.VISUAL_ID:
298                        if (OperationProvidedRoleEntityName2EditPart.VISUAL_ID == nodeVisualID) {
299                                return true;
300                        }
301                        break;
302                case OperationRequiredRole2EditPart.VISUAL_ID:
303                        if (OperationRequiredRoleEntityName2EditPart.VISUAL_ID == nodeVisualID) {
304                                return true;
305                        }
306                        break;
307                case ComposedProvidingRequiringEntityCompositeStructureInnerCompartmentEditPart.VISUAL_ID:
308                        if (AssemblyContextEditPart.VISUAL_ID == nodeVisualID) {
309                                return true;
310                        }
311                        break;
312                case ComposedProvidingRequiringEntityEditPart.VISUAL_ID:
313                        if (ComposedProvidingRequiringEntity2EditPart.VISUAL_ID == nodeVisualID) {
314                                return true;
315                        }
316                        break;
317                }
318                return false;
319        }
320 
321        /**
322         * @generated
323         */
324        public static int getLinkWithClassVisualID(EObject domainElement) {
325                if (domainElement == null) {
326                        return -1;
327                }
328                if (CompositionPackage.eINSTANCE.getAssemblyConnector().isSuperTypeOf(
329                                domainElement.eClass())) {
330                        return AssemblyConnectorEditPart.VISUAL_ID;
331                }
332                if (CompositionPackage.eINSTANCE.getAssemblyEventConnector()
333                                .isSuperTypeOf(domainElement.eClass())) {
334                        return AssemblyEventConnectorEditPart.VISUAL_ID;
335                }
336                if (CompositionPackage.eINSTANCE.getRequiredDelegationConnector()
337                                .isSuperTypeOf(domainElement.eClass())) {
338                        return RequiredDelegationConnectorEditPart.VISUAL_ID;
339                }
340                if (CompositionPackage.eINSTANCE.getProvidedDelegationConnector()
341                                .isSuperTypeOf(domainElement.eClass())) {
342                        return ProvidedDelegationConnectorEditPart.VISUAL_ID;
343                }
344                if (CompositionPackage.eINSTANCE.getAssemblyInfrastructureConnector()
345                                .isSuperTypeOf(domainElement.eClass())) {
346                        return AssemblyInfrastructureConnectorEditPart.VISUAL_ID;
347                }
348                return -1;
349        }
350 
351        /**
352         * User can change implementation of this method to handle some specific
353         * situations not covered by default logic.
354         * 
355         * @generated
356         */
357        private static boolean isDiagram(ComposedProvidingRequiringEntity element) {
358                return true;
359        }
360}

[all classes][de.uka.ipd.sdq.pcm.gmf.composite.part]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov