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

COVERAGE SUMMARY FOR SOURCE FILE [LinkingResourceConnectedResourceContainers_LinkingResourceReorientCommand.java]

nameclass, %method, %block, %line, %
LinkingResourceConnectedResourceContainers_LinkingResourceReorientCommand.java0%   (0/1)0%   (0/11)0%   (0/155)0%   (0/45)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LinkingResourceConnectedResourceContainers_LinkingResourceReorientCommand0%   (0/1)0%   (0/11)0%   (0/155)0%   (0/45)
LinkingResourceConnectedResourceContainers_LinkingResourceReorientCommand (Re... 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 (): LinkingResource 0%   (0/1)0%   (0/4)0%   (0/1)
getNewTarget (): ResourceContainer 0%   (0/1)0%   (0/4)0%   (0/1)
getOldSource (): LinkingResource 0%   (0/1)0%   (0/4)0%   (0/1)
getOldTarget (): ResourceContainer 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/18)0%   (0/5)

1/*
2 * Copyright 2009, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.resource.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.resource.edit.policies.PalladioComponentModelBaseItemSemanticEditPolicy;
16import de.uka.ipd.sdq.pcm.resourceenvironment.LinkingResource;
17import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer;
18 
19/**
20 * @generated
21 */
22public class LinkingResourceConnectedResourceContainers_LinkingResourceReorientCommand
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 LinkingResourceConnectedResourceContainers_LinkingResourceReorientCommand(
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 LinkingResource) {
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 ResourceContainer && newEnd instanceof LinkingResource)) {
78                        return false;
79                }
80                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
81                                .canExistLinkingResourceConnectedResourceContainers_LinkingResource_4002(
82                                                getNewSource(), getOldTarget());
83        }
84 
85        /**
86         * @generated
87         */
88        protected boolean canReorientTarget() {
89                if (!(oldEnd instanceof ResourceContainer && newEnd instanceof ResourceContainer)) {
90                        return false;
91                }
92                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
93                                .canExistLinkingResourceConnectedResourceContainers_LinkingResource_4002(
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().getConnectedResourceContainers_LinkingResource().remove(
120                                getOldTarget());
121                getNewSource().getConnectedResourceContainers_LinkingResource().add(
122                                getOldTarget());
123                return CommandResult.newOKCommandResult(referenceOwner);
124        }
125 
126        /**
127         * @generated
128         */
129        protected CommandResult reorientTarget() throws ExecutionException {
130                getOldSource().getConnectedResourceContainers_LinkingResource().remove(
131                                getOldTarget());
132                getOldSource().getConnectedResourceContainers_LinkingResource().add(
133                                getNewTarget());
134                return CommandResult.newOKCommandResult(referenceOwner);
135        }
136 
137        /**
138         * @generated
139         */
140        protected LinkingResource getOldSource() {
141                return (LinkingResource) referenceOwner;
142        }
143 
144        /**
145         * @generated
146         */
147        protected LinkingResource getNewSource() {
148                return (LinkingResource) newEnd;
149        }
150 
151        /**
152         * @generated
153         */
154        protected ResourceContainer getOldTarget() {
155                return (ResourceContainer) oldEnd;
156        }
157 
158        /**
159         * @generated
160         */
161        protected ResourceContainer getNewTarget() {
162                return (ResourceContainer) newEnd;
163        }
164}

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