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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelViewProvider.java]

nameclass, %method, %block, %line, %
PalladioComponentModelViewProvider.java0%   (0/1)0%   (0/7)0%   (0/205)0%   (0/84)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelViewProvider0%   (0/1)0%   (0/7)0%   (0/205)0%   (0/84)
PalladioComponentModelViewProvider (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getDiagramViewClass (IAdaptable, String): Class 0%   (0/1)0%   (0/16)0%   (0/6)
getEdgeViewClass (IAdaptable, View, String): Class 0%   (0/1)0%   (0/47)0%   (0/17)
getEdgeViewClass (int): Class 0%   (0/1)0%   (0/4)0%   (0/2)
getNodeViewClass (IAdaptable, View, String): Class 0%   (0/1)0%   (0/102)0%   (0/43)
getNodeViewClass (View, int): Class 0%   (0/1)0%   (0/24)0%   (0/12)
getSemanticElementType (IAdaptable): IElementType 0%   (0/1)0%   (0/9)0%   (0/3)

1/*
2 *Copyright 2007, SDQ, IPD, U KA
3 */
4package de.uka.ipd.sdq.pcm.gmf.allocation.providers;
5 
6import org.eclipse.core.runtime.IAdaptable;
7import org.eclipse.emf.ecore.EClass;
8import org.eclipse.emf.ecore.EObject;
9import org.eclipse.gmf.runtime.diagram.core.providers.AbstractViewProvider;
10import org.eclipse.gmf.runtime.notation.View;
11import org.eclipse.gmf.runtime.emf.type.core.IElementType;
12import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
13import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationComponentLabelEditPart;
14import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationContextEditPart;
15import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationContextEntityNameEditPart;
16import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationEditPart;
17import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerAllocationCompartmentEditPart;
18import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerEditPart;
19import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerEntityNameEditPart;
20 
21import de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelVisualIDRegistry;
22 
23import de.uka.ipd.sdq.pcm.gmf.allocation.view.factories.AllocationComponentLabelViewFactory;
24import de.uka.ipd.sdq.pcm.gmf.allocation.view.factories.AllocationContextEntityNameViewFactory;
25import de.uka.ipd.sdq.pcm.gmf.allocation.view.factories.AllocationContextViewFactory;
26import de.uka.ipd.sdq.pcm.gmf.allocation.view.factories.AllocationViewFactory;
27import de.uka.ipd.sdq.pcm.gmf.allocation.view.factories.ResourceContainerAllocationCompartmentViewFactory;
28import de.uka.ipd.sdq.pcm.gmf.allocation.view.factories.ResourceContainerEntityNameViewFactory;
29import de.uka.ipd.sdq.pcm.gmf.allocation.view.factories.ResourceContainerViewFactory;
30 
31/**
32 * @generated
33 */
34public class PalladioComponentModelViewProvider extends AbstractViewProvider {
35 
36        /**
37         * @generated
38         */
39        protected Class getDiagramViewClass(IAdaptable semanticAdapter,
40                        String diagramKind) {
41                EObject semanticElement = getSemanticElement(semanticAdapter);
42                if (AllocationEditPart.MODEL_ID.equals(diagramKind)
43                                && PalladioComponentModelVisualIDRegistry
44                                                .getDiagramVisualID(semanticElement) != -1) {
45                        return AllocationViewFactory.class;
46                }
47                return null;
48        }
49 
50        /**
51         * @generated
52         */
53        protected Class getNodeViewClass(IAdaptable semanticAdapter,
54                        View containerView, String semanticHint) {
55                if (containerView == null) {
56                        return null;
57                }
58                IElementType elementType = getSemanticElementType(semanticAdapter);
59                EObject domainElement = getSemanticElement(semanticAdapter);
60                int visualID;
61                if (semanticHint == null) {
62                        // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
63                        // In this situation there should be NO elementType, visualID will be determined
64                        // by VisualIDRegistry.getNodeVisualID() for domainElement.
65                        if (elementType != null || domainElement == null) {
66                                return null;
67                        }
68                        visualID = PalladioComponentModelVisualIDRegistry.getNodeVisualID(
69                                        containerView, domainElement);
70                } else {
71                        visualID = PalladioComponentModelVisualIDRegistry
72                                        .getVisualID(semanticHint);
73                        if (elementType != null) {
74                                // Semantic hint is specified together with element type.
75                                // Both parameters should describe exactly the same diagram element.
76                                // In addition we check that visualID returned by VisualIDRegistry.getNodeVisualID() for
77                                // domainElement (if specified) is the same as in element type.
78                                if (!PalladioComponentModelElementTypes
79                                                .isKnownElementType(elementType)
80                                                || (!(elementType instanceof IHintedType))) {
81                                        return null; // foreign element type
82                                }
83                                String elementTypeHint = ((IHintedType) elementType)
84                                                .getSemanticHint();
85                                if (!semanticHint.equals(elementTypeHint)) {
86                                        return null; // if semantic hint is specified it should be the same as in element type
87                                }
88                                if (domainElement != null
89                                                && visualID != PalladioComponentModelVisualIDRegistry
90                                                                .getNodeVisualID(containerView, domainElement)) {
91                                        return null; // visual id for node EClass should match visual id from element type
92                                }
93                        } else {
94                                // Element type is not specified. Domain element should be present (except pure design elements).
95                                // This method is called with EObjectAdapter as parameter from:
96                                //   - ViewService.createNode(View container, EObject eObject, String type, PreferencesHint preferencesHint) 
97                                //   - generated ViewFactory.decorateView() for parent element
98                                if (!AllocationEditPart.MODEL_ID
99                                                .equals(PalladioComponentModelVisualIDRegistry
100                                                                .getModelID(containerView))) {
101                                        return null; // foreign diagram
102                                }
103                                switch (visualID) {
104                                case ResourceContainerEditPart.VISUAL_ID:
105                                case AllocationContextEditPart.VISUAL_ID:
106                                        if (domainElement == null
107                                                        || visualID != PalladioComponentModelVisualIDRegistry
108                                                                        .getNodeVisualID(containerView,
109                                                                                        domainElement)) {
110                                                return null; // visual id in semantic hint should match visual id for domain element
111                                        }
112                                        break;
113                                case ResourceContainerEntityNameEditPart.VISUAL_ID:
114                                case ResourceContainerAllocationCompartmentEditPart.VISUAL_ID:
115                                        if (ResourceContainerEditPart.VISUAL_ID != PalladioComponentModelVisualIDRegistry
116                                                        .getVisualID(containerView)
117                                                        || containerView.getElement() != domainElement) {
118                                                return null; // wrong container
119                                        }
120                                        break;
121                                case AllocationContextEntityNameEditPart.VISUAL_ID:
122                                case AllocationComponentLabelEditPart.VISUAL_ID:
123                                        if (AllocationContextEditPart.VISUAL_ID != PalladioComponentModelVisualIDRegistry
124                                                        .getVisualID(containerView)
125                                                        || containerView.getElement() != domainElement) {
126                                                return null; // wrong container
127                                        }
128                                        break;
129                                default:
130                                        return null;
131                                }
132                        }
133                }
134                return getNodeViewClass(containerView, visualID);
135        }
136 
137        /**
138         * @generated
139         */
140        protected Class getNodeViewClass(View containerView, int visualID) {
141                if (containerView == null
142                                || !PalladioComponentModelVisualIDRegistry.canCreateNode(
143                                                containerView, visualID)) {
144                        return null;
145                }
146                switch (visualID) {
147                case ResourceContainerEditPart.VISUAL_ID:
148                        return ResourceContainerViewFactory.class;
149                case ResourceContainerEntityNameEditPart.VISUAL_ID:
150                        return ResourceContainerEntityNameViewFactory.class;
151                case AllocationContextEditPart.VISUAL_ID:
152                        return AllocationContextViewFactory.class;
153                case AllocationContextEntityNameEditPart.VISUAL_ID:
154                        return AllocationContextEntityNameViewFactory.class;
155                case AllocationComponentLabelEditPart.VISUAL_ID:
156                        return AllocationComponentLabelViewFactory.class;
157                case ResourceContainerAllocationCompartmentEditPart.VISUAL_ID:
158                        return ResourceContainerAllocationCompartmentViewFactory.class;
159                }
160                return null;
161        }
162 
163        /**
164         * @generated
165         */
166        protected Class getEdgeViewClass(IAdaptable semanticAdapter,
167                        View containerView, String semanticHint) {
168                IElementType elementType = getSemanticElementType(semanticAdapter);
169                if (!PalladioComponentModelElementTypes.isKnownElementType(elementType)
170                                || (!(elementType instanceof IHintedType))) {
171                        return null; // foreign element type
172                }
173                String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
174                if (elementTypeHint == null) {
175                        return null; // our hint is visual id and must be specified
176                }
177                if (semanticHint != null && !semanticHint.equals(elementTypeHint)) {
178                        return null; // if semantic hint is specified it should be the same as in element type
179                }
180                int visualID = PalladioComponentModelVisualIDRegistry
181                                .getVisualID(elementTypeHint);
182                EObject domainElement = getSemanticElement(semanticAdapter);
183                if (domainElement != null
184                                && visualID != PalladioComponentModelVisualIDRegistry
185                                                .getLinkWithClassVisualID(domainElement)) {
186                        return null; // visual id for link EClass should match visual id from element type
187                }
188                return getEdgeViewClass(visualID);
189        }
190 
191        /**
192         * @generated
193         */
194        protected Class getEdgeViewClass(int visualID) {
195                switch (visualID) {
196                }
197                return null;
198        }
199 
200        /**
201         * @generated
202         */
203        private IElementType getSemanticElementType(IAdaptable semanticAdapter) {
204                if (semanticAdapter == null) {
205                        return null;
206                }
207                return (IElementType) semanticAdapter.getAdapter(IElementType.class);
208        }
209 
210}

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