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

COVERAGE SUMMARY FOR SOURCE FILE [SourceRoleReorientCommand.java]

nameclass, %method, %block, %line, %
SourceRoleReorientCommand.java0%   (0/1)0%   (0/12)0%   (0/161)0%   (0/45)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SourceRoleReorientCommand0%   (0/1)0%   (0/12)0%   (0/161)0%   (0/45)
SourceRoleReorientCommand (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/19)0%   (0/5)
canReorientTarget (): boolean 0%   (0/1)0%   (0/27)0%   (0/8)
doExecuteWithResult (IProgressMonitor, IAdaptable): CommandResult 0%   (0/1)0%   (0/26)0%   (0/8)
getLink (): SourceRole 0%   (0/1)0%   (0/4)0%   (0/1)
getNewSource (): InterfaceRequiringEntity 0%   (0/1)0%   (0/4)0%   (0/1)
getNewTarget (): EventGroup 0%   (0/1)0%   (0/4)0%   (0/1)
getOldSource (): InterfaceRequiringEntity 0%   (0/1)0%   (0/4)0%   (0/1)
getOldTarget (): EventGroup 0%   (0/1)0%   (0/4)0%   (0/1)
reorientSource (): CommandResult 0%   (0/1)0%   (0/18)0%   (0/5)
reorientTarget (): CommandResult 0%   (0/1)0%   (0/9)0%   (0/2)

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

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