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 [PalladioComponentModelElementTypes.java]

nameclass, %method, %block, %line, %
PalladioComponentModelElementTypes.java0%   (0/1)0%   (0/12)0%   (0/199)0%   (0/71)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelElementTypes0%   (0/1)0%   (0/12)0%   (0/199)0%   (0/71)
<static initializer> 0%   (0/1)0%   (0/10)0%   (0/4)
PalladioComponentModelElementTypes (): void 0%   (0/1)0%   (0/3)0%   (0/2)
getElement (IAdaptable): ENamedElement 0%   (0/1)0%   (0/33)0%   (0/12)
getElementType (String): IElementType 0%   (0/1)0%   (0/4)0%   (0/1)
getImage (ENamedElement): Image 0%   (0/1)0%   (0/26)0%   (0/9)
getImage (IAdaptable): Image 0%   (0/1)0%   (0/10)0%   (0/4)
getImageDescriptor (ENamedElement): ImageDescriptor 0%   (0/1)0%   (0/22)0%   (0/8)
getImageDescriptor (IAdaptable): ImageDescriptor 0%   (0/1)0%   (0/10)0%   (0/4)
getImageRegistry (): ImageRegistry 0%   (0/1)0%   (0/8)0%   (0/3)
getImageRegistryKey (ENamedElement): String 0%   (0/1)0%   (0/3)0%   (0/1)
getProvidedImageDescriptor (ENamedElement): ImageDescriptor 0%   (0/1)0%   (0/48)0%   (0/17)
isKnownElementType (IElementType): boolean 0%   (0/1)0%   (0/22)0%   (0/6)

