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 [AssemblyContextItemSemanticEditPolicy.java]

nameclass, %method, %block, %line, %
AssemblyContextItemSemanticEditPolicy.java0%   (0/1)0%   (0/4)0%   (0/626)0%   (0/166)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AssemblyContextItemSemanticEditPolicy0%   (0/1)0%   (0/4)0%   (0/626)0%   (0/166)
AssemblyContextItemSemanticEditPolicy (): void 0%   (0/1)0%   (0/4)0%   (0/2)
addDestroyChildNodesCommand (ICompositeCommand): void 0%   (0/1)0%   (0/452)0%   (0/118)
getCreateCommand (CreateElementRequest): Command 0%   (0/1)0%   (0/70)0%   (0/21)
getDestroyElementCommand (DestroyElementRequest): Command 0%   (0/1)0%   (0/100)0%   (0/25)

1/*
2 * Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.composite.edit.policies;
5 
6import java.util.ArrayList;
7import java.util.Collection;
8import java.util.Collections;
9import java.util.Iterator;
10 
11import org.eclipse.emf.ecore.EAnnotation;
12import org.eclipse.gef.EditPart;
13import org.eclipse.gef.commands.Command;
14import org.eclipse.gef.commands.CompoundCommand;
15import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
16import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
17import org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart;
18import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
19import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
20import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
21import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
22import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
23import org.eclipse.gmf.runtime.notation.Edge;
24import org.eclipse.gmf.runtime.notation.Node;
25import org.eclipse.gmf.runtime.notation.View;
26 
27import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.InfrastructureProvidedRoleCreateCommand;
28import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.InfrastructureRequiredRoleCreateCommand;
29import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.OperationProvidedRoleCreateCommand;
30import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.OperationRequiredRoleCreateCommand;
31import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.SinkRoleCreateCommand;
32import de.uka.ipd.sdq.pcm.gmf.composite.edit.commands.SourceRoleCreateCommand;
33import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyConnectorEditPart;
34import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyContextEditPart;
35import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyEventConnectorEditPart;
36import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.AssemblyInfrastructureConnectorEditPart;
37import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.InfrastructureProvidedRoleEditPart;
38import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.InfrastructureRequiredRoleEditPart;
39import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationProvidedRoleEditPart;
40import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.OperationRequiredRoleEditPart;
41import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.ProvidedDelegationConnectorEditPart;
42import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.RequiredDelegationConnectorEditPart;
43import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.SinkRoleEditPart;
44import de.uka.ipd.sdq.pcm.gmf.composite.edit.parts.SourceRoleEditPart;
45import de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelVisualIDRegistry;
46import de.uka.ipd.sdq.pcm.gmf.composite.providers.PalladioComponentModelElementTypes;
47 
48/**
49 * @generated
50 */
51public class AssemblyContextItemSemanticEditPolicy extends
52                PalladioComponentModelBaseItemSemanticEditPolicy {
53 
54        /**
55         * @generated
56         */
57        public AssemblyContextItemSemanticEditPolicy() {
58                super(PalladioComponentModelElementTypes.AssemblyContext_3006);
59        }
60 
61        /**
62         * @generated
63         */
64        protected Command getCreateCommand(CreateElementRequest req) {
65                if (PalladioComponentModelElementTypes.OperationProvidedRole_3007 == req
66                                .getElementType()) {
67                        return getGEFWrapper(new OperationProvidedRoleCreateCommand(req));
68                }
69                if (PalladioComponentModelElementTypes.OperationRequiredRole_3008 == req
70                                .getElementType()) {
71                        return getGEFWrapper(new OperationRequiredRoleCreateCommand(req));
72                }
73                if (PalladioComponentModelElementTypes.SourceRole_3013 == req
74                                .getElementType()) {
75                        return getGEFWrapper(new SourceRoleCreateCommand(req));
76                }
77                if (PalladioComponentModelElementTypes.SinkRole_3014 == req
78                                .getElementType()) {
79                        return getGEFWrapper(new SinkRoleCreateCommand(req));
80                }
81                if (PalladioComponentModelElementTypes.InfrastructureProvidedRole_3015 == req
82                                .getElementType()) {
83                        return getGEFWrapper(new InfrastructureProvidedRoleCreateCommand(
84                                        req));
85                }
86                if (PalladioComponentModelElementTypes.InfrastructureRequiredRole_3016 == req
87                                .getElementType()) {
88                        return getGEFWrapper(new InfrastructureRequiredRoleCreateCommand(
89                                        req));
90                }
91                return super.getCreateCommand(req);
92        }
93 
94        // TODO: write javadoc and annotations
95        /**
96         * @generated not
97         */
98        protected Command getDestroyElementCommand(DestroyElementRequest req) {
99                CompoundCommand cc = new CompoundCommand();
100                Collection allEdges = new ArrayList();
101                View view = (View) getHost().getModel();
102                for (Object p : getHost().getChildren()) {
103                        if (p instanceof BorderedBorderItemEditPart) {
104                                BorderedBorderItemEditPart borderItem = (BorderedBorderItemEditPart) p;
105                                if (borderItem.getModel() != null
106                                                && borderItem.getModel() instanceof View) {
107                                        allEdges.addAll(((View) borderItem.getModel())
108                                                        .getSourceEdges());
109                                        allEdges.addAll(((View) borderItem.getModel())
110                                                        .getTargetEdges());
111                                }
112                        }
113                }
114                for (Iterator it = allEdges.iterator(); it.hasNext();) {
115                        Edge nextEdge = (Edge) it.next();
116                        EditPart nextEditPart = (EditPart) getHost().getViewer()
117                                        .getEditPartRegistry().get(nextEdge);
118                        EditCommandRequestWrapper editCommandRequest = new EditCommandRequestWrapper(
119                                        new DestroyElementRequest(
120                                                        ((AssemblyContextEditPart) getHost())
121                                                                        .getEditingDomain(), req
122                                                                        .isConfirmationRequired()),
123                                        Collections.EMPTY_MAP);
124                        cc.add(nextEditPart.getCommand(editCommandRequest));
125                }
126                cc.add(getGEFWrapper(new DestroyElementCommand(req)));
127                return cc;
128        }
129 
130        /**
131         * @generated
132         */
133        private void addDestroyChildNodesCommand(ICompositeCommand cmd) {
134                View view = (View) getHost().getModel();
135                for (Iterator nit = view.getChildren().iterator(); nit.hasNext();) {
136                        Node node = (Node) nit.next();
137                        switch (PalladioComponentModelVisualIDRegistry.getVisualID(node)) {
138                        case OperationProvidedRoleEditPart.VISUAL_ID:
139                                for (Iterator it = node.getTargetEdges().iterator(); it
140                                                .hasNext();) {
141                                        Edge incomingLink = (Edge) it.next();
142                                        if (PalladioComponentModelVisualIDRegistry
143                                                        .getVisualID(incomingLink) == AssemblyConnectorEditPart.VISUAL_ID) {
144                                                DestroyElementRequest r = new DestroyElementRequest(
145                                                                incomingLink.getElement(), false);
146                                                cmd.add(new DestroyElementCommand(r));
147                                                cmd.add(new DeleteCommand(getEditingDomain(),
148                                                                incomingLink));
149                                                continue;
150                                        }
151                                        if (PalladioComponentModelVisualIDRegistry
152                                                        .getVisualID(incomingLink) == ProvidedDelegationConnectorEditPart.VISUAL_ID) {
153                                                DestroyElementRequest r = new DestroyElementRequest(
154                                                                incomingLink.getElement(), false);
155                                                cmd.add(new DestroyElementCommand(r));
156                                                cmd.add(new DeleteCommand(getEditingDomain(),
157                                                                incomingLink));
158                                                continue;
159                                        }
160                                }
161                                for (Iterator it = node.getSourceEdges().iterator(); it
162                                                .hasNext();) {
163                                        Edge outgoingLink = (Edge) it.next();
164                                        if (PalladioComponentModelVisualIDRegistry
165                                                        .getVisualID(outgoingLink) == ProvidedDelegationConnectorEditPart.VISUAL_ID) {
166                                                DestroyElementRequest r = new DestroyElementRequest(
167                                                                outgoingLink.getElement(), false);
168                                                cmd.add(new DestroyElementCommand(r));
169                                                cmd.add(new DeleteCommand(getEditingDomain(),
170                                                                outgoingLink));
171                                                continue;
172                                        }
173                                }
174                                cmd.add(new DestroyElementCommand(new DestroyElementRequest(
175                                                getEditingDomain(), node.getElement(), false))); // directlyOwned: false
176                                // don't need explicit deletion of node as parent's view deletion would clean child views as well 
177                                // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), node));
178                                break;
179                        case OperationRequiredRoleEditPart.VISUAL_ID:
180                                for (Iterator it = node.getTargetEdges().iterator(); it
181                                                .hasNext();) {
182                                        Edge incomingLink = (Edge) it.next();
183                                        if (PalladioComponentModelVisualIDRegistry
184                                                        .getVisualID(incomingLink) == RequiredDelegationConnectorEditPart.VISUAL_ID) {
185                                                DestroyElementRequest r = new DestroyElementRequest(
186                                                                incomingLink.getElement(), false);
187                                                cmd.add(new DestroyElementCommand(r));
188                                                cmd.add(new DeleteCommand(getEditingDomain(),
189                                                                incomingLink));
190                                                continue;
191                                        }
192                                }
193                                for (Iterator it = node.getSourceEdges().iterator(); it
194                                                .hasNext();) {
195                                        Edge outgoingLink = (Edge) it.next();
196                                        if (PalladioComponentModelVisualIDRegistry
197                                                        .getVisualID(outgoingLink) == AssemblyConnectorEditPart.VISUAL_ID) {
198                                                DestroyElementRequest r = new DestroyElementRequest(
199                                                                outgoingLink.getElement(), false);
200                                                cmd.add(new DestroyElementCommand(r));
201                                                cmd.add(new DeleteCommand(getEditingDomain(),
202                                                                outgoingLink));
203                                                continue;
204                                        }
205                                        if (PalladioComponentModelVisualIDRegistry
206                                                        .getVisualID(outgoingLink) == RequiredDelegationConnectorEditPart.VISUAL_ID) {
207                                                DestroyElementRequest r = new DestroyElementRequest(
208                                                                outgoingLink.getElement(), false);
209                                                cmd.add(new DestroyElementCommand(r));
210                                                cmd.add(new DeleteCommand(getEditingDomain(),
211                                                                outgoingLink));
212                                                continue;
213                                        }
214                                }
215                                cmd.add(new DestroyElementCommand(new DestroyElementRequest(
216                                                getEditingDomain(), node.getElement(), false))); // directlyOwned: false
217                                // don't need explicit deletion of node as parent's view deletion would clean child views as well 
218                                // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), node));
219                                break;
220                        case SourceRoleEditPart.VISUAL_ID:
221                                for (Iterator it = node.getSourceEdges().iterator(); it
222                                                .hasNext();) {
223                                        Edge outgoingLink = (Edge) it.next();
224                                        if (PalladioComponentModelVisualIDRegistry
225                                                        .getVisualID(outgoingLink) == AssemblyEventConnectorEditPart.VISUAL_ID) {
226                                                DestroyElementRequest r = new DestroyElementRequest(
227                                                                outgoingLink.getElement(), false);
228                                                cmd.add(new DestroyElementCommand(r));
229                                                cmd.add(new DeleteCommand(getEditingDomain(),
230                                                                outgoingLink));
231                                                continue;
232                                        }
233                                }
234                                cmd.add(new DestroyElementCommand(new DestroyElementRequest(
235                                                getEditingDomain(), node.getElement(), false))); // directlyOwned: false
236                                // don't need explicit deletion of node as parent's view deletion would clean child views as well 
237                                // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), node));
238                                break;
239                        case SinkRoleEditPart.VISUAL_ID:
240                                for (Iterator it = node.getTargetEdges().iterator(); it
241                                                .hasNext();) {
242                                        Edge incomingLink = (Edge) it.next();
243                                        if (PalladioComponentModelVisualIDRegistry
244                                                        .getVisualID(incomingLink) == AssemblyEventConnectorEditPart.VISUAL_ID) {
245                                                DestroyElementRequest r = new DestroyElementRequest(
246                                                                incomingLink.getElement(), false);
247                                                cmd.add(new DestroyElementCommand(r));
248                                                cmd.add(new DeleteCommand(getEditingDomain(),
249                                                                incomingLink));
250                                                continue;
251                                        }
252                                }
253                                cmd.add(new DestroyElementCommand(new DestroyElementRequest(
254                                                getEditingDomain(), node.getElement(), false))); // directlyOwned: false
255                                // don't need explicit deletion of node as parent's view deletion would clean child views as well 
256                                // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), node));
257                                break;
258                        case InfrastructureProvidedRoleEditPart.VISUAL_ID:
259                                for (Iterator it = node.getTargetEdges().iterator(); it
260                                                .hasNext();) {
261                                        Edge incomingLink = (Edge) it.next();
262                                        if (PalladioComponentModelVisualIDRegistry
263                                                        .getVisualID(incomingLink) == AssemblyInfrastructureConnectorEditPart.VISUAL_ID) {
264                                                DestroyElementRequest r = new DestroyElementRequest(
265                                                                incomingLink.getElement(), false);
266                                                cmd.add(new DestroyElementCommand(r));
267                                                cmd.add(new DeleteCommand(getEditingDomain(),
268                                                                incomingLink));
269                                                continue;
270                                        }
271                                }
272                                cmd.add(new DestroyElementCommand(new DestroyElementRequest(
273                                                getEditingDomain(), node.getElement(), false))); // directlyOwned: false
274                                // don't need explicit deletion of node as parent's view deletion would clean child views as well 
275                                // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), node));
276                                break;
277                        case InfrastructureRequiredRoleEditPart.VISUAL_ID:
278                                for (Iterator it = node.getSourceEdges().iterator(); it
279                                                .hasNext();) {
280                                        Edge outgoingLink = (Edge) it.next();
281                                        if (PalladioComponentModelVisualIDRegistry
282                                                        .getVisualID(outgoingLink) == AssemblyInfrastructureConnectorEditPart.VISUAL_ID) {
283                                                DestroyElementRequest r = new DestroyElementRequest(
284                                                                outgoingLink.getElement(), false);
285                                                cmd.add(new DestroyElementCommand(r));
286                                                cmd.add(new DeleteCommand(getEditingDomain(),
287                                                                outgoingLink));
288                                                continue;
289                                        }
290                                }
291                                cmd.add(new DestroyElementCommand(new DestroyElementRequest(
292                                                getEditingDomain(), node.getElement(), false))); // directlyOwned: false
293                                // don't need explicit deletion of node as parent's view deletion would clean child views as well 
294                                // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), node));
295                                break;
296                        }
297                }
298        }
299 
300}

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