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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelSheetLabelProvider.java]

nameclass, %method, %block, %line, %
PalladioComponentModelSheetLabelProvider.java0%   (0/1)0%   (0/6)0%   (0/93)0%   (0/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelSheetLabelProvider0%   (0/1)0%   (0/6)0%   (0/93)0%   (0/27)
PalladioComponentModelSheetLabelProvider (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getElementType (View): IElementType 0%   (0/1)0%   (0/25)0%   (0/9)
getImage (Object): Image 0%   (0/1)0%   (0/15)0%   (0/3)
getText (Object): String 0%   (0/1)0%   (0/24)0%   (0/6)
getView (Object): View 0%   (0/1)0%   (0/17)0%   (0/5)
unwrap (Object): Object 0%   (0/1)0%   (0/9)0%   (0/3)

1/*
2 * Copyright 2007, IPD, SDQ, University of Karlsruhe
3 */
4package de.uka.ipd.sdq.pcm.gmf.repository.sheet;
5 
6import org.eclipse.core.runtime.IAdaptable;
7import org.eclipse.gmf.runtime.emf.type.core.IElementType;
8import org.eclipse.gmf.runtime.notation.View;
9import org.eclipse.jface.viewers.BaseLabelProvider;
10import org.eclipse.jface.viewers.ILabelProvider;
11import org.eclipse.jface.viewers.IStructuredSelection;
12import org.eclipse.swt.graphics.Image;
13 
14import de.uka.ipd.sdq.pcm.gmf.repository.navigator.PalladioComponentModelNavigatorGroup;
15import de.uka.ipd.sdq.pcm.gmf.repository.part.PalladioComponentModelVisualIDRegistry;
16import de.uka.ipd.sdq.pcm.gmf.repository.providers.PalladioComponentModelElementTypes;
17 
18/**
19 * @generated
20 */
21public class PalladioComponentModelSheetLabelProvider extends BaseLabelProvider
22                implements ILabelProvider {
23 
24        /**
25         * @generated
26         */
27        public String getText(Object element) {
28                element = unwrap(element);
29                if (element instanceof PalladioComponentModelNavigatorGroup) {
30                        return ((PalladioComponentModelNavigatorGroup) element)
31                                        .getGroupName();
32                }
33                IElementType etype = getElementType(getView(element));
34                return etype == null ? "" : etype.getDisplayName();
35        }
36 
37        /**
38         * @generated
39         */
40        public Image getImage(Object element) {
41                IElementType etype = getElementType(getView(unwrap(element)));
42                return etype == null ? null : PalladioComponentModelElementTypes
43                                .getImage(etype);
44        }
45 
46        /**
47         * @generated
48         */
49        private Object unwrap(Object element) {
50                if (element instanceof IStructuredSelection) {
51                        return ((IStructuredSelection) element).getFirstElement();
52                }
53                return element;
54        }
55 
56        /**
57         * @generated
58         */
59        private View getView(Object element) {
60                if (element instanceof View) {
61                        return (View) element;
62                }
63                if (element instanceof IAdaptable) {
64                        return (View) ((IAdaptable) element).getAdapter(View.class);
65                }
66                return null;
67        }
68 
69        /**
70         * @generated
71         */
72        private IElementType getElementType(View view) {
73                // For intermediate views climb up the containment hierarchy to find the one associated with an element type.
74                while (view != null) {
75                        int vid = PalladioComponentModelVisualIDRegistry.getVisualID(view);
76                        IElementType etype = PalladioComponentModelElementTypes
77                                        .getElementType(vid);
78                        if (etype != null) {
79                                return etype;
80                        }
81                        view = view.eContainer() instanceof View ? (View) view.eContainer()
82                                        : null;
83                }
84                return null;
85        }
86 
87}

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