1/*
2 * Copyright 2007, SDQ, IPD, U KA
3 */
4package de.uka.ipd.sdq.pcm.gmf.allocation.providers;
5 
6import java.util.HashSet;
7import java.util.IdentityHashMap;
8import java.util.Map;
9import java.util.Set;
10 
11import org.eclipse.core.runtime.IAdaptable;
12import org.eclipse.emf.ecore.EClass;
13import org.eclipse.emf.ecore.EClassifier;
14import org.eclipse.emf.ecore.ENamedElement;
15import org.eclipse.emf.ecore.EStructuralFeature;
16import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
17import org.eclipse.gmf.runtime.emf.type.core.IElementType;
18import org.eclipse.jface.resource.ImageDescriptor;
19import org.eclipse.jface.resource.ImageRegistry;
20import org.eclipse.swt.graphics.Image;
21 
22import de.uka.ipd.sdq.pcm.allocation.AllocationPackage;
23import de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelAllocationDiagramEditorPlugin;
24import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage;
25 
26/**
27 * @generated
28 */
29public class PalladioComponentModelElementTypes extends ElementInitializers {
30 
31        /**
32         * @generated
33         */
34        private PalladioComponentModelElementTypes() {
35        }
36 
37        /**
38         * @generated
39         */
40        private static Map elements;
41 
42        /**
43         * @generated
44         */
45        private static ImageRegistry imageRegistry;
46 
47        /**
48         * @generated
49         */
50        private static Set KNOWN_ELEMENT_TYPES;
51 
52        /**
53         * @generated
54         */
55        public static final IElementType Allocation_1000 = getElementType("de.uka.ipd.sdq.pcm.gmf.allocation.Allocation_1000"); //$NON-NLS-1$
56        /**
57         * @generated
58         */
59        public static final IElementType ResourceContainer_2002 = getElementType("de.uka.ipd.sdq.pcm.gmf.allocation.ResourceContainer_2002"); //$NON-NLS-1$
60        /**
61         * @generated
62         */
63        public static final IElementType AllocationContext_3001 = getElementType("de.uka.ipd.sdq.pcm.gmf.allocation.AllocationContext_3001"); //$NON-NLS-1$
64 
65        /**
66         * @generated
67         */
68        private static ImageRegistry getImageRegistry() {
69                if (imageRegistry == null) {
70                        imageRegistry = new ImageRegistry();
71                }
72                return imageRegistry;
73        }
74 
75        /**
76         * @generated
77         */
78        private static String getImageRegistryKey(ENamedElement element) {
79                return element.getName();
80        }
81 
82        /**
83         * @generated
84         */
85        private static ImageDescriptor getProvidedImageDescriptor(
86                        ENamedElement element) {
87                if (element instanceof EStructuralFeature) {
88                        EStructuralFeature feature = ((EStructuralFeature) element);
89                        EClass eContainingClass = feature.getEContainingClass();
90                        EClassifier eType = feature.getEType();
91                        if (eContainingClass != null && !eContainingClass.isAbstract()) {
92                                element = eContainingClass;
93                        } else if (eType instanceof EClass
94                                        && !((EClass) eType).isAbstract()) {
95                                element = eType;
96                        }
97                }
98                if (element instanceof EClass) {
99                        EClass eClass = (EClass) element;
100                        if (!eClass.isAbstract()) {
101                                return PalladioComponentModelAllocationDiagramEditorPlugin
102                                                .getInstance().getItemImageDescriptor(
103                                                                eClass.getEPackage().getEFactoryInstance()
104                                                                                .create(eClass));
105                        }
106                }
107                // TODO : support structural features
108                return null;
109        }
110 
111        /**
112         * @generated
113         */
114        public static ImageDescriptor getImageDescriptor(ENamedElement element) {
115                String key = getImageRegistryKey(element);
116                ImageDescriptor imageDescriptor = getImageRegistry().getDescriptor(key);
117                if (imageDescriptor == null) {
118                        imageDescriptor = getProvidedImageDescriptor(element);
119                        if (imageDescriptor == null) {
120                                imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
121                        }
122                        getImageRegistry().put(key, imageDescriptor);
123                }
124                return imageDescriptor;
125        }
126 
127        /**
128         * @generated
129         */
130        public static Image getImage(ENamedElement element) {
131                String key = getImageRegistryKey(element);
132                Image image = getImageRegistry().get(key);
133                if (image == null) {
134                        ImageDescriptor imageDescriptor = getProvidedImageDescriptor(element);
135                        if (imageDescriptor == null) {
136                                imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
137                        }
138                        getImageRegistry().put(key, imageDescriptor);
139                        image = getImageRegistry().get(key);
140                }
141                return image;
142        }
143 
144        /**
145         * @generated
146         */
147        public static ImageDescriptor getImageDescriptor(IAdaptable hint) {
148                ENamedElement element = getElement(hint);
149                if (element == null) {
150                        return null;
151                }
152                return getImageDescriptor(element);
153        }
154 
155        /**
156         * @generated
157         */
158        public static Image getImage(IAdaptable hint) {
159                ENamedElement element = getElement(hint);
160                if (element == null) {
161                        return null;
162                }
163                return getImage(element);
164        }
165 
166        /**
167         * Returns 'type' of the ecore object associated with the hint.
168         * 
169         * @generated
170         */
171        public static ENamedElement getElement(IAdaptable hint) {
172                Object type = hint.getAdapter(IElementType.class);
173                if (elements == null) {
174                        elements = new IdentityHashMap();
175 
176                        elements.put(Allocation_1000, AllocationPackage.eINSTANCE
177                                        .getAllocation());
178 
179                        elements
180                                        .put(ResourceContainer_2002,
181                                                        ResourceenvironmentPackage.eINSTANCE
182                                                                        .getResourceContainer());
183 
184                        elements.put(AllocationContext_3001, AllocationPackage.eINSTANCE
185                                        .getAllocationContext());
186                }
187                return (ENamedElement) elements.get(type);
188        }
189 
190        /**
191         * @generated
192         */
193        private static IElementType getElementType(String id) {
194                return ElementTypeRegistry.getInstance().getType(id);
195        }
196 
197        /**
198         * @generated
199         */
200        public static boolean isKnownElementType(IElementType elementType) {
201                if (KNOWN_ELEMENT_TYPES == null) {
202                        KNOWN_ELEMENT_TYPES = new HashSet();
203                        KNOWN_ELEMENT_TYPES.add(Allocation_1000);
204                        KNOWN_ELEMENT_TYPES.add(ResourceContainer_2002);
205                        KNOWN_ELEMENT_TYPES.add(AllocationContext_3001);
206                }
207                return KNOWN_ELEMENT_TYPES.contains(elementType);
208        }
209 
210}

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