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 [OperationProvidedRoleReorientCommand.java]

nameclass, %method, %block, %line, %
OperationProvidedRoleReorientCommand.java0%   (0/1)0%   (0/12)0%   (0/161)0%   (0/46)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OperationProvidedRoleReorientCommand0%   (0/1)0%   (0/12)0%   (0/161)0%   (0/46)
OperationProvidedRoleReorientCommand (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/6)
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 (): OperationProvidedRole 0%   (0/1)0%   (0/4)0%   (0/1)
getNewSource (): InterfaceProvidingEntity 0%   (0/1)0%   (0/4)0%   (0/1)
getNewTarget (): OperationInterface 0%   (0/1)0%   (0/4)0%   (0/1)
getOldSource (): InterfaceProvidingEntity 0%   (0/1)0%   (0/4)0%   (0/1)
getOldTarget (): OperationInterface 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.InterfaceProvidingEntity;
15import de.uka.ipd.sdq.pcm.gmf.repository.edit.policies.PalladioComponentModelBaseItemSemanticEditPolicy;
16import de.uka.ipd.sdq.pcm.repository.OperationInterface;
17import de.uka.ipd.sdq.pcm.repository.OperationProvidedRole;
18 
19/**
20 * @generated
21 */
22public class OperationProvidedRoleReorientCommand 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 OperationProvidedRoleReorientCommand(
43                        ReorientRelationshipRequest request) {
44                super(request.getLabel(), request.getRelationship(), request);
45                reorientDirection = request.getDirection();
46                oldEnd = request.getOldRelationshipEnd();
47                newEnd = request.getNewRelationshipEnd();
48        }
49 
50        /**
51         * @generated
52         */
53        public boolean canExecute() {
54                if (false == getElementToEdit() instanceof OperationProvidedRole) {
55                        return false;
56                }
57                if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
58                        return canReorientSource();
59                }
60                if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
61                        return canReorientTarget();
62                }
63                return false;
64        }
65 
66        /**
67         * @generated
68         */
69        protected boolean canReorientSource() {
70                if (!(oldEnd instanceof InterfaceProvidingEntity && newEnd instanceof InterfaceProvidingEntity)) {
71                        return false;
72                }
73                OperationInterface target = getLink()
74                                .getProvidedInterface__OperationProvidedRole();
75                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
76                                .canExistOperationProvidedRole_4105(getNewSource(), target);
77        }
78 
79        /**
80         * @generated
81         */
82        protected boolean canReorientTarget() {
83                if (!(oldEnd instanceof OperationInterface && newEnd instanceof OperationInterface)) {
84                        return false;
85                }
86                if (!(getLink().eContainer() instanceof InterfaceProvidingEntity)) {
87                        return false;
88                }
89                InterfaceProvidingEntity source = (InterfaceProvidingEntity) getLink()
90                                .eContainer();
91                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
92                                .canExistOperationProvidedRole_4105(source, getNewTarget());
93        }
94 
95        /**
96         * @generated
97         */
98        protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
99                        IAdaptable info) throws ExecutionException {
100                if (!canExecute()) {
101                        throw new ExecutionException(
102                                        "Invalid arguments in reorient link command"); //$NON-NLS-1$
103                }
104                if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
105                        return reorientSource();
106                }
107                if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
108                        return reorientTarget();
109                }
110                throw new IllegalStateException();
111        }
112 
113        /**
114         * @generated
115         */
116        protected CommandResult reorientSource() throws ExecutionException {
117                getOldSource().getProvidedRoles_InterfaceProvidingEntity().remove(
118                                getLink());
119                getNewSource().getProvidedRoles_InterfaceProvidingEntity().add(
120                                getLink());
121                return CommandResult.newOKCommandResult(getLink());
122        }
123 
124        /**
125         * @generated
126         */
127        protected CommandResult reorientTarget() throws ExecutionException {
128                getLink().setProvidedInterface__OperationProvidedRole(getNewTarget());
129                return CommandResult.newOKCommandResult(getLink());
130        }
131 
132        /**
133         * @generated
134         */
135        protected OperationProvidedRole getLink() {
136                return (OperationProvidedRole) getElementToEdit();
137        }
138 
139        /**
140         * @generated
141         */
142        protected InterfaceProvidingEntity getOldSource() {
143                return (InterfaceProvidingEntity) oldEnd;
144        }
145 
146        /**
147         * @generated
148         */
149        protected InterfaceProvidingEntity getNewSource() {
150                return (InterfaceProvidingEntity) newEnd;
151        }
152 
153        /**
154         * @generated
155         */
156        protected OperationInterface getOldTarget() {
157                return (OperationInterface) oldEnd;
158        }
159 
160        /**
161         * @generated
162         */
163        protected OperationInterface getNewTarget() {
164                return (OperationInterface) newEnd;
165        }
166}

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