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

nameclass, %method, %block, %line, %
VariableUsageContentProvider.java0%   (0/1)0%   (0/10)0%   (0/235)0%   (0/64)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VariableUsageContentProvider0%   (0/1)0%   (0/10)0%   (0/235)0%   (0/64)
VariableUsageContentProvider (): void 0%   (0/1)0%   (0/3)0%   (0/1)
dispose (): void 0%   (0/1)0%   (0/1)0%   (0/1)
getChildren (Object): Object [] 0%   (0/1)0%   (0/115)0%   (0/26)
getCompositeTypeElements (DataType, Object): Object [] 0%   (0/1)0%   (0/34)0%   (0/8)
getElements (Object): Object [] 0%   (0/1)0%   (0/9)0%   (0/3)
getParent (Object): Object 0%   (0/1)0%   (0/2)0%   (0/1)
getTreeDeclarationInner (Object): DataType 0%   (0/1)0%   (0/10)0%   (0/4)
getTreeTypeInner (Object): DataType 0%   (0/1)0%   (0/18)0%   (0/6)
hasChildren (Object): boolean 0%   (0/1)0%   (0/42)0%   (0/13)
inputChanged (Viewer, Object, Object): void 0%   (0/1)0%   (0/1)0%   (0/1)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.pcm.dialogs.variableusage;
5 
6import org.eclipse.emf.common.util.EList;
7import org.eclipse.jface.viewers.ITreeContentProvider;
8import org.eclipse.jface.viewers.Viewer;
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;
18import de.uka.ipd.sdq.pcm.repository.Signature;
19import de.uka.ipd.sdq.pcm.seff.ResourceDemandingSEFF;
20 
21/**
22 * @author admin
23 *
24 */
25public class VariableUsageContentProvider implements ITreeContentProvider {
26 
27        /* (non-Javadoc)
28         * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
29         */
30        public Object[] getElements(Object inputElement) {
31                if (inputElement instanceof Signature) {
32                        return getChildren(inputElement);
33                }
34                return null;
35        }
36 
37        /* (non-Javadoc)
38         * @see org.eclipse.jface.viewers.IContentProvider#dispose()
39         */
40        public void dispose() {
41                // TODO Auto-generated method stub
42        }
43 
44        /* (non-Javadoc)
45         * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
46         */
47        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
48                // TODO Auto-generated method stub
49        }
50 
51        /* (non-Javadoc)
52         * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
53         */
54        public Object[] getChildren(Object parent) {
55                /**
56                 * SEFF
57                 */
58                if (parent instanceof ResourceDemandingSEFF) {
59                        ResourceDemandingSEFF seff = (ResourceDemandingSEFF) parent;
60                        return new Object[] {seff.getDescribedService__SEFF()};
61                }
62                
63                /**
64                 * Parameter
65                 */
66                if (parent instanceof Parameter) {
67                        Parameter parameter = (Parameter) parent;
68                        DataType dataType = (DataType) parameter.getDataType__Parameter();
69                        
70                        if (dataType instanceof CompositeDataType) {
71                                return getCompositeTypeElements(dataType, parameter);
72                        }
73                        else if (dataType instanceof CollectionDataType) {
74                                return new Object[] {new DataTypeContainer(((CollectionDataType)dataType).getInnerType_CollectionDataType(),parent)};
75                        }
76                        else
77                                return new Object[]{};
78                }
79                
80                /**
81                 * TreeType
82                 */
83                if (parent instanceof DataTypeContainer) {
84                        DataType innerType = getTreeTypeInner(parent);
85                        
86                        if (innerType instanceof PrimitiveDataType)
87                                return new Object[0];
88                        
89                        if (innerType instanceof CompositeDataType)
90                                return getCompositeTypeElements(innerType,parent);
91                        
92                        return new Object[] { new DataTypeContainer(innerType,parent) };
93                }
94                
95                /**
96                 * TreeDeclaration
97                 */
98                if (parent instanceof InnerDeclarationContainer) {
99                        DataType innerType = getTreeDeclarationInner(parent);
100 
101                        if (innerType instanceof CompositeDataType) {
102                                return getCompositeTypeElements(innerType, parent);
103                        }
104 
105                        CollectionDataType collDataType = (CollectionDataType) innerType;
106                        return new Object[] { new DataTypeContainer(collDataType
107                                        .getInnerType_CollectionDataType(),parent) };
108                }
109 
110                return new Object[0];
111        }
112 
113        /**
114         * @return - return the DataType from InnerDeclaration of
115         *         TreeDeclaration-Object
116         */
117        private DataType getTreeDeclarationInner(Object parent) {
118                InnerDeclarationContainer treeDeclaration = (InnerDeclarationContainer) parent;
119                InnerDeclaration declaration = (InnerDeclaration) treeDeclaration
120                                .getObject();
121                return declaration.getDatatype_InnerDeclaration();
122        }
123 
124        /**
125         * @return - return the DataType from inner collection datatype of
126         *         TreeType-Object
127         */
128        private DataType getTreeTypeInner(Object parent) {
129                DataTypeContainer treeType = (DataTypeContainer) parent;
130                DataType dataType = (DataType) treeType.getObject();
131                
132                if (dataType instanceof PrimitiveDataType) {
133                        return dataType;
134                        
135                }
136                CollectionDataType collDataType = (CollectionDataType) dataType;
137                return collDataType.getInnerType_CollectionDataType();
138        }
139        
140        /**
141         * TODO
142         * 
143         * @return - array of TreeDeclaration from composite datatype
144         */
145        private Object[] getCompositeTypeElements(DataType dataType, Object parent) {
146                CompositeDataType compDataType = (CompositeDataType) dataType;
147                EList<InnerDeclaration> list = compDataType
148                                .getInnerDeclaration_CompositeDataType();
149                Object[] objects = new Object[list.size()];
150                
151                int i = 0;
152                
153                for (InnerDeclaration inner : list)
154                        objects[i++] = new InnerDeclarationContainer(inner, parent);
155                
156                return objects;
157        }
158 
159        /* (non-Javadoc)
160         * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
161         */
162        public Object getParent(Object element) {
163                // TODO Auto-generated method stub
164                return null;
165        }
166 
167        /* (non-Javadoc)
168         * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
169         */
170        public boolean hasChildren(Object element) {
171                
172                if (element instanceof Parameter) {
173                        Parameter parameter = (Parameter) element;
174                        DataType dataType = parameter.getDataType__Parameter();
175                        return hasChildren(dataType);
176                }
177                
178                if (element instanceof DataTypeContainer){
179                        DataType innerType = getTreeTypeInner(element);
180                        return hasChildren(innerType);
181                }
182                
183                if (element instanceof InnerDeclarationContainer){
184                        DataType dataType = getTreeDeclarationInner(element);
185                        return hasChildren(dataType);
186                }
187                
188                if (element instanceof PrimitiveDataType)
189                        return false;
190                
191                return true;
192        }
193}
194 
195 
196 
197 

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