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

COVERAGE SUMMARY FOR SOURCE FILE [OperationProvidedRoleItemSemanticEditPolicy.java]

nameclass, %method, %block, %line, %
OperationProvidedRoleItemSemanticEditPolicy.java0%   (0/1)0%   (0/8)0%   (0/388)0%   (0/109)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OperationProvidedRoleItemSemanticEditPolicy0%   (0/1)0%   (0/8)0%   (0/388)0%   (0/109)
OperationProvidedRoleItemSemanticEditPolicy (): void 0%   (0/1)0%   (0/4)0%   (0/2)
getCompleteCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/32)0%   (0/9)
getCompleteCreateRelationshipCommandAssemblyConnector (CreateRelationshipRequ... 0%   (0/1)0%   (0/66)0%   (0/21)
getCompleteCreateRelationshipCommandProvidedDelegationConnector (CreateRelati... 0%   (0/1)0%   (0/66)0%   (0/22)
getCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/30)0%   (0/9)
getDestroyElementCommand (DestroyElementRequest): Command 0%   (0/1)0%   (0/145)0%   (0/33)
getReorientRelationshipCommand (ReorientRelationshipRequest): Command 0%   (0/1)0%   (0/22)0%   (0/5)
getStartCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/23)0%   (0/8)

1/*
2 * Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.composite.edit.policies;
5 
6import java.util.Iterator;
7 
8import org.eclipse.emf.ecore.EAnnotation;
9import org.eclipse.emf.ecore.EObject;
10import org.eclipse.gef.commands.Command;
11import org.eclipse.gef.commands.UnexecutableCommand;
12import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
13import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
14import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
15import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
16import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
17import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
18import org.eclipse.gmf.runtime.notation.Edge;
19import org.eclipse.gmf.runtime.notation.View;
20 
21import de.uka.ipd.sdq.pcm.core.composition.ComposedStructure;
22import de.uka.ipd.sdq.pcm.core.composition.CompositionPackage;
23import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.AssemblyConnectorCreateCommand;
24import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.AssemblyConnectorReorientCommand;
25import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.AssemblyConnectorTypeLinkCreateCommand;
26import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.ProvidedDelegationConnectorCreateCommand;
27import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.ProvidedDelegationConnectorReorientCommand;
28import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.ProvidedDelegationConnectorTypeLinkCreateCommand;
29import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyConnectorEditPart;
30import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ProvidedDelegationConnectorEditPart;
31import de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelVisualIDRegistry;
32import de.uka.ipd.sdq.pcm.gmf.composite.providers.PalladioComponentModelElementTypes;
33import de.uka.ipd.sdq.pcm.repository.OperationProvidedRole;
34import de.uka.ipd.sdq.pcm.repository.OperationRequiredRole;
35 
36/**
37 * @generated
38 */
39public class OperationProvidedRoleItemSemanticEditPolicy extends
40                PalladioComponentModelBaseItemSemanticEditPolicy {
41 
42        /**
43         * @generated
44         */
45        public OperationProvidedRoleItemSemanticEditPolicy() {
46                super(PalladioComponentModelElementTypes.OperationProvidedRole_3007);
47        }
48 
49        /**
50         * @generated
51         */
52        protected Command getDestroyElementCommand(DestroyElementRequest req) {
53                View view = (View) getHost().getModel();
54                CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
55                                getEditingDomain(), null);
56                cmd.setTransactionNestingEnabled(false);
57                for (Iterator it = view.getTargetEdges().iterator(); it.hasNext();) {
58                        Edge incomingLink = (Edge) it.next();
59                        if (PalladioComponentModelVisualIDRegistry
60                                        .getVisualID(incomingLink) == AssemblyConnectorEditPart.VISUAL_ID) {
61                                DestroyElementRequest r = new DestroyElementRequest(
62                                                incomingLink.getElement(), false);
63                                cmd.add(new DestroyElementCommand(r));
64                                cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
65                                continue;
66                        }
67                        if (PalladioComponentModelVisualIDRegistry
68                                        .getVisualID(incomingLink) == ProvidedDelegationConnectorEditPart.VISUAL_ID) {
69                                DestroyElementRequest r = new DestroyElementRequest(
70                                                incomingLink.getElement(), false);
71                                cmd.add(new DestroyElementCommand(r));
72                                cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
73                                continue;
74                        }
75                }
76                for (Iterator it = view.getSourceEdges().iterator(); it.hasNext();) {
77                        Edge outgoingLink = (Edge) it.next();
78                        if (PalladioComponentModelVisualIDRegistry
79                                        .getVisualID(outgoingLink) == ProvidedDelegationConnectorEditPart.VISUAL_ID) {
80                                DestroyElementRequest r = new DestroyElementRequest(
81                                                outgoingLink.getElement(), false);
82                                cmd.add(new DestroyElementCommand(r));
83                                cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
84                                continue;
85                        }
86                }
87                EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
88                if (annotation == null) {
89                        // there are indirectly referenced children, need extra commands: false
90                        addDestroyShortcutsCommand(cmd, view);
91                        // delete host element
92                        cmd.add(new DestroyElementCommand(req));
93                } else {
94                        cmd.add(new DeleteCommand(getEditingDomain(), view));
95                }
96                return getGEFWrapper(cmd.reduce());
97        }
98 
99        /**
100         * Get the create relationship command or null / UnexecutableCommand instance
101         * if this is not an valid end for the connector creation.
102         *  
103         * @generated not
104         */
105        protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
106                if (PalladioComponentModelElementTypes.AssemblyConnector_4004 == req
107                                .getElementType()) {
108                        return req.getTarget() == null ? null
109                                        : getCompleteCreateRelationshipCommandAssemblyConnector(req);
110                }
111                if (PalladioComponentModelElementTypes.ProvidedDelegationConnector_4006 == req
112                                .getElementType()) {
113                        return req.getTarget() == null ? null
114                                        : getCompleteCreateRelationshipCommandProvidedDelegationConnector(req);
115                }
116                return super.getCreateRelationshipCommand(req);
117        }
118 
119        /**
120         * Get the complete create relationship command
121         * if the relationship is about an internal assembly connector.
122         * 
123         * @param req The request object for this command request
124         * @return The prepared command.
125         *  
126         * @generated not
127         */
128        protected Command getCompleteCreateRelationshipCommandAssemblyConnector(
129                        CreateRelationshipRequest req) {
130                EObject sourceEObject = req.getSource();
131                EObject targetEObject = req.getTarget();
132                if (false == sourceEObject instanceof OperationRequiredRole
133                                || false == targetEObject instanceof OperationProvidedRole) {
134                        return UnexecutableCommand.INSTANCE;
135                }
136                OperationRequiredRole source = (OperationRequiredRole) sourceEObject;
137                OperationProvidedRole target = (OperationProvidedRole) targetEObject;
138                ComposedStructure container = (ComposedStructure) getRelationshipContainer(
139                                source, CompositionPackage.eINSTANCE.getComposedStructure(),
140                                req.getElementType());
141                if (container == null) {
142                        return UnexecutableCommand.INSTANCE;
143                }
144                if (!PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
145                                .canCreateAssemblyConnector_4004(container, source, target)) {
146                        return UnexecutableCommand.INSTANCE;
147                }
148                if (req.getContainmentFeature() == null) {
149                        req.setContainmentFeature(CompositionPackage.eINSTANCE
150                                        .getComposedStructure_Connectors__ComposedStructure());
151                }
152                req.setParameter("PROV_CHILD_CONTEXT", ((View) getHost().getParent()
153                                .getModel()).getElement());
154                return getGEFWrapper(new AssemblyConnectorTypeLinkCreateCommand(req,
155                                container, source, target));
156        }
157 
158        /**
159         * Get the complete create relationship command
160         * if the relationship is about a operation provided delegation connector.
161         * 
162         * @param req The request object for this command request
163         * @return The prepared command.
164         *  
165         * @generated not
166         */
167        protected Command getCompleteCreateRelationshipCommandProvidedDelegationConnector(
168                        CreateRelationshipRequest req) {
169                EObject sourceEObject = req.getSource();
170                EObject targetEObject = req.getTarget();
171                if (false == sourceEObject instanceof OperationProvidedRole
172                                || false == targetEObject instanceof OperationProvidedRole) {
173                        return UnexecutableCommand.INSTANCE;
174                }
175                OperationProvidedRole source = (OperationProvidedRole) sourceEObject;
176                OperationProvidedRole target = (OperationProvidedRole) targetEObject;
177                ComposedStructure container = (ComposedStructure) getRelationshipContainer(
178                                source, CompositionPackage.eINSTANCE.getComposedStructure(),
179                                req.getElementType());
180                if (container == null) {
181                        return UnexecutableCommand.INSTANCE;
182                }
183                if (!PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
184                                .canCreateProvidedDelegationConnector_4006(container, source,
185                                                target)) {
186                        return UnexecutableCommand.INSTANCE;
187                }
188                if (req.getContainmentFeature() == null) {
189                        req.setContainmentFeature(CompositionPackage.eINSTANCE
190                                        .getComposedStructure_Connectors__ComposedStructure());
191                }
192                req.setParameter("CHILD_CONTEXT", ((View) getHost().getParent()
193                                .getModel()).getElement());
194                return getGEFWrapper(new ProvidedDelegationConnectorTypeLinkCreateCommand(
195                                req, container, source, target));
196        }
197 
198        /**
199         * @generated
200         */
201        protected Command getStartCreateRelationshipCommand(
202                        CreateRelationshipRequest req) {
203                if (PalladioComponentModelElementTypes.AssemblyConnector_4004 == req
204                                .getElementType()) {
205                        return null;
206                }
207                if (PalladioComponentModelElementTypes.ProvidedDelegationConnector_4006 == req
208                                .getElementType()) {
209                        return getGEFWrapper(new ProvidedDelegationConnectorCreateCommand(
210                                        req, req.getSource(), req.getTarget()));
211                }
212                return null;
213        }
214 
215        /**
216         * @generated
217         */
218        protected Command getCompleteCreateRelationshipCommand(
219                        CreateRelationshipRequest req) {
220                if (PalladioComponentModelElementTypes.AssemblyConnector_4004 == req
221                                .getElementType()) {
222                        return getGEFWrapper(new AssemblyConnectorCreateCommand(req, req
223                                        .getSource(), req.getTarget()));
224                }
225                if (PalladioComponentModelElementTypes.ProvidedDelegationConnector_4006 == req
226                                .getElementType()) {
227                        return getGEFWrapper(new ProvidedDelegationConnectorCreateCommand(
228                                        req, req.getSource(), req.getTarget()));
229                }
230                return null;
231        }
232 
233        /**
234         * Returns command to reorient EClass based link. New link target or source
235         * should be the domain model element associated with this node.
236         * 
237         * @generated
238         */
239        protected Command getReorientRelationshipCommand(
240                        ReorientRelationshipRequest req) {
241                switch (getVisualID(req)) {
242                case AssemblyConnectorEditPart.VISUAL_ID:
243                        return getGEFWrapper(new AssemblyConnectorReorientCommand(req));
244                case ProvidedDelegationConnectorEditPart.VISUAL_ID:
245                        return getGEFWrapper(new ProvidedDelegationConnectorReorientCommand(
246                                        req));
247                }
248                return super.getReorientRelationshipCommand(req);
249        }
250 
251}

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