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

nameclass, %method, %block, %line, %
InfrastructureRequiredRoleReorientCommand.java0%   (0/1)0%   (0/12)0%   (0/161)0%   (0/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InfrastructureRequiredRoleReorientCommand0%   (0/1)0%   (0/12)0%   (0/161)0%   (0/47)
InfrastructureRequiredRoleReorientCommand (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 (): InfrastructureRequiredRole 0%   (0/1)0%   (0/4)0%   (0/1)
getNewSource (): InterfaceRequiringEntity 0%   (0/1)0%   (0/4)0%   (0/1)
getNewTarget (): InfrastructureInterface 0%   (0/1)0%   (0/4)0%   (0/1)
getOldSource (): InterfaceRequiringEntity 0%   (0/1)0%   (0/4)0%   (0/1)
getOldTarget (): InfrastructureInterface 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/3)

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.InfrastructureInterface;
17import de.uka.ipd.sdq.pcm.repository.InfrastructureRequiredRole;
18 
19/**
20 * @generated
21 */
22public class InfrastructureRequiredRoleReorientCommand extends
23                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 InfrastructureRequiredRoleReorientCommand(
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 InfrastructureRequiredRole) {
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 InterfaceRequiringEntity && newEnd instanceof InterfaceRequiringEntity)) {
72                        return false;
73                }
74                InfrastructureInterface target = getLink()
75                                .getRequiredInterface__InfrastructureRequiredRole();
76                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
77                                .canExistInfrastructureRequiredRole_4112(getNewSource(), target);
78        }
79 
80        /**
81         * @generated
82         */
83        protected boolean canReorientTarget() {
84                if (!(oldEnd instanceof InfrastructureInterface && newEnd instanceof InfrastructureInterface)) {
85                        return false;
86                }
87                if (!(getLink().eContainer() instanceof InterfaceRequiringEntity)) {
88                        return false;
89                }
90                InterfaceRequiringEntity source = (InterfaceRequiringEntity) getLink()
91                                .eContainer();
92                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
93                                .canExistInfrastructureRequiredRole_4112(source, getNewTarget());
94        }
95 
96        /**
97         * @generated
98         */
99        protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
100                        IAdaptable info) throws ExecutionException {
101                if (!canExecute()) {
102                        throw new ExecutionException(
103                                        "Invalid arguments in reorient link command"); //$NON-NLS-1$
104                }
105                if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
106                        return reorientSource();
107                }
108                if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
109                        return reorientTarget();
110                }
111                throw new IllegalStateException();
112        }
113 
114        /**
115         * @generated
116         */
117        protected CommandResult reorientSource() throws ExecutionException {
118                getOldSource().getRequiredRoles_InterfaceRequiringEntity().remove(
119                                getLink());
120                getNewSource().getRequiredRoles_InterfaceRequiringEntity().add(
121                                getLink());
122                return CommandResult.newOKCommandResult(getLink());
123        }
124 
125        /**
126         * @generated
127         */
128        protected CommandResult reorientTarget() throws ExecutionException {
129                getLink().setRequiredInterface__InfrastructureRequiredRole(
130                                getNewTarget());
131                return CommandResult.newOKCommandResult(getLink());
132        }
133 
134        /**
135         * @generated
136         */
137        protected InfrastructureRequiredRole getLink() {
138                return (InfrastructureRequiredRole) getElementToEdit();
139        }
140 
141        /**
142         * @generated
143         */
144        protected InterfaceRequiringEntity getOldSource() {
145                return (InterfaceRequiringEntity) oldEnd;
146        }
147 
148        /**
149         * @generated
150         */
151        protected InterfaceRequiringEntity getNewSource() {
152                return (InterfaceRequiringEntity) newEnd;
153        }
154 
155        /**
156         * @generated
157         */
158        protected InfrastructureInterface getOldTarget() {
159                return (InfrastructureInterface) oldEnd;
160        }
161 
162        /**
163         * @generated
164         */
165        protected InfrastructureInterface getNewTarget() {
166                return (InfrastructureInterface) newEnd;
167        }
168}

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