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

COVERAGE SUMMARY FOR SOURCE FILE [CategoryAwareItemProvider.java]

nameclass, %method, %block, %line, %
CategoryAwareItemProvider.java0%   (0/1)0%   (0/4)0%   (0/113)0%   (0/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CategoryAwareItemProvider0%   (0/1)0%   (0/4)0%   (0/113)0%   (0/27)
CategoryAwareItemProvider (AdapterFactory, ICategoryDescriptions): void 0%   (0/1)0%   (0/12)0%   (0/4)
CategoryAwareItemProvider (CategoryAwareItemProviderAdapterFactory, ICategory... 0%   (0/1)0%   (0/12)0%   (0/4)
dispose (): void 0%   (0/1)0%   (0/25)0%   (0/5)
getChildren (Object): Collection 0%   (0/1)0%   (0/64)0%   (0/15)

1package de.uka.ipd.sdq.pcmbench.ui.provider.categoryaware;
2 
3 
4import java.util.ArrayList;
5import java.util.Collection;
6import java.util.HashMap;
7import java.util.Iterator;
8 
9import org.eclipse.emf.common.notify.AdapterFactory;
10import org.eclipse.emf.ecore.EObject;
11import org.eclipse.emf.edit.provider.IDisposable;
12import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
13import org.eclipse.emf.edit.provider.IItemLabelProvider;
14import org.eclipse.emf.edit.provider.IItemPropertySource;
15import org.eclipse.emf.edit.provider.IItemProviderDecorator;
16import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
17import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
18import org.eclipse.emf.edit.provider.ItemProviderDecorator;
19 
20/**
21 * @author Snowball
22 * This class implements an IItemProvider which is capable of inserting pseudo-
23 * nodes into the tree based view of its items. These pseudo nodes are used to 
24 * categorise the elements of the root nodes (e.g, Component->{Provided Roles, RequiredRoles, ...}.
25 * Categories are configurable using
26 * EMF Refelection and CategoryDescriptors. This class uses GenericCategoryItemProvider
27 * as child provider to actually render the pseudo nodes. It decorated the item provider
28 * of the model object which should be displayed using categories.
29 */
30public class CategoryAwareItemProvider extends ItemProviderDecorator
31                implements IEditingDomainItemProvider, IStructuredItemContentProvider,
32                ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource,
33                IItemProviderDecorator, IDisposable {
34 
35        /* (non-Javadoc)
36         * @see org.eclipse.emf.edit.provider.ItemProviderDecorator#dispose()
37         * Remember also to send the dispose() signal to our child item providers for the
38         * categories
39         */
40        @Override
41        public void dispose() {
42                for (Iterator<Collection> childCacheIterator = childCache.values().iterator(); childCacheIterator.hasNext(); )
43                {
44                        for(Iterator<GenericCategoryItemProvider> itemProviderIterator = childCacheIterator.next().iterator(); itemProviderIterator.hasNext();)
45                        {
46                                itemProviderIterator.next().dispose();
47                        }
48                }
49                super.dispose();
50        }
51 
52        private ICategoryDescriptions categories;
53 
54        private HashMap<EObject, Collection> childCache = new HashMap<EObject, Collection>();
55 
56        public CategoryAwareItemProvider(AdapterFactory adapterFactory,
57                        ICategoryDescriptions categories) {
58                super(adapterFactory);
59                this.categories = categories;
60        }
61 
62        public CategoryAwareItemProvider(
63                        CategoryAwareItemProviderAdapterFactory factory,
64                        ICategoryDescriptions categories) {
65                super(factory);
66                this.categories = categories;
67        }
68 
69        /*
70         * (non-Javadoc)
71         * 
72         * @see org.eclipse.emf.edit.provider.ItemProviderDecorator#getChildren(java.lang.Object)
73         * Get children return now pseudo item providers (GenericCategoryItemProvider) which only
74         * render the categories and contain themselfs the children of our node - sorted now by
75         * categories
76         */
77        @Override
78        public Collection getChildren(Object object) {
79                if (object instanceof EObject) {
80                        EObject eObject = (EObject) object;
81                        if (categories.hasCategoriesForObject(eObject)) {
82                                if (!childCache.containsKey(eObject)) {
83                                        ArrayList children = new ArrayList();
84                                        Collection<CategoryDescriptor> childDescriptors = categories
85                                                        .getCategoriesForObject(eObject);
86                                        for (Iterator<CategoryDescriptor> iterator = childDescriptors
87                                                        .iterator(); iterator.hasNext();) {
88                                                children.add(new GenericCategoryItemProvider(
89                                                                adapterFactory, iterator.next(), eObject));
90                                        }
91                                        childCache.put(eObject, children);
92                                }
93                                return childCache.get(eObject);
94                        }
95                        else
96                                return super.getChildren(object);
97                } else
98                        return super.getChildren(object);
99        }
100}

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