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

COVERAGE SUMMARY FOR SOURCE FILE [PropertyLabelProvider.java]

nameclass, %method, %block, %line, %
PropertyLabelProvider.java0%   (0/2)0%   (0/8)0%   (0/145)0%   (0/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PropertyLabelProvider0%   (0/1)0%   (0/6)0%   (0/132)0%   (0/37)
PropertyLabelProvider (): void 0%   (0/1)0%   (0/43)0%   (0/13)
addListener (ILabelProviderListener): void 0%   (0/1)0%   (0/8)0%   (0/3)
dispose (): void 0%   (0/1)0%   (0/4)0%   (0/2)
getImage (Object): Image 0%   (0/1)0%   (0/23)0%   (0/6)
getText (Object): String 0%   (0/1)0%   (0/46)0%   (0/10)
removeListener (ILabelProviderListener): void 0%   (0/1)0%   (0/8)0%   (0/3)
     
class PropertyLabelProvider$10%   (0/1)0%   (0/2)0%   (0/13)0%   (0/5)
PropertyLabelProvider$1 (PropertyLabelProvider, AdapterFactory): void 0%   (0/1)0%   (0/7)0%   (0/2)
notifyChanged (Notification): void 0%   (0/1)0%   (0/6)0%   (0/3)

1package de.uka.ipd.sdq.pcmbench.tabs;
2import org.eclipse.emf.common.notify.Notification;
3import org.eclipse.emf.ecore.EObject;
4import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
5import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
6import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
7import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
8import org.eclipse.jface.viewers.ILabelProvider;
9import org.eclipse.jface.viewers.ILabelProviderListener;
10import org.eclipse.jface.viewers.IStructuredSelection;
11import org.eclipse.jface.viewers.LabelProvider;
12import org.eclipse.swt.graphics.Image;
13 
14import de.uka.ipd.sdq.pcm.core.entity.Entity;
15import de.uka.ipd.sdq.pcm.repository.provider.RepositoryItemProviderAdapterFactory;
16import de.uka.ipd.sdq.pcm.seff.provider.SeffItemProviderAdapterFactory;
17 
18 
19/**
20 * @author Snowball
21 * An Label Provider (see the EMF bible for details on LabelProvider) for the labels of the heading
22 * of any single tab sheet.
23 * This label provider mostly delegates the calls to it to the generated
24 * LabelProvider in the PCM.Edit plugin.
25 */
26public class PropertyLabelProvider 
27extends LabelProvider 
28implements
29                ILabelProvider {
30 
31        private ComposedAdapterFactory adapterFactory;
32 
33        private AdapterFactoryLabelProvider labelProvider = null;
34 
35        /**
36         * Constructor. Sets up a LabelProvider by using an adapter factory
37         * provided by the generated PCM.Edit plugin
38         */
39        public PropertyLabelProvider() {
40                super();
41                adapterFactory = new ComposedAdapterFactory();
42                adapterFactory
43                        .addAdapterFactory(new ResourceItemProviderAdapterFactory());
44                adapterFactory
45                        .addAdapterFactory(new RepositoryItemProviderAdapterFactory());
46                adapterFactory
47                        .addAdapterFactory(new SeffItemProviderAdapterFactory());
48                adapterFactory
49                                .addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
50                labelProvider = new AdapterFactoryLabelProvider(adapterFactory)
51                {
52 
53                        /* (non-Javadoc)
54                         * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider#notifyChanged(org.eclipse.emf.common.notify.Notification)
55                         */
56                        @Override
57                        public void notifyChanged(Notification notification) {
58                                super.notifyChanged(notification);
59                                fireLabelProviderChanged();
60                        }
61 
62                };
63 
64        }
65 
66        /* (non-Javadoc)
67         * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
68         * GetImage is delegated to the PCM.Edit label provider
69         */
70        @Override
71        public Image getImage(Object element) {
72                if (element instanceof IStructuredSelection) {
73                        IStructuredSelection selection = (IStructuredSelection) element;
74                        if (selection.getFirstElement() instanceof EObject) {
75                                EObject selectedObject = (EObject) selection.getFirstElement();
76                                return labelProvider.getImage(selectedObject);
77                        }
78                }
79                return super.getImage(element);
80        }
81 
82        /* (non-Javadoc)
83         * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
84         * GetText delegated to the PCM.Edit LabelProvider. If the object is an
85         * entity we change the label to include the UUID of the object
86         */
87        @Override
88        public String getText(Object element) {
89                if (element instanceof IStructuredSelection) {
90                        IStructuredSelection selection = (IStructuredSelection) element;
91                        if (selection.getFirstElement() instanceof EObject) {
92                                EObject selectedObject = (EObject) selection.getFirstElement();
93                                String result = labelProvider.getText(selectedObject); 
94                                if (selectedObject instanceof Entity)
95                                {
96                                        Entity e = (Entity)selectedObject;
97                                        result = e.getEntityName() + " [ID: " + e.getId() +"]";
98                                }
99                                return result;
100                        }
101                }
102                return super.getText(element);
103        }
104 
105        @Override
106        public void dispose() {
107                labelProvider.dispose();
108        }
109 
110        /* (non-Javadoc)
111         * @see org.eclipse.jface.viewers.LabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
112         */
113        @Override
114        public void addListener(ILabelProviderListener listener) {
115                super.addListener(listener);
116                labelProvider.addListener(listener);
117        }
118 
119        /* (non-Javadoc)
120         * @see org.eclipse.jface.viewers.LabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
121         */
122        @Override
123        public void removeListener(ILabelProviderListener listener) {
124                labelProvider.removeListener(listener);
125                super.removeListener(listener);
126        }
127        
128}

[all classes][de.uka.ipd.sdq.pcmbench.tabs]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov