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

COVERAGE SUMMARY FOR SOURCE FILE [AssemblyEventConnectorReorientCommand.java]

nameclass, %method, %block, %line, %
AssemblyEventConnectorReorientCommand.java0%   (0/1)0%   (0/12)0%   (0/170)0%   (0/49)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AssemblyEventConnectorReorientCommand0%   (0/1)0%   (0/12)0%   (0/170)0%   (0/49)
AssemblyEventConnectorReorientCommand (ReorientRelationshipRequest): void 0%   (0/1)0%   (0/20)0%   (0/5)
canExecute (): boolean 0%   (0/1)0%   (0/22)0%   (0/7)
canReorientSource (): boolean 0%   (0/1)0%   (0/32)0%   (0/10)
canReorientTarget (): boolean 0%   (0/1)0%   (0/32)0%   (0/10)
doExecuteWithResult (IProgressMonitor, IAdaptable): CommandResult 0%   (0/1)0%   (0/26)0%   (0/8)
getLink (): AssemblyEventConnector 0%   (0/1)0%   (0/4)0%   (0/1)
getNewSource (): SourceRole 0%   (0/1)0%   (0/4)0%   (0/1)
getNewTarget (): SinkRole 0%   (0/1)0%   (0/4)0%   (0/1)
getOldSource (): SourceRole 0%   (0/1)0%   (0/4)0%   (0/1)
getOldTarget (): SinkRole 0%   (0/1)0%   (0/4)0%   (0/1)
reorientSource (): CommandResult 0%   (0/1)0%   (0/9)0%   (0/2)
reorientTarget (): CommandResult 0%   (0/1)0%   (0/9)0%   (0/2)

1/*
2 * Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.composite.edit.commands;
5 
6import org.eclipse.core.commands.ExecutionException;
7import org.eclipse.core.runtime.IAdaptable;
8import org.eclipse.core.runtime.IProgressMonitor;
9import org.eclipse.emf.ecore.EObject;
10import org.eclipse.gmf.runtime.common.core.command.CommandResult;
11import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
12import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
13 
14import de.uka.ipd.sdq.pcm.core.composition.AssemblyEventConnector;
15import de.uka.ipd.sdq.pcm.core.composition.ComposedStructure;
16import de.uka.ipd.sdq.pcm.gmf.composite.edit.policies.PalladioComponentModelBaseItemSemanticEditPolicy;
17import de.uka.ipd.sdq.pcm.repository.SinkRole;
18import de.uka.ipd.sdq.pcm.repository.SourceRole;
19 
20/**
21 * @generated
22 */
23public class AssemblyEventConnectorReorientCommand extends EditElementCommand {
24 
25        /**
26         * @generated
27         */
28        private final int reorientDirection;
29 
30        /**
31         * @generated
32         */
33        private final EObject oldEnd;
34 
35        /**
36         * @generated
37         */
38        private final EObject newEnd;
39 
40        /**
41         * @generated
42         */
43        public AssemblyEventConnectorReorientCommand(
44                        ReorientRelationshipRequest request) {
45                super(request.getLabel(), request.getRelationship(), request);
46                reorientDirection = request.getDirection();
47                oldEnd = request.getOldRelationshipEnd();
48                newEnd = request.getNewRelationshipEnd();
49        }
50 
51        /**
52         * @generated
53         */
54        public boolean canExecute() {
55                if (false == getElementToEdit() instanceof AssemblyEventConnector) {
56                        return false;
57                }
58                if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
59                        return canReorientSource();
60                }
61                if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
62                        return canReorientTarget();
63                }
64                return false;
65        }
66 
67        /**
68         * @generated
69         */
70        protected boolean canReorientSource() {
71                if (!(oldEnd instanceof SourceRole && newEnd instanceof SourceRole)) {
72                        return false;
73                }
74                SinkRole target = getLink().getSinkRole__AssemblyEventConnector();
75                if (!(getLink().eContainer() instanceof ComposedStructure)) {
76                        return false;
77                }
78                ComposedStructure container = (ComposedStructure) getLink()
79                                .eContainer();
80                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
81                                .canExistAssemblyEventConnector_4007(container, getNewSource(),
82                                                target);
83        }
84 
85        /**
86         * @generated
87         */
88        protected boolean canReorientTarget() {
89                if (!(oldEnd instanceof SinkRole && newEnd instanceof SinkRole)) {
90                        return false;
91                }
92                SourceRole source = getLink().getSourceRole__AssemblyEventConnector();
93                if (!(getLink().eContainer() instanceof ComposedStructure)) {
94                        return false;
95                }
96                ComposedStructure container = (ComposedStructure) getLink()
97                                .eContainer();
98                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
99                                .canExistAssemblyEventConnector_4007(container, source,
100                                                getNewTarget());
101        }
102 
103        /**
104         * @generated
105         */
106        protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
107                        IAdaptable info) throws ExecutionException {
108                if (!canExecute()) {
109                        throw new ExecutionException(
110                                        "Invalid arguments in reorient link command"); //$NON-NLS-1$
111                }
112                if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
113                        return reorientSource();
114                }
115                if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
116                        return reorientTarget();
117                }
118                throw new IllegalStateException();
119        }
120 
121        /**
122         * @generated
123         */
124        protected CommandResult reorientSource() throws ExecutionException {
125                getLink().setSourceRole__AssemblyEventConnector(getNewSource());
126                return CommandResult.newOKCommandResult(getLink());
127        }
128 
129        /**
130         * @generated
131         */
132        protected CommandResult reorientTarget() throws ExecutionException {
133                getLink().setSinkRole__AssemblyEventConnector(getNewTarget());
134                return CommandResult.newOKCommandResult(getLink());
135        }
136 
137        /**
138         * @generated
139         */
140        protected AssemblyEventConnector getLink() {
141                return (AssemblyEventConnector) getElementToEdit();
142        }
143 
144        /**
145         * @generated
146         */
147        protected SourceRole getOldSource() {
148                return (SourceRole) oldEnd;
149        }
150 
151        /**
152         * @generated
153         */
154        protected SourceRole getNewSource() {
155                return (SourceRole) newEnd;
156        }
157 
158        /**
159         * @generated
160         */
161        protected SinkRole getOldTarget() {
162                return (SinkRole) oldEnd;
163        }
164 
165        /**
166         * @generated
167         */
168        protected SinkRole getNewTarget() {
169                return (SinkRole) newEnd;
170        }
171}

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