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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelModelingAssistantProvider.java]

nameclass, %method, %block, %line, %
PalladioComponentModelModelingAssistantProvider.java0%   (0/1)0%   (0/12)0%   (0/193)0%   (0/67)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelModelingAssistantProvider0%   (0/1)0%   (0/12)0%   (0/193)0%   (0/67)
PalladioComponentModelModelingAssistantProvider (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getRelTypesOnSource (IAdaptable): List 0%   (0/1)0%   (0/7)0%   (0/3)
getRelTypesOnSourceAndTarget (IAdaptable, IAdaptable): List 0%   (0/1)0%   (0/12)0%   (0/5)
getRelTypesOnTarget (IAdaptable): List 0%   (0/1)0%   (0/7)0%   (0/3)
getTypesForPopupBar (IAdaptable): List 0%   (0/1)0%   (0/29)0%   (0/11)
getTypesForSource (IAdaptable, IElementType): List 0%   (0/1)0%   (0/7)0%   (0/3)
getTypesForTarget (IAdaptable, IElementType): List 0%   (0/1)0%   (0/7)0%   (0/3)
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, U KA
3 */
4package de.uka.ipd.sdq.pcm.gmf.allocation.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.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
15import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
16import org.eclipse.gmf.runtime.emf.type.core.IElementType;
17import org.eclipse.gmf.runtime.emf.ui.services.modelingassistant.ModelingAssistantProvider;
18import org.eclipse.gmf.runtime.notation.Diagram;
19import org.eclipse.jface.viewers.ILabelProvider;
20import org.eclipse.jface.window.Window;
21import org.eclipse.swt.widgets.Display;
22import org.eclipse.swt.widgets.Shell;
23import org.eclipse.ui.dialogs.ElementListSelectionDialog;
24import org.eclipse.emf.ecore.EObject;
25import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
26import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationEditPart;
27import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerAllocationCompartmentEditPart;
28 
29import de.uka.ipd.sdq.pcm.gmf.allocation.part.Messages;
30import de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelAllocationDiagramEditorPlugin;
31 
32/**
33 * @generated
34 */
35public class PalladioComponentModelModelingAssistantProvider extends
36                ModelingAssistantProvider {
37 
38        /**
39         * @generated not
40         */
41        public List getTypesForPopupBar(IAdaptable host) {
42                IGraphicalEditPart editPart = (IGraphicalEditPart) host
43                                .getAdapter(IGraphicalEditPart.class);
44                if (editPart instanceof ResourceContainerAllocationCompartmentEditPart) {
45                        List types = new ArrayList();
46                        types
47                                        .add(PalladioComponentModelElementTypes.AllocationContext_3001);
48                        return types;
49                }
50                if (editPart instanceof AllocationEditPart) {
51                        List types = new ArrayList();
52                        //types
53                        //                .add(PalladioComponentModelElementTypes.ResourceContainer_2002);
54                        return types;
55                }
56                return Collections.EMPTY_LIST;
57        }
58 
59        /**
60         * @generated
61         */
62        public List getRelTypesOnSource(IAdaptable source) {
63                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
64                                .getAdapter(IGraphicalEditPart.class);
65                return Collections.EMPTY_LIST;
66        }
67 
68        /**
69         * @generated
70         */
71        public List getRelTypesOnTarget(IAdaptable target) {
72                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
73                                .getAdapter(IGraphicalEditPart.class);
74                return Collections.EMPTY_LIST;
75        }
76 
77        /**
78         * @generated
79         */
80        public List getRelTypesOnSourceAndTarget(IAdaptable source,
81                        IAdaptable target) {
82                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
83                                .getAdapter(IGraphicalEditPart.class);
84                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
85                                .getAdapter(IGraphicalEditPart.class);
86                return Collections.EMPTY_LIST;
87        }
88 
89        /**
90         * @generated
91         */
92        public List getTypesForSource(IAdaptable target,
93                        IElementType relationshipType) {
94                IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target
95                                .getAdapter(IGraphicalEditPart.class);
96                return Collections.EMPTY_LIST;
97        }
98 
99        /**
100         * @generated
101         */
102        public List getTypesForTarget(IAdaptable source,
103                        IElementType relationshipType) {
104                IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source
105                                .getAdapter(IGraphicalEditPart.class);
106                return Collections.EMPTY_LIST;
107        }
108 
109        /**
110         * @generated
111         */
112        public EObject selectExistingElementForSource(IAdaptable target,
113                        IElementType relationshipType) {
114                return selectExistingElement(target, getTypesForSource(target,
115                                relationshipType));
116        }
117 
118        /**
119         * @generated
120         */
121        public EObject selectExistingElementForTarget(IAdaptable source,
122                        IElementType relationshipType) {
123                return selectExistingElement(source, getTypesForTarget(source,
124                                relationshipType));
125        }
126 
127        /**
128         * @generated
129         */
130        protected EObject selectExistingElement(IAdaptable host, Collection types) {
131                if (types.isEmpty()) {
132                        return null;
133                }
134                IGraphicalEditPart editPart = (IGraphicalEditPart) host
135                                .getAdapter(IGraphicalEditPart.class);
136                if (editPart == null) {
137                        return null;
138                }
139                Diagram diagram = (Diagram) editPart.getRoot().getContents().getModel();
140                Collection elements = new HashSet();
141                for (Iterator it = diagram.getElement().eAllContents(); it.hasNext();) {
142                        EObject element = (EObject) it.next();
143                        if (isApplicableElement(element, types)) {
144                                elements.add(element);
145                        }
146                }
147                if (elements.isEmpty()) {
148                        return null;
149                }
150                return selectElement((EObject[]) elements.toArray(new EObject[elements
151                                .size()]));
152        }
153 
154        /**
155         * @generated
156         */
157        protected boolean isApplicableElement(EObject element, Collection types) {
158                IElementType type = ElementTypeRegistry.getInstance().getElementType(
159                                element);
160                return types.contains(type);
161        }
162 
163        /**
164         * @generated
165         */
166        protected EObject selectElement(EObject[] elements) {
167                Shell shell = Display.getCurrent().getActiveShell();
168                ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
169                                PalladioComponentModelAllocationDiagramEditorPlugin
170                                                .getInstance().getItemProvidersAdapterFactory());
171                ElementListSelectionDialog dialog = new ElementListSelectionDialog(
172                                shell, labelProvider);
173                dialog
174                                .setMessage(Messages.PalladioComponentModelModelingAssistantProviderMessage);
175                dialog
176                                .setTitle(Messages.PalladioComponentModelModelingAssistantProviderTitle);
177                dialog.setMultipleSelection(false);
178                dialog.setElements(elements);
179                EObject selected = null;
180                if (dialog.open() == Window.OK) {
181                        selected = (EObject) dialog.getFirstResult();
182                }
183                return selected;
184        }
185}

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