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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelModelingAssistantProvider.java]

nameclass, %method, %block, %line, %
PalladioComponentModelModelingAssistantProvider.java0%   (0/1)0%   (0/12)0%   (0/255)0%   (0/91)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelModelingAssistantProvider0%   (0/1)0%   (0/12)0%   (0/255)0%   (0/91)
PalladioComponentModelModelingAssistantProvider (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getRelTypesOnSource (IAdaptable): List 0%   (0/1)0%   (0/14)0%   (0/6)
getRelTypesOnSourceAndTarget (IAdaptable, IAdaptable): List 0%   (0/1)0%   (0/20)0%   (0/8)
getRelTypesOnTarget (IAdaptable): List 0%   (0/1)0%   (0/14)0%   (0/6)
getTypesForPopupBar (IAdaptable): List 0%   (0/1)0%   (0/53)0%   (0/19)
getTypesForSource (IAdaptable, IElementType): List 0%   (0/1)0%   (0/15)0%   (0/6)
getTypesForTarget (IAdaptable, IElementType): List 0%   (0/1)0%   (0/15)0%   (0/6)
isApplicableElement (EObject, Collection): boolean 0%   (0/1)0%   (0/8)0%   (0/3)
selectElement (EObject []): EObject 0%   (0/1)0%   (0/38)0%   (0/16)
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 2009, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.resource.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.resource.edit.parts.LinkingResource2EditPart;
28import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ResourceContainerEditPart;
29import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ResourceContainerResourceContainerCompartmentEditPart;
30import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ResourceEnvironmentEditPart;
31import de.uka.ipd.sdq.pcm.gmf.resource.part.Messages;
32import de.uka.ipd.sdq.pcm.gmf.resource.part.PalladioComponentModelDiagramEditorPlugin;
33 
34/**
35 * @generated
36 */
37public class PalladioComponentModelModelingAssistantProvider extends
38                ModelingAssistantProvider {
39 
40        /**
41         * @generated
42         */
43        public List getTypesForPopupBar(IAdaptable host) {
44                IGraphicalEditPart editPart = (IGraphicalEditPart) host
45                                .getAdapter(IGraphicalEditPart.class);
46                if (editPart instanceof ResourceContainerEditPart) {
47                        ArrayList types = new ArrayList(1);
48                        types
49                                        .add(PalladioComponentModelElementTypes.ProcessingResourceSpecification_3001);
50                        return types;
51                }
52                if (editPart instanceof LinkingResource2EditPart) {
53                        ArrayList types = new ArrayList(1);
54                        types
55                                        .add(PalladioComponentModelElementTypes.CommunicationLinkResourceSpecification_3002);
56                        return types;
57                }
58                if (editPart instanceof ResourceEnvironmentEditPart) {
59                        ArrayList types = new ArrayList(2);
60                        types
61                                        .add(PalladioComponentModelElementTypes.ResourceContainer_2001);
62                        types.add(PalladioComponentModelElementTypes.LinkingResource_2003);
63                        return types;
64                }
65                return Collections.EMPTY_LIST;
66        }
67 
68        /**
69         * @generated
70         */
71        public List getRelTypesOnSource(IAdaptable source) {
72                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
73                                .getAdapter(IGraphicalEditPart.class);
74                if (sourceEditPart instanceof LinkingResource2EditPart) {
75                        return ((LinkingResource2EditPart) sourceEditPart)
76                                        .getMARelTypesOnSource();
77                }
78                return Collections.EMPTY_LIST;
79        }
80 
81        /**
82         * @generated
83         */
84        public List getRelTypesOnTarget(IAdaptable target) {
85                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
86                                .getAdapter(IGraphicalEditPart.class);
87                if (targetEditPart instanceof ResourceContainerEditPart) {
88                        return ((ResourceContainerEditPart) targetEditPart)
89                                        .getMARelTypesOnTarget();
90                }
91                return Collections.EMPTY_LIST;
92        }
93 
94        /**
95         * @generated
96         */
97        public List getRelTypesOnSourceAndTarget(IAdaptable source,
98                        IAdaptable target) {
99                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
100                                .getAdapter(IGraphicalEditPart.class);
101                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
102                                .getAdapter(IGraphicalEditPart.class);
103                if (sourceEditPart instanceof LinkingResource2EditPart) {
104                        return ((LinkingResource2EditPart) sourceEditPart)
105                                        .getMARelTypesOnSourceAndTarget(targetEditPart);
106                }
107                return Collections.EMPTY_LIST;
108        }
109 
110        /**
111         * @generated
112         */
113        public List getTypesForSource(IAdaptable target,
114                        IElementType relationshipType) {
115                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
116                                .getAdapter(IGraphicalEditPart.class);
117                if (targetEditPart instanceof ResourceContainerEditPart) {
118                        return ((ResourceContainerEditPart) targetEditPart)
119                                        .getMATypesForSource(relationshipType);
120                }
121                return Collections.EMPTY_LIST;
122        }
123 
124        /**
125         * @generated
126         */
127        public List getTypesForTarget(IAdaptable source,
128                        IElementType relationshipType) {
129                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
130                                .getAdapter(IGraphicalEditPart.class);
131                if (sourceEditPart instanceof LinkingResource2EditPart) {
132                        return ((LinkingResource2EditPart) sourceEditPart)
133                                        .getMATypesForTarget(relationshipType);
134                }
135                return Collections.EMPTY_LIST;
136        }
137 
138        /**
139         * @generated
140         */
141        public EObject selectExistingElementForSource(IAdaptable target,
142                        IElementType relationshipType) {
143                return selectExistingElement(target, getTypesForSource(target,
144                                relationshipType));
145        }
146 
147        /**
148         * @generated
149         */
150        public EObject selectExistingElementForTarget(IAdaptable source,
151                        IElementType relationshipType) {
152                return selectExistingElement(source, getTypesForTarget(source,
153                                relationshipType));
154        }
155 
156        /**
157         * @generated
158         */
159        protected EObject selectExistingElement(IAdaptable host, Collection types) {
160                if (types.isEmpty()) {
161                        return null;
162                }
163                IGraphicalEditPart editPart = (IGraphicalEditPart) host
164                                .getAdapter(IGraphicalEditPart.class);
165                if (editPart == null) {
166                        return null;
167                }
168                Diagram diagram = (Diagram) editPart.getRoot().getContents().getModel();
169                Collection elements = new HashSet();
170                for (Iterator it = diagram.getElement().eAllContents(); it.hasNext();) {
171                        EObject element = (EObject) it.next();
172                        if (isApplicableElement(element, types)) {
173                                elements.add(element);
174                        }
175                }
176                if (elements.isEmpty()) {
177                        return null;
178                }
179                return selectElement((EObject[]) elements.toArray(new EObject[elements
180                                .size()]));
181        }
182 
183        /**
184         * @generated
185         */
186        protected boolean isApplicableElement(EObject element, Collection types) {
187                IElementType type = ElementTypeRegistry.getInstance().getElementType(
188                                element);
189                return types.contains(type);
190        }
191 
192        /**
193         * @generated
194         */
195        protected EObject selectElement(EObject[] elements) {
196                Shell shell = Display.getCurrent().getActiveShell();
197                ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
198                                PalladioComponentModelDiagramEditorPlugin.getInstance()
199                                                .getItemProvidersAdapterFactory());
200                ElementListSelectionDialog dialog = new ElementListSelectionDialog(
201                                shell, labelProvider);
202                dialog
203                                .setMessage(Messages.PalladioComponentModelModelingAssistantProviderMessage);
204                dialog
205                                .setTitle(Messages.PalladioComponentModelModelingAssistantProviderTitle);
206                dialog.setMultipleSelection(false);
207                dialog.setElements(elements);
208                EObject selected = null;
209                if (dialog.open() == Window.OK) {
210                        selected = (EObject) dialog.getFirstResult();
211                }
212                return selected;
213        }
214}

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