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

nameclass, %method, %block, %line, %
GenericCategoryItemProvider.java0%   (0/1)0%   (0/14)0%   (0/165)0%   (0/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GenericCategoryItemProvider0%   (0/1)0%   (0/14)0%   (0/165)0%   (0/34)
GenericCategoryItemProvider (AdapterFactory, CategoryDescriptor, EObject): void 0%   (0/1)0%   (0/12)0%   (0/4)
createCommand (Object, EditingDomain, Class, CommandParameter): Command 0%   (0/1)0%   (0/16)0%   (0/3)
dispose (): void 0%   (0/1)0%   (0/9)0%   (0/3)
getChildren (Object): Collection 0%   (0/1)0%   (0/5)0%   (0/1)
getChildrenReferences (Object): Collection 0%   (0/1)0%   (0/17)0%   (0/4)
getCreateChildDescription (Object, Object, Object, Collection): String 0%   (0/1)0%   (0/8)0%   (0/1)
getCreateChildImage (Object, Object, Object, Collection): Object 0%   (0/1)0%   (0/8)0%   (0/1)
getCreateChildResult (Object): Collection 0%   (0/1)0%   (0/4)0%   (0/1)
getCreateChildText (Object, Object, Object, Collection): String 0%   (0/1)0%   (0/8)0%   (0/1)
getCreateChildToolTipText (Object, Object, Object, Collection): String 0%   (0/1)0%   (0/8)0%   (0/1)
getNewChildDescriptors (Object, EditingDomain, Object): Collection 0%   (0/1)0%   (0/45)0%   (0/9)
getParent (Object): Object 0%   (0/1)0%   (0/3)0%   (0/1)
getText (Object): String 0%   (0/1)0%   (0/4)0%   (0/1)
notifyChanged (Notification): void 0%   (0/1)0%   (0/18)0%   (0/3)

1package de.uka.ipd.sdq.pcmbench.ui.provider.categoryaware;
2 
3 
4import java.util.ArrayList;
5import java.util.Collection;
6import java.util.Iterator;
7 
8import org.eclipse.emf.common.command.Command;
9import org.eclipse.emf.common.notify.Adapter;
10import org.eclipse.emf.common.notify.AdapterFactory;
11import org.eclipse.emf.common.notify.Notification;
12import org.eclipse.emf.common.notify.NotificationWrapper;
13import org.eclipse.emf.ecore.EObject;
14import org.eclipse.emf.edit.command.CommandParameter;
15import org.eclipse.emf.edit.domain.EditingDomain;
16import org.eclipse.emf.edit.provider.IDisposable;
17import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
18import org.eclipse.emf.edit.provider.IItemLabelProvider;
19import org.eclipse.emf.edit.provider.IItemPropertySource;
20import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
21import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
22import org.eclipse.emf.edit.provider.ItemProviderAdapter;
23 
24/**
25 * @author Snowball
26 * Pseudo item provider for category displays - No EMF Model Element is associated to this type of item provider.
27 * The idea is to insert item providers into the tree of model objects which are
28 * actually not associated to model objects and are only used for display/GUI
29 * reasons. Those providers filter the children of their parent node according
30 * to their category. The idea is inspired by the EMF bible, chapter 14, where
31 * a similar approach is presented. The class is partially generated by using
32 * "Generate delegator" on the type ItemProviderAdapter. Note that most calls are delegated
33 * to our parent node, as this is the "real" model object and not a pseudo node as we are....
34 *
35 */
36public class GenericCategoryItemProvider extends ItemProviderAdapter
37implements         IEditingDomainItemProvider,
38        IStructuredItemContentProvider,
39        ITreeItemContentProvider,
40        IItemLabelProvider,
41        IItemPropertySource,
42        IDisposable,
43        Adapter
44{
45        private CategoryDescriptor descriptor;
46        
47        /**
48         * Default constructor
49         * @param adapterFactory The adapter factory which can be used to generate ItemProviders
50         * for child elements, labels, ...
51         * @param descriptor A category descriptor characterising the filter which is used to
52         * select the child elements of the parent
53         * @param parentObject The parent (model) object whose children should be displayed using
54         * several categories
55         */
56        public GenericCategoryItemProvider(AdapterFactory adapterFactory, CategoryDescriptor descriptor, EObject parentObject) {
57                super(adapterFactory);
58                parentObject.eAdapters().add(this);
59                this.descriptor = descriptor;
60        }
61 
62        /* (non-Javadoc)
63         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getChildren(java.lang.Object)
64         * Delegate this call to our parent object, which works because the parent calls
65         * getChildReferences() to actually retrieve the children. See EMF.Edit documentation or 
66         * the EMF bible for the sequence of calls...
67         */
68        public Collection getChildren(Object object)
69        {
70                return super.getChildren(target);
71        }
72        
73        /* (non-Javadoc)
74         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getParent(java.lang.Object)
75         * The parent of all category items is the parent model element
76         */
77        public Object getParent(Object object)
78        {
79                return target;
80        }
81 
82        /* (non-Javadoc)
83         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getChildrenReferences(java.lang.Object)
84         * The only children to be displayed are those which fit to the eReference (category) given
85         * in its category desriptor
86         */
87        @Override
88        protected Collection getChildrenReferences(Object object) {
89                if (childrenReferences == null)
90                {
91                        super.getChildrenReferences(object);
92                        childrenReferences.add(descriptor.getEReference());
93                }
94                return childrenReferences;
95        }
96 
97        /* (non-Javadoc)
98         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getText(java.lang.Object)
99         * Get the label from the decriptor object
100         */
101        public String getText(Object object)
102        {
103                return descriptor.getLabel();
104        }
105        
106        /* (non-Javadoc)
107         * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
108         * We are only concerned with notifications which affect our category, filter out all others
109         */
110        public void notifyChanged(Notification notification)
111        {
112                if (notification.getFeatureID(descriptor.getParentClass()) == descriptor.getEReference().getFeatureID()){
113                        fireNotifyChanged(new NotificationWrapper(this,notification));
114                }
115        }
116        
117        /* (non-Javadoc)
118         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#dispose()
119         */
120        @Override
121        public void dispose() {
122                target.eAdapters().remove(this);
123                super.dispose();
124        }
125 
126        /* (non-Javadoc)
127         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getNewChildDescriptors(java.lang.Object, org.eclipse.emf.edit.domain.EditingDomain, java.lang.Object)
128         * Filter the child descriptors of our parent node in a way that only those decriptors
129         * matching our category are left over
130         */
131        @Override
132        public Collection getNewChildDescriptors(Object object, EditingDomain editingDomain, Object sibling) {
133                IEditingDomainItemProvider itemProvider = 
134                        (IEditingDomainItemProvider)adapterFactory.adapt((Object)target, IEditingDomainItemProvider.class);
135                Collection children = itemProvider.getNewChildDescriptors(target, editingDomain, sibling);
136                ArrayList result = new ArrayList();
137                for (Iterator i=children.iterator(); i.hasNext(); )
138                {
139                        CommandParameter p = (CommandParameter)i.next();
140                        if (p.getEReference() != null && p.getEReference() == descriptor.getEReference())
141                        {
142                                result.add(p);
143                        }
144                }
145                return result;
146        }
147 
148        /* (non-Javadoc)
149         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getCreateChildDescription(java.lang.Object, java.lang.Object, java.lang.Object, java.util.Collection)
150         */
151        @Override
152        public String getCreateChildDescription(Object owner, Object feature, Object child, Collection selection) {
153                // TODO Auto-generated method stub
154                return super.getCreateChildDescription(target, feature, child, selection);
155        }
156 
157        /* (non-Javadoc)
158         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getCreateChildImage(java.lang.Object, java.lang.Object, java.lang.Object, java.util.Collection)
159         */
160        @Override
161        public Object getCreateChildImage(Object owner, Object feature, Object child, Collection selection) {
162                // TODO Auto-generated method stub
163                return super.getCreateChildImage(target, feature, child, selection);
164        }
165 
166        /* (non-Javadoc)
167         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getCreateChildResult(java.lang.Object)
168         */
169        @Override
170        public Collection getCreateChildResult(Object child) {
171                // TODO Auto-generated method stub
172                return super.getCreateChildResult(child);
173        }
174 
175        /* (non-Javadoc)
176         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getCreateChildText(java.lang.Object, java.lang.Object, java.lang.Object, java.util.Collection)
177         */
178        @Override
179        public String getCreateChildText(Object owner, Object feature, Object child, Collection selection) {
180                // TODO Auto-generated method stub
181                return super.getCreateChildText(target, feature, child, selection);
182        }
183 
184        /* (non-Javadoc)
185         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getCreateChildToolTipText(java.lang.Object, java.lang.Object, java.lang.Object, java.util.Collection)
186         */
187        @Override
188        public String getCreateChildToolTipText(Object owner, Object feature, Object child, Collection selection) {
189                // TODO Auto-generated method stub
190                return super.getCreateChildToolTipText(target, feature, child, selection);
191        }
192 
193        /* (non-Javadoc)
194         * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#createCommand(java.lang.Object, org.eclipse.emf.edit.domain.EditingDomain, java.lang.Class, org.eclipse.emf.edit.command.CommandParameter)
195         */
196        @Override
197        public Command createCommand(Object object, EditingDomain domain, Class commandClass, CommandParameter commandParameter) {
198                IEditingDomainItemProvider itemProvider = 
199                        (IEditingDomainItemProvider)adapterFactory.adapt((Object)target, IEditingDomainItemProvider.class);
200                return itemProvider.createCommand(target, domain, commandClass, commandParameter);
201        }
202}

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