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

COVERAGE SUMMARY FOR SOURCE FILE [ProbeSpecRepositoryItemProvider.java]

nameclass, %method, %block, %line, %
ProbeSpecRepositoryItemProvider.java0%   (0/1)0%   (0/13)0%   (0/330)0%   (0/91)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ProbeSpecRepositoryItemProvider0%   (0/1)0%   (0/13)0%   (0/330)0%   (0/91)
ProbeSpecRepositoryItemProvider (AdapterFactory): void 0%   (0/1)0%   (0/4)0%   (0/2)
collectNewChildDescriptors (Collection, Object): void 0%   (0/1)0%   (0/77)0%   (0/38)
getChildFeature (Object, Object): EStructuralFeature 0%   (0/1)0%   (0/5)0%   (0/1)
getChildrenFeatures (Object): Collection 0%   (0/1)0%   (0/15)0%   (0/4)
getImage (Object): Object 0%   (0/1)0%   (0/8)0%   (0/1)
getNumberOfInvalidCalculators (ProbeSpecRepository): int 0%   (0/1)0%   (0/63)0%   (0/13)
getPropertyDescriptors (Object): List 0%   (0/1)0%   (0/10)0%   (0/3)
getResourceLocator (): ResourceLocator 0%   (0/1)0%   (0/2)0%   (0/1)
getText (Object): String 0%   (0/1)0%   (0/82)0%   (0/12)
isValid (BinaryCalculator): boolean 0%   (0/1)0%   (0/29)0%   (0/6)
isValid (Calculator): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
isValid (UnaryCalculator): boolean 0%   (0/1)0%   (0/11)0%   (0/3)
notifyChanged (Notification): void 0%   (0/1)0%   (0/22)0%   (0/6)

