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

nameclass, %method, %block, %line, %
AssemblyInfrastructureConnectorReorientCommand.java0%   (0/1)0%   (0/12)0%   (0/170)0%   (0/53)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AssemblyInfrastructureConnectorReorientCommand0%   (0/1)0%   (0/12)0%   (0/170)0%   (0/53)
AssemblyInfrastructureConnectorReorientCommand (ReorientRelationshipRequest):... 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/11)
canReorientTarget (): boolean 0%   (0/1)0%   (0/32)0%   (0/11)
doExecuteWithResult (IProgressMonitor, IAdaptable): CommandResult 0%   (0/1)0%   (0/26)0%   (0/8)
getLink (): AssemblyInfrastructureConnector 0%   (0/1)0%   (0/4)0%   (0/1)
getNewSource (): InfrastructureRequiredRole 0%   (0/1)0%   (0/4)0%   (0/1)
getNewTarget (): InfrastructureProvidedRole 0%   (0/1)0%   (0/4)0%   (0/1)
getOldSource (): InfrastructureRequiredRole 0%   (0/1)0%   (0/4)0%   (0/1)
getOldTarget (): InfrastructureProvidedRole 0%   (0/1)0%   (0/4)0%   (0/1)
reorientSource (): CommandResult 0%   (0/1)0%   (0/9)0%   (0/3)
reorientTarget (): CommandResult 0%   (0/1)0%   (0/9)0%   (0/3)

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

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