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

COVERAGE SUMMARY FOR SOURCE FILE [EventGroupItemSemanticEditPolicy.java]

nameclass, %method, %block, %line, %
EventGroupItemSemanticEditPolicy.java0%   (0/1)0%   (0/7)0%   (0/251)0%   (0/64)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EventGroupItemSemanticEditPolicy0%   (0/1)0%   (0/7)0%   (0/251)0%   (0/64)
EventGroupItemSemanticEditPolicy (): void 0%   (0/1)0%   (0/4)0%   (0/2)
addDestroyChildNodesCommand (ICompositeCommand): void 0%   (0/1)0%   (0/49)0%   (0/12)
getCompleteCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/32)0%   (0/9)
getCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/19)0%   (0/4)
getDestroyElementCommand (DestroyElementRequest): Command 0%   (0/1)0%   (0/111)0%   (0/26)
getReorientRelationshipCommand (ReorientRelationshipRequest): Command 0%   (0/1)0%   (0/22)0%   (0/4)
getStartCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/14)0%   (0/7)

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

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