1/**
2 * <copyright>
3 * </copyright>
4 *
5 * $Id$
6 */
7package de.uka.ipd.sdq.probespec.provider;
8 
9 
10import java.util.Collection;
11import java.util.List;
12 
13import org.eclipse.emf.common.notify.AdapterFactory;
14import org.eclipse.emf.common.notify.Notification;
15import org.eclipse.emf.common.util.ResourceLocator;
16import org.eclipse.emf.ecore.EStructuralFeature;
17import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
18import org.eclipse.emf.edit.provider.IItemLabelProvider;
19import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
20import org.eclipse.emf.edit.provider.IItemPropertySource;
21import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
22import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
23import org.eclipse.emf.edit.provider.ItemProviderAdapter;
24import org.eclipse.emf.edit.provider.ViewerNotification;
25 
26import de.uka.ipd.sdq.probespec.BinaryCalculator;
27import de.uka.ipd.sdq.probespec.Calculator;
28import de.uka.ipd.sdq.probespec.ProbeSpecRepository;
29import de.uka.ipd.sdq.probespec.UnaryCalculator;
30import de.uka.ipd.sdq.probespec.probespecFactory;
31import de.uka.ipd.sdq.probespec.probespecPackage;
32 
33/**
34 * This is the item provider adapter for a {@link de.uka.ipd.sdq.probespec.ProbeSpecRepository} object.
35 * <!-- begin-user-doc -->
36 * <!-- end-user-doc -->
37 * @generated
38 */
39public class ProbeSpecRepositoryItemProvider
40        extends ItemProviderAdapter
41        implements
42                IEditingDomainItemProvider,
43                IStructuredItemContentProvider,
44                ITreeItemContentProvider,
45                IItemLabelProvider,
46                IItemPropertySource {
47        /**
48         * This constructs an instance from a factory and a notifier.
49         * <!-- begin-user-doc -->
50         * <!-- end-user-doc -->
51         * @generated
52         */
53        public ProbeSpecRepositoryItemProvider(AdapterFactory adapterFactory) {
54                super(adapterFactory);
55        }
56 
57        /**
58         * This returns the property descriptors for the adapted class.
59         * <!-- begin-user-doc -->
60         * <!-- end-user-doc -->
61         * @generated
62         */
63        @Override
64        public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
65                if (itemPropertyDescriptors == null) {
66                        super.getPropertyDescriptors(object);
67 
68                }
69                return itemPropertyDescriptors;
70        }
71 
72        /**
73         * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
74         * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
75         * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
76         * <!-- begin-user-doc -->
77         * <!-- end-user-doc -->
78         * @generated
79         */
80        @Override
81        public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
82                if (childrenFeatures == null) {
83                        super.getChildrenFeatures(object);
84                        childrenFeatures.add(probespecPackage.Literals.PROBE_SPEC_REPOSITORY__CALCULATOR);
85                }
86                return childrenFeatures;
87        }
88 
89        /**
90         * <!-- begin-user-doc -->
91         * <!-- end-user-doc -->
92         * @generated
93         */
94        @Override
95        protected EStructuralFeature getChildFeature(Object object, Object child) {
96                // Check the type of the specified child object and return the proper feature to use for
97                // adding (see {@link AddCommand}) it as a child.
98 
99                return super.getChildFeature(object, child);
100        }
101 
102        /**
103         * This returns ProbeSpecRepository.gif.
104         * <!-- begin-user-doc -->
105         * <!-- end-user-doc -->
106         * @generated
107         */
108        @Override
109        public Object getImage(Object object) {
110                return overlayImage(object, getResourceLocator().getImage("full/obj16/ProbeSpecRepository"));
111        }
112 
113        /**
114         * This returns the label text for the adapted class.
115         * <!-- begin-user-doc -->
116         * <!-- end-user-doc -->
117         * @generated not
118         */
119        @Override
120        public String getText(Object object) {
121                //return getString("_UI_ProbeSpecRepository_type");
122                ProbeSpecRepository probeSpecRepository = (ProbeSpecRepository)object;
123                String label = "Sensor Repository";
124                if ((probeSpecRepository.getCalculator() == null) || (probeSpecRepository.getCalculator().size() == 0)) {
125                        label = label + " (no sensors specified)";
126                } else {
127                        if (probeSpecRepository.getCalculator().size() == 1) {
128                                label = label + " (1 sensor specified";
129                        } else {
130                                label = label + " (" + probeSpecRepository.getCalculator().size() + " sensors specified";
131                        }
132                        int numberOfInvalidSensors = getNumberOfInvalidCalculators(probeSpecRepository);
133                        if (numberOfInvalidSensors > 0) {
134                                label = label + ", " + numberOfInvalidSensors + " invalid";
135                        }
136                        label = label + ")";
137                }
138                return label;
139        }
140        
141        private int getNumberOfInvalidCalculators(ProbeSpecRepository probeSpecRepository) {
142                int result = 0;
143                if ((probeSpecRepository.getCalculator() == null) || (probeSpecRepository.getCalculator().size() == 0)) {
144                        return result;
145                }
146                for (int i=0; i<probeSpecRepository.getCalculator().size(); i++) {
147                        if (probeSpecRepository.getCalculator().get(i) instanceof BinaryCalculator) {
148                                if (!isValid((BinaryCalculator)probeSpecRepository.getCalculator().get(i))) {
149                                        result++;
150                                }
151                        } else if (probeSpecRepository.getCalculator().get(i) instanceof UnaryCalculator) {
152                                if (!isValid((UnaryCalculator)probeSpecRepository.getCalculator().get(i))) {
153                                        result++;
154                                }
155                        } else {
156                                if (!isValid(probeSpecRepository.getCalculator().get(i))) {
157                                        result++;
158                                }
159                        }
160                }
161                return result;
162        }
163        
164        private boolean isValid(BinaryCalculator calculator) {
165                if ((calculator.getProbeSet() == null) || (calculator.getProbeSet().size() == 0)) { 
166                        return false;
167                }
168                for (int i=0; i<calculator.getProbeSet().size(); i++) {
169                        if (calculator.getProbeSet().get(i).getAnnotatedElement() == null) {
170                                return false;
171                        }
172                }
173                return true;
174        }
175        
176        private boolean isValid(UnaryCalculator calculator) {
177                if ((calculator.getProbeSet() == null) || (calculator.getProbeSet().getAnnotatedElement() == null)) {
178                        return false;
179                }
180                return true;
181        }
182        
183        private boolean isValid(Calculator calculator) {
184                return false;
185        }
186 
187        /**
188         * This handles model notifications by calling {@link #updateChildren} to update any cached
189         * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
190         * <!-- begin-user-doc -->
191         * <!-- end-user-doc -->
192         * @generated
193         */
194        @Override
195        public void notifyChanged(Notification notification) {
196                updateChildren(notification);
197 
198                switch (notification.getFeatureID(ProbeSpecRepository.class)) {
199                        case probespecPackage.PROBE_SPEC_REPOSITORY__CALCULATOR:
200                                fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
201                                return;
202                }
203                super.notifyChanged(notification);
204        }
205 
206        /**
207         * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
208         * that can be created under this object.
209         * <!-- begin-user-doc -->
210         * <!-- end-user-doc -->
211         * @generated
212         */
213        @Override
214        protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
215                super.collectNewChildDescriptors(newChildDescriptors, object);
216 
217                newChildDescriptors.add
218                        (createChildParameter
219                                (probespecPackage.Literals.PROBE_SPEC_REPOSITORY__CALCULATOR,
220                                 probespecFactory.eINSTANCE.createPassiveResourceCalculator()));
221 
222                newChildDescriptors.add
223                        (createChildParameter
224                                (probespecPackage.Literals.PROBE_SPEC_REPOSITORY__CALCULATOR,
225                                 probespecFactory.eINSTANCE.createStoExCalculator()));
226 
227                newChildDescriptors.add
228                        (createChildParameter
229                                (probespecPackage.Literals.PROBE_SPEC_REPOSITORY__CALCULATOR,
230                                 probespecFactory.eINSTANCE.createSEFFParameterCalculator()));
231 
232                newChildDescriptors.add
233                        (createChildParameter
234                                (probespecPackage.Literals.PROBE_SPEC_REPOSITORY__CALCULATOR,
235                                 probespecFactory.eINSTANCE.createResponseTimeCalculator()));
236 
237                newChildDescriptors.add
238                        (createChildParameter
239                                (probespecPackage.Literals.PROBE_SPEC_REPOSITORY__CALCULATOR,
240                                 probespecFactory.eINSTANCE.createWaitingTimeCalculator()));
241 
242                newChildDescriptors.add
243                        (createChildParameter
244                                (probespecPackage.Literals.PROBE_SPEC_REPOSITORY__CALCULATOR,
245                                 probespecFactory.eINSTANCE.createHDDStateCalculator()));
246 
247                newChildDescriptors.add
248                        (createChildParameter
249                                (probespecPackage.Literals.PROBE_SPEC_REPOSITORY__CALCULATOR,
250                                 probespecFactory.eINSTANCE.createCPUStateCalculator()));
251 
252                newChildDescriptors.add
253                        (createChildParameter
254                                (probespecPackage.Literals.PROBE_SPEC_REPOSITORY__CALCULATOR,
255                                 probespecFactory.eINSTANCE.createCPUDemandCalculator()));
256 
257                newChildDescriptors.add
258                        (createChildParameter
259                                (probespecPackage.Literals.PROBE_SPEC_REPOSITORY__CALCULATOR,
260                                 probespecFactory.eINSTANCE.createHDDDemandCalculator()));
261        }
262 
263        /**
264         * Return the resource locator for this item provider's resources.
265         * <!-- begin-user-doc -->
266         * <!-- end-user-doc -->
267         * @generated
268         */
269        @Override
270        public ResourceLocator getResourceLocator() {
271                return ProbeSpecificationEditPlugin.INSTANCE;
272        }
273 
274}

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