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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelModelingAssistantProvider.java]

nameclass, %method, %block, %line, %
PalladioComponentModelModelingAssistantProvider.java0%   (0/1)0%   (0/12)0%   (0/454)0%   (0/168)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelModelingAssistantProvider0%   (0/1)0%   (0/12)0%   (0/454)0%   (0/168)
PalladioComponentModelModelingAssistantProvider (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getRelTypesOnSource (IAdaptable): List 0%   (0/1)0%   (0/49)0%   (0/21)
getRelTypesOnSourceAndTarget (IAdaptable, IAdaptable): List 0%   (0/1)0%   (0/60)0%   (0/23)
getRelTypesOnTarget (IAdaptable): List 0%   (0/1)0%   (0/49)0%   (0/20)
getTypesForPopupBar (IAdaptable): List 0%   (0/1)0%   (0/62)0%   (0/23)
getTypesForSource (IAdaptable, IElementType): List 0%   (0/1)0%   (0/55)0%   (0/21)
getTypesForTarget (IAdaptable, IElementType): List 0%   (0/1)0%   (0/55)0%   (0/21)
isApplicableElement (EObject, Collection): boolean 0%   (0/1)0%   (0/8)0%   (0/3)
selectElement (EObject []): EObject 0%   (0/1)0%   (0/38)0%   (0/15)
selectExistingElement (IAdaptable, Collection): EObject 0%   (0/1)0%   (0/59)0%   (0/16)
selectExistingElementForSource (IAdaptable, IElementType): EObject 0%   (0/1)0%   (0/8)0%   (0/2)
selectExistingElementForTarget (IAdaptable, IElementType): EObject 0%   (0/1)0%   (0/8)0%   (0/2)

1/*
2 *Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.composite.providers;
5 
6import java.util.ArrayList;
7import java.util.Collection;
8import java.util.Collections;
9import java.util.HashSet;
10import java.util.Iterator;
11import java.util.List;
12 
13import org.eclipse.core.runtime.IAdaptable;
14import org.eclipse.emf.ecore.EObject;
15import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
16import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
17import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
18import org.eclipse.gmf.runtime.emf.type.core.IElementType;
19import org.eclipse.gmf.runtime.emf.ui.services.modelingassistant.ModelingAssistantProvider;
20import org.eclipse.gmf.runtime.notation.Diagram;
21import org.eclipse.jface.viewers.ILabelProvider;
22import org.eclipse.jface.window.Window;
23import org.eclipse.swt.widgets.Display;
24import org.eclipse.swt.widgets.Shell;
25import org.eclipse.ui.dialogs.ElementListSelectionDialog;
26 
27import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyContextEditPart;
28import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ComposedProvidingRequiringEntity2EditPart;
29import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ComposedProvidingRequiringEntityCompositeStructureInnerCompartmentEditPart;
30import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ComposedProvidingRequiringEntityEditPart;
31import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.InfrastructureProvidedRoleEditPart;
32import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.InfrastructureRequiredRoleEditPart;
33import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationProvidedRole2EditPart;
34import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationProvidedRoleEditPart;
35import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationRequiredRole2EditPart;
36import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationRequiredRoleEditPart;
37import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.SinkRoleEditPart;
38import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.SourceRoleEditPart;
39import de.uka.ipd.sdq.pcm.gmf.composite.part.Messages;
40import de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelComposedStructureDiagramEditorPlugin;
41 
42/**
43 * @generated
44 */
45public class PalladioComponentModelModelingAssistantProvider extends
46                ModelingAssistantProvider {
47 
48        /**
49         * Get the types to provide within a pop-up bar (hover context menu) 
50         * in the editor.
51         * 
52         * This method has manually be adopted to disable the creation of new
53         * Composed Providing Requiring Entities within the same system. 
54         * 
55         * @generated not
56         */
57        public List getTypesForPopupBar(IAdaptable host) {
58                IGraphicalEditPart editPart = (IGraphicalEditPart) host
59                                .getAdapter(IGraphicalEditPart.class);
60                if (editPart instanceof ComposedProvidingRequiringEntity2EditPart) {
61                        ArrayList types = new ArrayList(2);
62                        types
63                                        .add(PalladioComponentModelElementTypes.OperationProvidedRole_3011);
64                        types
65                                        .add(PalladioComponentModelElementTypes.OperationRequiredRole_3012);
66                        return types;
67                }
68                if (editPart instanceof AssemblyContextEditPart) {
69                        ArrayList types = new ArrayList(2);
70                        types
71                                        .add(PalladioComponentModelElementTypes.OperationProvidedRole_3007);
72                        types
73                                        .add(PalladioComponentModelElementTypes.OperationRequiredRole_3008);
74                        return types;
75                }
76                if (editPart instanceof ComposedProvidingRequiringEntityCompositeStructureInnerCompartmentEditPart) {
77                        ArrayList types = new ArrayList(1);
78                        types.add(PalladioComponentModelElementTypes.AssemblyContext_3006);
79                        return types;
80                }
81                if (editPart instanceof ComposedProvidingRequiringEntityEditPart) {
82                        return Collections.EMPTY_LIST;
83                }
84                return Collections.EMPTY_LIST;
85        }
86 
87        /**
88         * @generated
89         */
90        public List getRelTypesOnSource(IAdaptable source) {
91                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
92                                .getAdapter(IGraphicalEditPart.class);
93                if (sourceEditPart instanceof OperationProvidedRoleEditPart) {
94                        return ((OperationProvidedRoleEditPart) sourceEditPart)
95                                        .getMARelTypesOnSource();
96                }
97                if (sourceEditPart instanceof OperationRequiredRoleEditPart) {
98                        return ((OperationRequiredRoleEditPart) sourceEditPart)
99                                        .getMARelTypesOnSource();
100                }
101                if (sourceEditPart instanceof SourceRoleEditPart) {
102                        return ((SourceRoleEditPart) sourceEditPart)
103                                        .getMARelTypesOnSource();
104                }
105                if (sourceEditPart instanceof InfrastructureRequiredRoleEditPart) {
106                        return ((InfrastructureRequiredRoleEditPart) sourceEditPart)
107                                        .getMARelTypesOnSource();
108                }
109                if (sourceEditPart instanceof OperationProvidedRole2EditPart) {
110                        return ((OperationProvidedRole2EditPart) sourceEditPart)
111                                        .getMARelTypesOnSource();
112                }
113                if (sourceEditPart instanceof OperationRequiredRole2EditPart) {
114                        return ((OperationRequiredRole2EditPart) sourceEditPart)
115                                        .getMARelTypesOnSource();
116                }
117                return Collections.EMPTY_LIST;
118        }
119 
120        /**
121         * @generated
122         */
123        public List getRelTypesOnTarget(IAdaptable target) {
124                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
125                                .getAdapter(IGraphicalEditPart.class);
126                if (targetEditPart instanceof OperationProvidedRoleEditPart) {
127                        return ((OperationProvidedRoleEditPart) targetEditPart)
128                                        .getMARelTypesOnTarget();
129                }
130                if (targetEditPart instanceof OperationRequiredRoleEditPart) {
131                        return ((OperationRequiredRoleEditPart) targetEditPart)
132                                        .getMARelTypesOnTarget();
133                }
134                if (targetEditPart instanceof SinkRoleEditPart) {
135                        return ((SinkRoleEditPart) targetEditPart).getMARelTypesOnTarget();
136                }
137                if (targetEditPart instanceof InfrastructureProvidedRoleEditPart) {
138                        return ((InfrastructureProvidedRoleEditPart) targetEditPart)
139                                        .getMARelTypesOnTarget();
140                }
141                if (targetEditPart instanceof OperationProvidedRole2EditPart) {
142                        return ((OperationProvidedRole2EditPart) targetEditPart)
143                                        .getMARelTypesOnTarget();
144                }
145                if (targetEditPart instanceof OperationRequiredRole2EditPart) {
146                        return ((OperationRequiredRole2EditPart) targetEditPart)
147                                        .getMARelTypesOnTarget();
148                }
149                return Collections.EMPTY_LIST;
150        }
151 
152        /**
153         * @generated
154         */
155        public List getRelTypesOnSourceAndTarget(IAdaptable source,
156                        IAdaptable target) {
157                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
158                                .getAdapter(IGraphicalEditPart.class);
159                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
160                                .getAdapter(IGraphicalEditPart.class);
161                if (sourceEditPart instanceof OperationProvidedRoleEditPart) {
162                        return ((OperationProvidedRoleEditPart) sourceEditPart)
163                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
164                }
165                if (sourceEditPart instanceof OperationRequiredRoleEditPart) {
166                        return ((OperationRequiredRoleEditPart) sourceEditPart)
167                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
168                }
169                if (sourceEditPart instanceof SourceRoleEditPart) {
170                        return ((SourceRoleEditPart) sourceEditPart)
171                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
172                }
173                if (sourceEditPart instanceof InfrastructureRequiredRoleEditPart) {
174                        return ((InfrastructureRequiredRoleEditPart) sourceEditPart)
175                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
176                }
177                if (sourceEditPart instanceof OperationProvidedRole2EditPart) {
178                        return ((OperationProvidedRole2EditPart) sourceEditPart)
179                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
180                }
181                if (sourceEditPart instanceof OperationRequiredRole2EditPart) {
182                        return ((OperationRequiredRole2EditPart) sourceEditPart)
183                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
184                }
185                return Collections.EMPTY_LIST;
186        }
187 
188        /**
189         * @generated
190         */
191        public List getTypesForSource(IAdaptable target,
192                        IElementType relationshipType) {
193                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
194                                .getAdapter(IGraphicalEditPart.class);
195                if (targetEditPart instanceof OperationProvidedRoleEditPart) {
196                        return ((OperationProvidedRoleEditPart) targetEditPart)
197                                        .getMATypesForSource(relationshipType);
198                }
199                if (targetEditPart instanceof OperationRequiredRoleEditPart) {
200                        return ((OperationRequiredRoleEditPart) targetEditPart)
201                                        .getMATypesForSource(relationshipType);
202                }
203                if (targetEditPart instanceof SinkRoleEditPart) {
204                        return ((SinkRoleEditPart) targetEditPart)
205                                        .getMATypesForSource(relationshipType);
206                }
207                if (targetEditPart instanceof InfrastructureProvidedRoleEditPart) {
208                        return ((InfrastructureProvidedRoleEditPart) targetEditPart)
209                                        .getMATypesForSource(relationshipType);
210                }
211                if (targetEditPart instanceof OperationProvidedRole2EditPart) {
212                        return ((OperationProvidedRole2EditPart) targetEditPart)
213                                        .getMATypesForSource(relationshipType);
214                }
215                if (targetEditPart instanceof OperationRequiredRole2EditPart) {
216                        return ((OperationRequiredRole2EditPart) targetEditPart)
217                                        .getMATypesForSource(relationshipType);
218                }
219                return Collections.EMPTY_LIST;
220        }
221 
222        /**
223         * @generated
224         */
225        public List getTypesForTarget(IAdaptable source,
226                        IElementType relationshipType) {
227                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
228                                .getAdapter(IGraphicalEditPart.class);
229                if (sourceEditPart instanceof OperationProvidedRoleEditPart) {
230                        return ((OperationProvidedRoleEditPart) sourceEditPart)
231                                        .getMATypesForTarget(relationshipType);
232                }
233                if (sourceEditPart instanceof OperationRequiredRoleEditPart) {
234                        return ((OperationRequiredRoleEditPart) sourceEditPart)
235                                        .getMATypesForTarget(relationshipType);
236                }
237                if (sourceEditPart instanceof SourceRoleEditPart) {
238                        return ((SourceRoleEditPart) sourceEditPart)
239                                        .getMATypesForTarget(relationshipType);
240                }
241                if (sourceEditPart instanceof InfrastructureRequiredRoleEditPart) {
242                        return ((InfrastructureRequiredRoleEditPart) sourceEditPart)
243                                        .getMATypesForTarget(relationshipType);
244                }
245                if (sourceEditPart instanceof OperationProvidedRole2EditPart) {
246                        return ((OperationProvidedRole2EditPart) sourceEditPart)
247                                        .getMATypesForTarget(relationshipType);
248                }
249                if (sourceEditPart instanceof OperationRequiredRole2EditPart) {
250                        return ((OperationRequiredRole2EditPart) sourceEditPart)
251                                        .getMATypesForTarget(relationshipType);
252                }
253                return Collections.EMPTY_LIST;
254        }
255 
256        /**
257         * @generated
258         */
259        public EObject selectExistingElementForSource(IAdaptable target,
260                        IElementType relationshipType) {
261                return selectExistingElement(target, getTypesForSource(target,
262                                relationshipType));
263        }
264 
265        /**
266         * @generated
267         */
268        public EObject selectExistingElementForTarget(IAdaptable source,
269                        IElementType relationshipType) {
270                return selectExistingElement(source, getTypesForTarget(source,
271                                relationshipType));
272        }
273 
274        /**
275         * @generated
276         */
277        protected EObject selectExistingElement(IAdaptable host, Collection types) {
278                if (types.isEmpty()) {
279                        return null;
280                }
281                IGraphicalEditPart editPart = (IGraphicalEditPart) host
282                                .getAdapter(IGraphicalEditPart.class);
283                if (editPart == null) {
284                        return null;
285                }
286                Diagram diagram = (Diagram) editPart.getRoot().getContents().getModel();
287                Collection elements = new HashSet();
288                for (Iterator it = diagram.getElement().eAllContents(); it.hasNext();) {
289                        EObject element = (EObject) it.next();
290                        if (isApplicableElement(element, types)) {
291                                elements.add(element);
292                        }
293                }
294                if (elements.isEmpty()) {
295                        return null;
296                }
297                return selectElement((EObject[]) elements.toArray(new EObject[elements
298                                .size()]));
299        }
300 
301        /**
302         * @generated
303         */
304        protected boolean isApplicableElement(EObject element, Collection types) {
305                IElementType type = ElementTypeRegistry.getInstance().getElementType(
306                                element);
307                return types.contains(type);
308        }
309 
310        /**
311         * @generated
312         */
313        protected EObject selectElement(EObject[] elements) {
314                Shell shell = Display.getCurrent().getActiveShell();
315                ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
316                                PalladioComponentModelComposedStructureDiagramEditorPlugin
317                                                .getInstance().getItemProvidersAdapterFactory());
318                ElementListSelectionDialog dialog = new ElementListSelectionDialog(
319                                shell, labelProvider);
320                dialog
321                                .setMessage(Messages.PalladioComponentModelModelingAssistantProviderMessage);
322                dialog
323                                .setTitle(Messages.PalladioComponentModelModelingAssistantProviderTitle);
324                dialog.setMultipleSelection(false);
325                dialog.setElements(elements);
326                EObject selected = null;
327                if (dialog.open() == Window.OK) {
328                        selected = (EObject) dialog.getFirstResult();
329                }
330                return selected;
331        }
332}

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