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

COVERAGE SUMMARY FOR SOURCE FILE [LinkingResource2ItemSemanticEditPolicy.java]

nameclass, %method, %block, %line, %
LinkingResource2ItemSemanticEditPolicy.java0%   (0/1)0%   (0/7)0%   (0/202)0%   (0/51)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LinkingResource2ItemSemanticEditPolicy0%   (0/1)0%   (0/7)0%   (0/202)0%   (0/51)
LinkingResource2ItemSemanticEditPolicy (): 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/8)0%   (0/4)
getCreateRelationshipCommand (CreateRelationshipRequest): Command 0%   (0/1)0%   (0/19)0%   (0/4)
getDestroyElementCommand (DestroyElementRequest): Command 0%   (0/1)0%   (0/90)0%   (0/20)
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 2009, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.resource.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.CreateRelationshipRequest;
16import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
17import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
18import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
19import org.eclipse.gmf.runtime.notation.Edge;
20import org.eclipse.gmf.runtime.notation.Node;
21import org.eclipse.gmf.runtime.notation.View;
22 
23import de.uka.ipd.sdq.pcm.gmf.resource.edit.commands.LinkingResourceConnectedResourceContainers_LinkingResourceCreateCommand;
24import de.uka.ipd.sdq.pcm.gmf.resource.edit.commands.LinkingResourceConnectedResourceContainers_LinkingResourceReorientCommand;
25import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.CommunicationLinkResourceSpecificationEditPart;
26import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.LinkingResourceConnectedResourceContainers_LinkingResourceEditPart;
27import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.LinkingResourceNetworkSwitchCompartmentEditPart;
28import de.uka.ipd.sdq.pcm.gmf.resource.part.PalladioComponentModelVisualIDRegistry;
29import de.uka.ipd.sdq.pcm.gmf.resource.providers.PalladioComponentModelElementTypes;
30 
31/**
32 * @generated
33 */
34public class LinkingResource2ItemSemanticEditPolicy extends
35                PalladioComponentModelBaseItemSemanticEditPolicy {
36 
37        /**
38         * @generated
39         */
40        public LinkingResource2ItemSemanticEditPolicy() {
41                super(PalladioComponentModelElementTypes.LinkingResource_2003);
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.getSourceEdges().iterator(); it.hasNext();) {
53                        Edge outgoingLink = (Edge) it.next();
54                        if (PalladioComponentModelVisualIDRegistry
55                                        .getVisualID(outgoingLink) == LinkingResourceConnectedResourceContainers_LinkingResourceEditPart.VISUAL_ID) {
56                                DestroyReferenceRequest r = new DestroyReferenceRequest(
57                                                outgoingLink.getSource().getElement(), null,
58                                                outgoingLink.getTarget().getElement(), false);
59                                cmd.add(new DestroyReferenceCommand(r));
60                                cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
61                                continue;
62                        }
63                }
64                EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
65                if (annotation == null) {
66                        // there are indirectly referenced children, need extra commands: false
67                        addDestroyChildNodesCommand(cmd);
68                        addDestroyShortcutsCommand(cmd, view);
69                        // delete host element
70                        cmd.add(new DestroyElementCommand(req));
71                } else {
72                        cmd.add(new DeleteCommand(getEditingDomain(), view));
73                }
74                return getGEFWrapper(cmd.reduce());
75        }
76 
77        /**
78         * @generated
79         */
80        private void addDestroyChildNodesCommand(ICompositeCommand cmd) {
81                View view = (View) getHost().getModel();
82                for (Iterator nit = view.getChildren().iterator(); nit.hasNext();) {
83                        Node node = (Node) nit.next();
84                        switch (PalladioComponentModelVisualIDRegistry.getVisualID(node)) {
85                        case LinkingResourceNetworkSwitchCompartmentEditPart.VISUAL_ID:
86                                for (Iterator cit = node.getChildren().iterator(); cit
87                                                .hasNext();) {
88                                        Node cnode = (Node) cit.next();
89                                        switch (PalladioComponentModelVisualIDRegistry
90                                                        .getVisualID(cnode)) {
91                                        case CommunicationLinkResourceSpecificationEditPart.VISUAL_ID:
92                                                cmd.add(new DestroyElementCommand(
93                                                                new DestroyElementRequest(getEditingDomain(),
94                                                                                cnode.getElement(), false))); // directlyOwned: true
95                                                // don't need explicit deletion of cnode as parent's view deletion would clean child views as well 
96                                                // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
97                                                break;
98                                        }
99                                }
100                                break;
101                        }
102                }
103        }
104 
105        /**
106         * @generated
107         */
108        protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
109                Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req)
110                                : getCompleteCreateRelationshipCommand(req);
111                return command != null ? command : super
112                                .getCreateRelationshipCommand(req);
113        }
114 
115        /**
116         * @generated
117         */
118        protected Command getStartCreateRelationshipCommand(
119                        CreateRelationshipRequest req) {
120                if (PalladioComponentModelElementTypes.LinkingResourceConnectedResourceContainers_LinkingResource_4002 == req
121                                .getElementType()) {
122                        return getGEFWrapper(new LinkingResourceConnectedResourceContainers_LinkingResourceCreateCommand(
123                                        req, req.getSource(), req.getTarget()));
124                }
125                return null;
126        }
127 
128        /**
129         * @generated
130         */
131        protected Command getCompleteCreateRelationshipCommand(
132                        CreateRelationshipRequest req) {
133                if (PalladioComponentModelElementTypes.LinkingResourceConnectedResourceContainers_LinkingResource_4002 == req
134                                .getElementType()) {
135                        return null;
136                }
137                return null;
138        }
139 
140        /**
141         * Returns command to reorient EReference based link. New link target or source
142         * should be the domain model element associated with this node.
143         * 
144         * @generated
145         */
146        protected Command getReorientReferenceRelationshipCommand(
147                        ReorientReferenceRelationshipRequest req) {
148                switch (getVisualID(req)) {
149                case LinkingResourceConnectedResourceContainers_LinkingResourceEditPart.VISUAL_ID:
150                        return getGEFWrapper(new LinkingResourceConnectedResourceContainers_LinkingResourceReorientCommand(
151                                        req));
152                }
153                return super.getReorientReferenceRelationshipCommand(req);
154        }
155 
156}

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