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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelModelingAssistantProvider.java]

nameclass, %method, %block, %line, %
PalladioComponentModelModelingAssistantProvider.java0%   (0/1)0%   (0/12)0%   (0/491)0%   (0/178)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelModelingAssistantProvider0%   (0/1)0%   (0/12)0%   (0/491)0%   (0/178)
PalladioComponentModelModelingAssistantProvider (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getRelTypesOnSource (IAdaptable): List 0%   (0/1)0%   (0/42)0%   (0/17)
getRelTypesOnSourceAndTarget (IAdaptable, IAdaptable): List 0%   (0/1)0%   (0/52)0%   (0/20)
getRelTypesOnTarget (IAdaptable): List 0%   (0/1)0%   (0/42)0%   (0/18)
getTypesForPopupBar (IAdaptable): List 0%   (0/1)0%   (0/137)0%   (0/48)
getTypesForSource (IAdaptable, IElementType): List 0%   (0/1)0%   (0/47)0%   (0/18)
getTypesForTarget (IAdaptable, IElementType): List 0%   (0/1)0%   (0/47)0%   (0/18)
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, IPD, SDQ, University of Karlsruhe
3 */
4package de.uka.ipd.sdq.pcm.gmf.repository.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.repository.edit.parts.BasicComponentComponentParameterCompartmentEditPart;
28import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.BasicComponentEditPart;
29import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.CompleteComponentTypeEditPart;
30import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.CompositeComponentEditPart;
31import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.EventGroupEditPart;
32import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.EventGroupEventTypeListEditPart;
33import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.InfrastructureInterfaceEditPart;
34import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.InfrastructureInterfaceInfrastructureSignatureListEditPart;
35import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.OperationInterfaceEditPart;
36import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.ProvidesComponentTypeEditPart;
37import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.RepositoryEditPart;
38import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.SubSystemEditPart;
39import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.VariableUsageEditPart;
40import de.uka.ipd.sdq.pcm.gmf.repository.part.Messages;
41import de.uka.ipd.sdq.pcm.gmf.repository.part.PalladioComponentModelRepositoryDiagramEditorPlugin;
42 
43/**
44 * @generated
45 */
46public class PalladioComponentModelModelingAssistantProvider extends
47                ModelingAssistantProvider {
48 
49        /**
50         * @generated
51         */
52        public List getTypesForPopupBar(IAdaptable host) {
53                IGraphicalEditPart editPart = (IGraphicalEditPart) host
54                                .getAdapter(IGraphicalEditPart.class);
55                if (editPart instanceof OperationInterfaceEditPart) {
56                        ArrayList types = new ArrayList(1);
57                        types
58                                        .add(PalladioComponentModelElementTypes.OperationSignature_3106);
59                        return types;
60                }
61                if (editPart instanceof EventGroupEditPart) {
62                        ArrayList types = new ArrayList(1);
63                        types.add(PalladioComponentModelElementTypes.EventType_3107);
64                        return types;
65                }
66                if (editPart instanceof BasicComponentEditPart) {
67                        ArrayList types = new ArrayList(2);
68                        types
69                                        .add(PalladioComponentModelElementTypes.ResourceDemandingSEFF_3102);
70                        types.add(PalladioComponentModelElementTypes.PassiveResource_3103);
71                        return types;
72                }
73                if (editPart instanceof InfrastructureInterfaceEditPart) {
74                        ArrayList types = new ArrayList(1);
75                        types
76                                        .add(PalladioComponentModelElementTypes.InfrastructureSignature_3108);
77                        return types;
78                }
79                if (editPart instanceof VariableUsageEditPart) {
80                        ArrayList types = new ArrayList(1);
81                        types
82                                        .add(PalladioComponentModelElementTypes.VariableCharacterisation_3105);
83                        return types;
84                }
85                if (editPart instanceof BasicComponentComponentParameterCompartmentEditPart) {
86                        ArrayList types = new ArrayList(1);
87                        types.add(PalladioComponentModelElementTypes.VariableUsage_3104);
88                        return types;
89                }
90                if (editPart instanceof RepositoryEditPart) {
91                        ArrayList types = new ArrayList(8);
92                        types
93                                        .add(PalladioComponentModelElementTypes.OperationInterface_2107);
94                        types.add(PalladioComponentModelElementTypes.EventGroup_2108);
95                        types.add(PalladioComponentModelElementTypes.BasicComponent_2102);
96                        types
97                                        .add(PalladioComponentModelElementTypes.CompositeComponent_2103);
98                        types
99                                        .add(PalladioComponentModelElementTypes.CompleteComponentType_2104);
100                        types
101                                        .add(PalladioComponentModelElementTypes.ProvidesComponentType_2105);
102                        types.add(PalladioComponentModelElementTypes.SubSystem_2106);
103                        types
104                                        .add(PalladioComponentModelElementTypes.InfrastructureInterface_2109);
105                        return types;
106                }
107                return Collections.EMPTY_LIST;
108        }
109 
110        /**
111         * @generated
112         */
113        public List getRelTypesOnSource(IAdaptable source) {
114                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
115                                .getAdapter(IGraphicalEditPart.class);
116                if (sourceEditPart instanceof BasicComponentEditPart) {
117                        return ((BasicComponentEditPart) sourceEditPart)
118                                        .getMARelTypesOnSource();
119                }
120                if (sourceEditPart instanceof CompositeComponentEditPart) {
121                        return ((CompositeComponentEditPart) sourceEditPart)
122                                        .getMARelTypesOnSource();
123                }
124                if (sourceEditPart instanceof CompleteComponentTypeEditPart) {
125                        return ((CompleteComponentTypeEditPart) sourceEditPart)
126                                        .getMARelTypesOnSource();
127                }
128                if (sourceEditPart instanceof ProvidesComponentTypeEditPart) {
129                        return ((ProvidesComponentTypeEditPart) sourceEditPart)
130                                        .getMARelTypesOnSource();
131                }
132                if (sourceEditPart instanceof SubSystemEditPart) {
133                        return ((SubSystemEditPart) sourceEditPart).getMARelTypesOnSource();
134                }
135                return Collections.EMPTY_LIST;
136        }
137 
138        /**
139         * @generated
140         */
141        public List getRelTypesOnTarget(IAdaptable target) {
142                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
143                                .getAdapter(IGraphicalEditPart.class);
144                if (targetEditPart instanceof OperationInterfaceEditPart) {
145                        return ((OperationInterfaceEditPart) targetEditPart)
146                                        .getMARelTypesOnTarget();
147                }
148                if (targetEditPart instanceof EventGroupEditPart) {
149                        return ((EventGroupEditPart) targetEditPart)
150                                        .getMARelTypesOnTarget();
151                }
152                if (targetEditPart instanceof CompleteComponentTypeEditPart) {
153                        return ((CompleteComponentTypeEditPart) targetEditPart)
154                                        .getMARelTypesOnTarget();
155                }
156                if (targetEditPart instanceof ProvidesComponentTypeEditPart) {
157                        return ((ProvidesComponentTypeEditPart) targetEditPart)
158                                        .getMARelTypesOnTarget();
159                }
160                if (targetEditPart instanceof InfrastructureInterfaceEditPart) {
161                        return ((InfrastructureInterfaceEditPart) targetEditPart)
162                                        .getMARelTypesOnTarget();
163                }
164                return Collections.EMPTY_LIST;
165        }
166 
167        /**
168         * @generated
169         */
170        public List getRelTypesOnSourceAndTarget(IAdaptable source,
171                        IAdaptable target) {
172                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
173                                .getAdapter(IGraphicalEditPart.class);
174                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
175                                .getAdapter(IGraphicalEditPart.class);
176                if (sourceEditPart instanceof BasicComponentEditPart) {
177                        return ((BasicComponentEditPart) sourceEditPart)
178                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
179                }
180                if (sourceEditPart instanceof CompositeComponentEditPart) {
181                        return ((CompositeComponentEditPart) sourceEditPart)
182                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
183                }
184                if (sourceEditPart instanceof CompleteComponentTypeEditPart) {
185                        return ((CompleteComponentTypeEditPart) sourceEditPart)
186                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
187                }
188                if (sourceEditPart instanceof ProvidesComponentTypeEditPart) {
189                        return ((ProvidesComponentTypeEditPart) sourceEditPart)
190                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
191                }
192                if (sourceEditPart instanceof SubSystemEditPart) {
193                        return ((SubSystemEditPart) sourceEditPart)
194                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
195                }
196                return Collections.EMPTY_LIST;
197        }
198 
199        /**
200         * @generated
201         */
202        public List getTypesForSource(IAdaptable target,
203                        IElementType relationshipType) {
204                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
205                                .getAdapter(IGraphicalEditPart.class);
206                if (targetEditPart instanceof OperationInterfaceEditPart) {
207                        return ((OperationInterfaceEditPart) targetEditPart)
208                                        .getMATypesForSource(relationshipType);
209                }
210                if (targetEditPart instanceof EventGroupEditPart) {
211                        return ((EventGroupEditPart) targetEditPart)
212                                        .getMATypesForSource(relationshipType);
213                }
214                if (targetEditPart instanceof CompleteComponentTypeEditPart) {
215                        return ((CompleteComponentTypeEditPart) targetEditPart)
216                                        .getMATypesForSource(relationshipType);
217                }
218                if (targetEditPart instanceof ProvidesComponentTypeEditPart) {
219                        return ((ProvidesComponentTypeEditPart) targetEditPart)
220                                        .getMATypesForSource(relationshipType);
221                }
222                if (targetEditPart instanceof InfrastructureInterfaceEditPart) {
223                        return ((InfrastructureInterfaceEditPart) targetEditPart)
224                                        .getMATypesForSource(relationshipType);
225                }
226                return Collections.EMPTY_LIST;
227        }
228 
229        /**
230         * @generated
231         */
232        public List getTypesForTarget(IAdaptable source,
233                        IElementType relationshipType) {
234                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
235                                .getAdapter(IGraphicalEditPart.class);
236                if (sourceEditPart instanceof BasicComponentEditPart) {
237                        return ((BasicComponentEditPart) sourceEditPart)
238                                        .getMATypesForTarget(relationshipType);
239                }
240                if (sourceEditPart instanceof CompositeComponentEditPart) {
241                        return ((CompositeComponentEditPart) sourceEditPart)
242                                        .getMATypesForTarget(relationshipType);
243                }
244                if (sourceEditPart instanceof CompleteComponentTypeEditPart) {
245                        return ((CompleteComponentTypeEditPart) sourceEditPart)
246                                        .getMATypesForTarget(relationshipType);
247                }
248                if (sourceEditPart instanceof ProvidesComponentTypeEditPart) {
249                        return ((ProvidesComponentTypeEditPart) sourceEditPart)
250                                        .getMATypesForTarget(relationshipType);
251                }
252                if (sourceEditPart instanceof SubSystemEditPart) {
253                        return ((SubSystemEditPart) sourceEditPart)
254                                        .getMATypesForTarget(relationshipType);
255                }
256                return Collections.EMPTY_LIST;
257        }
258 
259        /**
260         * @generated
261         */
262        public EObject selectExistingElementForSource(IAdaptable target,
263                        IElementType relationshipType) {
264                return selectExistingElement(target, getTypesForSource(target,
265                                relationshipType));
266        }
267 
268        /**
269         * @generated
270         */
271        public EObject selectExistingElementForTarget(IAdaptable source,
272                        IElementType relationshipType) {
273                return selectExistingElement(source, getTypesForTarget(source,
274                                relationshipType));
275        }
276 
277        /**
278         * @generated
279         */
280        protected EObject selectExistingElement(IAdaptable host, Collection types) {
281                if (types.isEmpty()) {
282                        return null;
283                }
284                IGraphicalEditPart editPart = (IGraphicalEditPart) host
285                                .getAdapter(IGraphicalEditPart.class);
286                if (editPart == null) {
287                        return null;
288                }
289                Diagram diagram = (Diagram) editPart.getRoot().getContents().getModel();
290                Collection elements = new HashSet();
291                for (Iterator it = diagram.getElement().eAllContents(); it.hasNext();) {
292                        EObject element = (EObject) it.next();
293                        if (isApplicableElement(element, types)) {
294                                elements.add(element);
295                        }
296                }
297                if (elements.isEmpty()) {
298                        return null;
299                }
300                return selectElement((EObject[]) elements.toArray(new EObject[elements
301                                .size()]));
302        }
303 
304        /**
305         * @generated
306         */
307        protected boolean isApplicableElement(EObject element, Collection types) {
308                IElementType type = ElementTypeRegistry.getInstance().getElementType(
309                                element);
310                return types.contains(type);
311        }
312 
313        /**
314         * @generated
315         */
316        protected EObject selectElement(EObject[] elements) {
317                Shell shell = Display.getCurrent().getActiveShell();
318                ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
319                                PalladioComponentModelRepositoryDiagramEditorPlugin
320                                                .getInstance().getItemProvidersAdapterFactory());
321                ElementListSelectionDialog dialog = new ElementListSelectionDialog(
322                                shell, labelProvider);
323                dialog
324                                .setMessage(Messages.PalladioComponentModelModelingAssistantProviderMessage);
325                dialog
326                                .setTitle(Messages.PalladioComponentModelModelingAssistantProviderTitle);
327                dialog.setMultipleSelection(false);
328                dialog.setElements(elements);
329                EObject selected = null;
330                if (dialog.open() == Window.OK) {
331                        selected = (EObject) dialog.getFirstResult();
332                }
333                return selected;
334        }
335}

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