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

COVERAGE SUMMARY FOR SOURCE FILE [VariableUsageLabelProvider.java]

nameclass, %method, %block, %line, %
VariableUsageLabelProvider.java0%   (0/1)0%   (0/6)0%   (0/153)0%   (0/40)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VariableUsageLabelProvider0%   (0/1)0%   (0/6)0%   (0/153)0%   (0/40)
VariableUsageLabelProvider (AdapterFactory): void 0%   (0/1)0%   (0/4)0%   (0/2)
getImage (Object): Object 0%   (0/1)0%   (0/26)0%   (0/7)
getNameDataType (DataType): String 0%   (0/1)0%   (0/8)0%   (0/3)
getText (Object): String 0%   (0/1)0%   (0/101)0%   (0/24)
getTreeDeclarationObject (Object): InnerDeclaration 0%   (0/1)0%   (0/7)0%   (0/2)
getTreeTypeObject (Object): DataType 0%   (0/1)0%   (0/7)0%   (0/2)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.pcm.dialogs.variableusage;
5 
6import org.eclipse.emf.common.notify.AdapterFactory;
7import org.eclipse.emf.edit.provider.IItemLabelProvider;
8import org.eclipse.emf.edit.provider.ItemProviderDecorator;
9 
10import de.uka.ipd.sdq.pcm.dialogs.datatype.DataTypeContainer;
11import de.uka.ipd.sdq.pcm.dialogs.datatype.InnerDeclarationContainer;
12import de.uka.ipd.sdq.pcm.repository.CollectionDataType;
13import de.uka.ipd.sdq.pcm.repository.CompositeDataType;
14import de.uka.ipd.sdq.pcm.repository.DataType;
15import de.uka.ipd.sdq.pcm.repository.InnerDeclaration;
16import de.uka.ipd.sdq.pcm.repository.Parameter;
17import de.uka.ipd.sdq.pcm.repository.PrimitiveDataType;
18 
19/**
20 * @author admin
21 *
22 */
23public class VariableUsageLabelProvider extends ItemProviderDecorator implements
24 IItemLabelProvider {
25 
26        public VariableUsageLabelProvider(AdapterFactory adapterFactory) {
27                super(adapterFactory);
28        }
29 
30        @Override
31        public Object getImage(Object object) {
32                
33                if (object instanceof DataTypeContainer) {
34                        DataTypeContainer treeType = (DataTypeContainer) object;
35                        return super.getImage(treeType.getObject());
36                }
37                
38                if (object instanceof InnerDeclarationContainer) {
39                        InnerDeclarationContainer treeDeclaration = (InnerDeclarationContainer) object;
40                        return super.getImage(treeDeclaration.getObject());
41                }
42 
43                return super.getImage(object);
44        }
45 
46        /* (non-Javadoc)
47         * @see org.eclipse.emf.edit.provider.ItemProviderDecorator#getText(java.lang.Object)
48         */
49        @Override
50        public String getText(Object object) {
51                
52                if (object instanceof Parameter) {
53                        Parameter p = (Parameter) object;
54                        String result = p.getParameterName();
55                        if (p.getDataType__Parameter() != null) {
56                                result += ": " + super.getText(p.getDataType__Parameter());
57                        }
58                        return result;
59                }
60                
61                if (object instanceof DataTypeContainer) {
62                        DataType dataType = getTreeTypeObject(object);
63                        return "INNER: " + getNameDataType(dataType);
64                }
65                
66                if (object instanceof InnerDeclarationContainer) {
67                        InnerDeclaration declaration = getTreeDeclarationObject(object);
68                        DataType dataType = declaration.getDatatype_InnerDeclaration();
69                        
70                        String typeName = "";
71 
72                        if (dataType instanceof CollectionDataType) {
73                                CollectionDataType collType = (CollectionDataType) dataType;
74                                typeName = collType.getEntityName();
75                        }
76                        if (dataType instanceof CompositeDataType) {
77                                CompositeDataType compType = (CompositeDataType) dataType;
78                                typeName = compType.getEntityName();
79                        }
80                        if (dataType instanceof PrimitiveDataType) {
81                                PrimitiveDataType primType = (PrimitiveDataType) dataType;
82                                typeName = primType.getType().getName();
83                        }
84                        
85                        return declaration.getEntityName() + ": " + typeName;
86                }
87                return super.getText(object);
88        }
89 
90        /**
91         * @return - return the DdataType from TreeType-Object
92         */
93        private DataType getTreeTypeObject(Object object){
94                DataTypeContainer treeType = (DataTypeContainer)object;
95                return (DataType) treeType.getObject();
96        }
97        
98        /**
99         * @return - return the InnerDeclaration from TreeDeclaration-Object
100         */
101        private InnerDeclaration getTreeDeclarationObject(Object object) {
102                InnerDeclarationContainer treeDeclaration = (InnerDeclarationContainer) object;
103                return (InnerDeclaration) treeDeclaration.getObject();
104        }
105        
106        private String getNameDataType(DataType dataType) {
107                if (dataType != null)
108                        return super.getText(dataType);
109                return "null";
110        }
111}

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