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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelVisualIDRegistry.java]

nameclass, %method, %block, %line, %
PalladioComponentModelVisualIDRegistry.java0%   (0/1)0%   (0/11)0%   (0/219)0%   (0/81)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelVisualIDRegistry0%   (0/1)0%   (0/11)0%   (0/219)0%   (0/81)
<static initializer> 0%   (0/1)0%   (0/12)0%   (0/4)
PalladioComponentModelVisualIDRegistry (): void 0%   (0/1)0%   (0/3)0%   (0/1)
canCreateNode (View, int): boolean 0%   (0/1)0%   (0/59)0%   (0/24)
getDiagramVisualID (EObject): int 0%   (0/1)0%   (0/18)0%   (0/7)
getLinkWithClassVisualID (EObject): int 0%   (0/1)0%   (0/6)0%   (0/3)
getModelID (View): String 0%   (0/1)0%   (0/30)0%   (0/7)
getNodeVisualID (View, EObject): int 0%   (0/1)0%   (0/49)0%   (0/20)
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/6)
isDiagram (Allocation): boolean 0%   (0/1)0%   (0/2)0%   (0/1)

1/*
2 *Copyright 2007, SDQ, IPD, U KA
3 */
4package de.uka.ipd.sdq.pcm.gmf.allocation.part;
5 
6import de.uka.ipd.sdq.pcm.allocation.Allocation;
7import de.uka.ipd.sdq.pcm.allocation.AllocationContext;
8import de.uka.ipd.sdq.pcm.allocation.AllocationPackage;
9 
10import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationComponentLabelEditPart;
11import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationContextEditPart;
12import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationContextEntityNameEditPart;
13import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationEditPart;
14import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerAllocationCompartmentEditPart;
15import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerEditPart;
16import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerEntityNameEditPart;
17 
18import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer;
19import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage;
20 
21import org.eclipse.core.runtime.Platform;
22 
23import org.eclipse.emf.ecore.EAnnotation;
24import org.eclipse.emf.ecore.EClass;
25import org.eclipse.emf.ecore.EObject;
26 
27import org.eclipse.gmf.runtime.notation.Diagram;
28import org.eclipse.gmf.runtime.notation.View;
29 
30/**
31 * This registry is used to determine which type of visual object should be
32 * created for the corresponding Diagram, Node, ChildNode or Link represented 
33 * by a domain model object.
34 *
35 * @generated
36 */
37public class PalladioComponentModelVisualIDRegistry {
38 
39        /**
40         * @generated
41         */
42        private static final String DEBUG_KEY = PalladioComponentModelAllocationDiagramEditorPlugin
43                        .getInstance().getBundle().getSymbolicName()
44                        + "/debug/visualID"; //$NON-NLS-1$
45 
46        /**
47         * @generated
48         */
49        public static int getVisualID(View view) {
50                if (view instanceof Diagram) {
51                        if (AllocationEditPart.MODEL_ID.equals(view.getType())) {
52                                return AllocationEditPart.VISUAL_ID;
53                        } else {
54                                return -1;
55                        }
56                }
57                return de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelVisualIDRegistry
58                                .getVisualID(view.getType());
59        }
60 
61        /**
62         * @generated
63         */
64        public static String getModelID(View view) {
65                View diagram = view.getDiagram();
66                while (view != diagram) {
67                        EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
68                        if (annotation != null) {
69                                return (String) annotation.getDetails().get("modelID"); //$NON-NLS-1$
70                        }
71                        view = (View) view.eContainer();
72                }
73                return diagram != null ? diagram.getType() : null;
74        }
75 
76        /**
77         * @generated
78         */
79        public static int getVisualID(String type) {
80                try {
81                        return Integer.parseInt(type);
82                } catch (NumberFormatException e) {
83                        if (Boolean.TRUE.toString().equalsIgnoreCase(
84                                        Platform.getDebugOption(DEBUG_KEY))) {
85                                PalladioComponentModelAllocationDiagramEditorPlugin
86                                                .getInstance().logError(
87                                                                "Unable to parse view type as a visualID number: "
88                                                                                + type);
89                        }
90                }
91                return -1;
92        }
93 
94        /**
95         * @generated
96         */
97        public static String getType(int visualID) {
98                return String.valueOf(visualID);
99        }
100 
101        /**
102         * @generated
103         */
104        public static int getDiagramVisualID(EObject domainElement) {
105                if (domainElement == null) {
106                        return -1;
107                }
108                if (AllocationPackage.eINSTANCE.getAllocation().isSuperTypeOf(
109                                domainElement.eClass())
110                                && isDiagram((Allocation) domainElement)) {
111                        return AllocationEditPart.VISUAL_ID;
112                }
113                return -1;
114        }
115 
116        /**
117         * @generated
118         */
119        public static int getNodeVisualID(View containerView, EObject domainElement) {
120                if (domainElement == null) {
121                        return -1;
122                }
123                String containerModelID = de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelVisualIDRegistry
124                                .getModelID(containerView);
125                if (!AllocationEditPart.MODEL_ID.equals(containerModelID)) {
126                        return -1;
127                }
128                int containerVisualID;
129                if (AllocationEditPart.MODEL_ID.equals(containerModelID)) {
130                        containerVisualID = de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelVisualIDRegistry
131                                        .getVisualID(containerView);
132                } else {
133                        if (containerView instanceof Diagram) {
134                                containerVisualID = AllocationEditPart.VISUAL_ID;
135                        } else {
136                                return -1;
137                        }
138                }
139                switch (containerVisualID) {
140                case ResourceContainerAllocationCompartmentEditPart.VISUAL_ID:
141                        if (AllocationPackage.eINSTANCE.getAllocationContext()
142                                        .isSuperTypeOf(domainElement.eClass())) {
143                                return AllocationContextEditPart.VISUAL_ID;
144                        }
145                        break;
146                case AllocationEditPart.VISUAL_ID:
147                        if (ResourceenvironmentPackage.eINSTANCE.getResourceContainer()
148                                        .isSuperTypeOf(domainElement.eClass())) {
149                                return ResourceContainerEditPart.VISUAL_ID;
150                        }
151                        break;
152                }
153                return -1;
154        }
155 
156        /**
157         * @generated
158         */
159        public static boolean canCreateNode(View containerView, int nodeVisualID) {
160                String containerModelID = de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelVisualIDRegistry
161                                .getModelID(containerView);
162                if (!AllocationEditPart.MODEL_ID.equals(containerModelID)) {
163                        return false;
164                }
165                int containerVisualID;
166                if (AllocationEditPart.MODEL_ID.equals(containerModelID)) {
167                        containerVisualID = de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelVisualIDRegistry
168                                        .getVisualID(containerView);
169                } else {
170                        if (containerView instanceof Diagram) {
171                                containerVisualID = AllocationEditPart.VISUAL_ID;
172                        } else {
173                                return false;
174                        }
175                }
176                switch (containerVisualID) {
177                case ResourceContainerEditPart.VISUAL_ID:
178                        if (ResourceContainerEntityNameEditPart.VISUAL_ID == nodeVisualID) {
179                                return true;
180                        }
181                        if (ResourceContainerAllocationCompartmentEditPart.VISUAL_ID == nodeVisualID) {
182                                return true;
183                        }
184                        break;
185                case AllocationContextEditPart.VISUAL_ID:
186                        if (AllocationContextEntityNameEditPart.VISUAL_ID == nodeVisualID) {
187                                return true;
188                        }
189                        if (AllocationComponentLabelEditPart.VISUAL_ID == nodeVisualID) {
190                                return true;
191                        }
192                        break;
193                case ResourceContainerAllocationCompartmentEditPart.VISUAL_ID:
194                        if (AllocationContextEditPart.VISUAL_ID == nodeVisualID) {
195                                return true;
196                        }
197                        break;
198                case AllocationEditPart.VISUAL_ID:
199                        if (ResourceContainerEditPart.VISUAL_ID == nodeVisualID) {
200                                return true;
201                        }
202                        break;
203                }
204                return false;
205        }
206 
207        /**
208         * @generated
209         */
210        public static int getLinkWithClassVisualID(EObject domainElement) {
211                if (domainElement == null) {
212                        return -1;
213                }
214                return -1;
215        }
216 
217        /**
218         * User can change implementation of this method to handle some specific
219         * situations not covered by default logic.
220         * 
221         * @generated
222         */
223        private static boolean isDiagram(Allocation element) {
224                return true;
225        }
226}

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