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

COVERAGE SUMMARY FOR SOURCE FILE [LoopItemSemanticEditPolicy.java]

nameclass, %method, %block, %line, %
LoopItemSemanticEditPolicy.java0%   (0/1)0%   (0/8)0%   (0/253)0%   (0/60)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LoopItemSemanticEditPolicy0%   (0/1)0%   (0/8)0%   (0/253)0%   (0/60)
LoopItemSemanticEditPolicy (): void 0%   (0/1)0%   (0/4)0%   (0/2)
addDestroyChildNodesCommand (ICompositeCommand): void 0%   (0/1)0%   (0/34)0%   (0/7)
getCompleteCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/17)0%   (0/5)
getCreateCommand (CreateElementRequest): Command 0%   (0/1)0%   (0/15)0%   (0/4)
getCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/19)0%   (0/4)
getDestroyElementCommand (DestroyElementRequest): Command 0%   (0/1)0%   (0/132)0%   (0/29)
getReorientReferenceRelationshipCommand (ReorientReferenceRelationshipRequest... 0%   (0/1)0%   (0/15)0%   (0/4)
getStartCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/17)0%   (0/5)

1/*
2 * Copyright 2007, SDQ, IPD, University of Karlsruhe
3 */
4package de.uka.ipd.sdq.pcm.gmf.usage.edit.policies;
5 
6import java.util.Iterator;
7 
8import org.eclipse.emf.ecore.EAnnotation;
9import org.eclipse.gef.commands.Command;
10import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
11import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
12import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
13import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
14import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand;
15import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
16import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
17import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
18import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
19import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
20import org.eclipse.gmf.runtime.notation.Edge;
21import org.eclipse.gmf.runtime.notation.Node;
22import org.eclipse.gmf.runtime.notation.View;
23 
24import de.uka.ipd.sdq.pcm.gmf.usage.edit.commands.AbstractUserActionSuccessorCreateCommand;
25import de.uka.ipd.sdq.pcm.gmf.usage.edit.commands.AbstractUserActionSuccessorReorientCommand;
26import de.uka.ipd.sdq.pcm.gmf.usage.edit.commands.ScenarioBehaviour2CreateCommand;
27import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.AbstractUserActionSuccessorEditPart;
28import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.ScenarioBehaviour2EditPart;
29import de.uka.ipd.sdq.pcm.gmf.usage.part.PalladioComponentModelVisualIDRegistry;
30import de.uka.ipd.sdq.pcm.gmf.usage.providers.PalladioComponentModelElementTypes;
31 
32/**
33 * @generated
34 */
35public class LoopItemSemanticEditPolicy extends
36                PalladioComponentModelBaseItemSemanticEditPolicy {
37 
38        /**
39         * @generated
40         */
41        public LoopItemSemanticEditPolicy() {
42                super(PalladioComponentModelElementTypes.Loop_3005);
43        }
44 
45        /**
46         * @generated
47         */
48        protected Command getCreateCommand(CreateElementRequest req) {
49                if (PalladioComponentModelElementTypes.ScenarioBehaviour_3007 == req
50                                .getElementType()) {
51                        return getGEFWrapper(new ScenarioBehaviour2CreateCommand(req));
52                }
53                return super.getCreateCommand(req);
54        }
55 
56        /**
57         * @generated
58         */
59        protected Command getDestroyElementCommand(DestroyElementRequest req) {
60                View view = (View) getHost().getModel();
61                CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
62                                getEditingDomain(), null);
63                cmd.setTransactionNestingEnabled(false);
64                for (Iterator it = view.getTargetEdges().iterator(); it.hasNext();) {
65                        Edge incomingLink = (Edge) it.next();
66                        if (PalladioComponentModelVisualIDRegistry
67                                        .getVisualID(incomingLink) == AbstractUserActionSuccessorEditPart.VISUAL_ID) {
68                                DestroyReferenceRequest r = new DestroyReferenceRequest(
69                                                incomingLink.getSource().getElement(), null,
70                                                incomingLink.getTarget().getElement(), false);
71                                cmd.add(new DestroyReferenceCommand(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) == AbstractUserActionSuccessorEditPart.VISUAL_ID) {
80                                DestroyReferenceRequest r = new DestroyReferenceRequest(
81                                                outgoingLink.getSource().getElement(), null,
82                                                outgoingLink.getTarget().getElement(), false);
83                                cmd.add(new DestroyReferenceCommand(r));
84                                cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
85                                continue;
86                        }
87                }
88                EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
89                if (annotation == null) {
90                        // there are indirectly referenced children, need extra commands: false
91                        addDestroyChildNodesCommand(cmd);
92                        addDestroyShortcutsCommand(cmd, view);
93                        // delete host element
94                        cmd.add(new DestroyElementCommand(req));
95                } else {
96                        cmd.add(new DeleteCommand(getEditingDomain(), view));
97                }
98                return getGEFWrapper(cmd.reduce());
99        }
100 
101        /**
102         * @generated
103         */
104        private void addDestroyChildNodesCommand(ICompositeCommand cmd) {
105                View view = (View) getHost().getModel();
106                for (Iterator nit = view.getChildren().iterator(); nit.hasNext();) {
107                        Node node = (Node) nit.next();
108                        switch (PalladioComponentModelVisualIDRegistry.getVisualID(node)) {
109                        case ScenarioBehaviour2EditPart.VISUAL_ID:
110                                cmd.add(new DestroyElementCommand(new DestroyElementRequest(
111                                                getEditingDomain(), node.getElement(), false))); // directlyOwned: true
112                                // don't need explicit deletion of node as parent's view deletion would clean child views as well 
113                                // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), node));
114                                break;
115                        }
116                }
117        }
118 
119        /**
120         * @generated
121         */
122        protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
123                Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req)
124                                : getCompleteCreateRelationshipCommand(req);
125                return command != null ? command : super
126                                .getCreateRelationshipCommand(req);
127        }
128 
129        /**
130         * @generated
131         */
132        protected Command getStartCreateRelationshipCommand(
133                        CreateRelationshipRequest req) {
134                if (PalladioComponentModelElementTypes.AbstractUserActionSuccessor_4002 == req
135                                .getElementType()) {
136                        return getGEFWrapper(new AbstractUserActionSuccessorCreateCommand(
137                                        req, req.getSource(), req.getTarget()));
138                }
139                return null;
140        }
141 
142        /**
143         * @generated
144         */
145        protected Command getCompleteCreateRelationshipCommand(
146                        CreateRelationshipRequest req) {
147                if (PalladioComponentModelElementTypes.AbstractUserActionSuccessor_4002 == req
148                                .getElementType()) {
149                        return getGEFWrapper(new AbstractUserActionSuccessorCreateCommand(
150                                        req, req.getSource(), req.getTarget()));
151                }
152                return null;
153        }
154 
155        /**
156         * Returns command to reorient EReference based link. New link target or source
157         * should be the domain model element associated with this node.
158         * 
159         * @generated
160         */
161        protected Command getReorientReferenceRelationshipCommand(
162                        ReorientReferenceRelationshipRequest req) {
163                switch (getVisualID(req)) {
164                case AbstractUserActionSuccessorEditPart.VISUAL_ID:
165                        return getGEFWrapper(new AbstractUserActionSuccessorReorientCommand(
166                                        req));
167                }
168                return super.getReorientReferenceRelationshipCommand(req);
169        }
170 
171}

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