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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioSelectEObjectDialog.java]

nameclass, %method, %block, %line, %
PalladioSelectEObjectDialog.java0%   (0/1)0%   (0/7)0%   (0/234)0%   (0/77)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioSelectEObjectDialog0%   (0/1)0%   (0/7)0%   (0/234)0%   (0/77)
PalladioSelectEObjectDialog (Shell, Collection, Collection, Object): void 0%   (0/1)0%   (0/108)0%   (0/39)
PalladioSelectEObjectDialog (Shell, Collection, Object): void 0%   (0/1)0%   (0/9)0%   (0/2)
addModelToResourceSet (Shell, String): void 0%   (0/1)0%   (0/23)0%   (0/8)
correctionResourceRepositoryName (String): String 0%   (0/1)0%   (0/8)0%   (0/3)
getResourceSet (Object): ResourceSet 0%   (0/1)0%   (0/20)0%   (0/8)
getViewerRootElement (): Object 0%   (0/1)0%   (0/15)0%   (0/4)
setInputDialogResourceName (Collection): void 0%   (0/1)0%   (0/51)0%   (0/13)

1package de.uka.ipd.sdq.pcm.dialogs.selection;
2 
3import java.util.ArrayList;
4import java.util.Collection;
5 
6import org.eclipse.emf.common.util.URI;
7import org.eclipse.emf.ecore.EObject;
8import org.eclipse.emf.ecore.EReference;
9import org.eclipse.emf.ecore.resource.ResourceSet;
10import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
11import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
12import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
13import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
14import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
15import org.eclipse.emf.transaction.TransactionalEditingDomain;
16import org.eclipse.emf.transaction.util.TransactionUtil;
17import org.eclipse.jface.dialogs.MessageDialog;
18import org.eclipse.swt.widgets.Shell;
19 
20import de.uka.ipd.sdq.dialogs.selection.FilteredItemsAdapterFactory;
21import de.uka.ipd.sdq.dialogs.selection.SelectEObjectDialog;
22import de.uka.ipd.sdq.pcm.allocation.provider.AllocationItemProviderAdapterFactory;
23import de.uka.ipd.sdq.pcm.core.composition.provider.CompositionItemProviderAdapterFactory;
24import de.uka.ipd.sdq.pcm.core.provider.CoreItemProviderAdapterFactory;
25import de.uka.ipd.sdq.pcm.parameter.provider.ParameterItemProviderAdapterFactory;
26import de.uka.ipd.sdq.pcm.repository.provider.RepositoryItemProviderAdapterFactory;
27import de.uka.ipd.sdq.pcm.resourceenvironment.provider.ResourceenvironmentItemProviderAdapterFactory;
28import de.uka.ipd.sdq.pcm.resourcetype.provider.ResourcetypeItemProviderAdapterFactory;
29import de.uka.ipd.sdq.pcm.seff.provider.SeffItemProviderAdapterFactory;
30import de.uka.ipd.sdq.pcm.system.provider.SystemItemProviderAdapterFactory;
31import de.uka.ipd.sdq.pcm.subsystem.provider.SubsystemItemProviderAdapterFactory;
32import de.uka.ipd.sdq.pcm.usagemodel.provider.UsagemodelItemProviderAdapterFactory;
33import de.uka.ipd.sdq.pcmbench.ui.provider.PalladioItemProviderAdapterFactory;
34 
35/**
36 * @author Snowball
37 *
38 */
39public class PalladioSelectEObjectDialog extends SelectEObjectDialog {
40        
41        private Object input;
42        private AdapterFactoryContentProvider contentProvider;
43        
44        /**
45         * Creates a selection dialog
46         * @param parent Shell of active workbench window
47         * @param filterList Objects to show (positive filter). Also include respective super types here
48         * @param additionalChildReferences Usually this should be the EReference which should be set
49         * @param input ResourceSet or object of which resource set should be taken
50         */
51        public PalladioSelectEObjectDialog(Shell parent,
52                        Collection<Object> filterList,
53                        Collection<EReference> additionalChildReferences, Object input) {
54                super(parent);
55                this.input = input;
56                create();
57                ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory();
58                adapterFactory
59                                .addAdapterFactory(new ResourceItemProviderAdapterFactory());
60                adapterFactory
61                        .addAdapterFactory(new RepositoryItemProviderAdapterFactory());
62                adapterFactory
63                        .addAdapterFactory(new SeffItemProviderAdapterFactory());
64                adapterFactory
65                        .addAdapterFactory(new SystemItemProviderAdapterFactory());
66                adapterFactory
67                        .addAdapterFactory(new AllocationItemProviderAdapterFactory());
68                adapterFactory
69                        .addAdapterFactory(new UsagemodelItemProviderAdapterFactory());
70                adapterFactory
71                        .addAdapterFactory(new ResourceenvironmentItemProviderAdapterFactory());
72                adapterFactory
73                        .addAdapterFactory(new ParameterItemProviderAdapterFactory());
74                adapterFactory
75                        .addAdapterFactory(new ResourcetypeItemProviderAdapterFactory());
76                adapterFactory
77                        .addAdapterFactory(new CoreItemProviderAdapterFactory());
78                adapterFactory
79                        .addAdapterFactory(new CompositionItemProviderAdapterFactory());
80                adapterFactory
81                        .addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
82                adapterFactory
83                        .addAdapterFactory(new SubsystemItemProviderAdapterFactory());
84 
85                contentProvider = new AdapterFactoryContentProvider(
86                                new FilteredItemsAdapterFactory(adapterFactory, filterList,
87                                                additionalChildReferences));
88                setViewerContentProvider(contentProvider);
89                
90                setViewerLabelProvider(new AdapterFactoryLabelProvider(
91                                new PalladioItemProviderAdapterFactory(adapterFactory)));
92                setViewerInput(input);
93                setInputDialogResourceName(filterList);
94        }
95 
96        public PalladioSelectEObjectDialog(Shell parent,
97                        Collection<Object> filterList, Object input) {
98                this(parent,filterList,new ArrayList<EReference>(),input);
99        }
100        
101        /* (non-Javadoc)
102         * @see de.uka.ipd.sdq.dialogs.selection.SelectEObjectDialog#setResourceName(java.util.Collection)
103         */
104        @Override
105        protected void setInputDialogResourceName(Collection<Object> filterList) {
106                String system = "System";
107                String repository = "Repository";
108                String resourceRepository = "ResourceRepository";
109 
110                ArrayList<Object> list = new ArrayList<Object>();
111                list.addAll(filterList);
112 
113                if (!list.isEmpty()) {
114                        for (Object object : list) {
115                                Class<?> clazz = (Class<?>) object;
116                                String name = clazz.getSimpleName();
117                                if (name.equals(system) || name.equals(repository)
118                                                || name.equals(resourceRepository))
119                                        setResourceName(correctionResourceRepositoryName(name));
120                        }
121                }
122        }
123        
124        /** Correction the ResourceRepository to ResourceType */
125        private String correctionResourceRepositoryName(String name){
126                if (name.equals("ResourceRepository"))
127                        return "ResourceType";
128                return name;
129        }
130        
131 
132        /* (non-Javadoc)
133         * @see de.uka.ipd.sdq.dialogs.selection.SelectEObjectDialog#addResourceToEditingDomain(org.eclipse.swt.widgets.Shell, java.lang.String)
134         */
135        @Override
136        protected void addModelToResourceSet(Shell shell, String uri) {
137                ResourceSet resourceSet = getResourceSet(input);
138                
139                if (resourceSet != null) {
140                        URI model = URI.createURI(uri);
141                        try {
142                                resourceSet.getResource(model, true);
143                        } catch (Throwable t) {
144                                MessageDialog.openInformation(shell, "Resource Loader Error", t
145                                                .getMessage());
146                        }
147                }
148        }
149        
150        /**
151         * Get a resource set from dialog input object
152         * 
153         * @param object -
154         *            dialog input object
155         */
156        protected ResourceSet getResourceSet(Object object) {
157                /** ResourceSet */
158                if (object instanceof ResourceSet)
159                        return (ResourceSet) object;
160                /** EObject */
161                if (object instanceof EObject) {
162                        TransactionalEditingDomain editingDomain = TransactionUtil
163                                        .getEditingDomain((EObject) object);
164                        if (editingDomain != null)
165                                return editingDomain.getResourceSet();
166                }
167                return null;
168        }
169        
170        /**
171         * The method supplies the main knots of, in this dialogue the represented,
172         * tree
173         */
174        public Object getViewerRootElement() {
175                Object object = null;
176                
177                if (contentProvider != null){
178                        object = (contentProvider.getElements(input))[0];
179                }
180                
181                return object;
182        }
183}

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