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

nameclass, %method, %block, %line, %
ImplementationComponentTypeParentCompleteComponentTypesReorientCommand.java0%   (0/1)0%   (0/11)0%   (0/155)0%   (0/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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