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

nameclass, %method, %block, %line, %
AssemblyConnectorReorientCommand.java0%   (0/1)0%   (0/12)0%   (0/194)0%   (0/63)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AssemblyConnectorReorientCommand0%   (0/1)0%   (0/12)0%   (0/194)0%   (0/63)
AssemblyConnectorReorientCommand (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/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 (): AssemblyConnector 0%   (0/1)0%   (0/4)0%   (0/1)
getNewSource (): OperationRequiredRole 0%   (0/1)0%   (0/4)0%   (0/1)
getNewTarget (): OperationProvidedRole 0%   (0/1)0%   (0/4)0%   (0/1)
getOldSource (): OperationRequiredRole 0%   (0/1)0%   (0/4)0%   (0/1)
getOldTarget (): OperationProvidedRole 0%   (0/1)0%   (0/4)0%   (0/1)
reorientSource (): CommandResult 0%   (0/1)0%   (0/21)0%   (0/8)
reorientTarget (): CommandResult 0%   (0/1)0%   (0/21)0%   (0/8)

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;
13import org.eclipse.swt.SWT;
14import org.eclipse.swt.widgets.MessageBox;
15import org.eclipse.swt.widgets.Shell;
16import org.eclipse.ui.PlatformUI;
17 
18import de.uka.ipd.sdq.pcm.core.composition.AssemblyConnector;
19import de.uka.ipd.sdq.pcm.core.composition.ComposedStructure;
20import de.uka.ipd.sdq.pcm.gmf.composite.edit.policies.PalladioComponentModelBaseItemSemanticEditPolicy;
21import de.uka.ipd.sdq.pcm.repository.OperationProvidedRole;
22import de.uka.ipd.sdq.pcm.repository.OperationRequiredRole;
23 
24/**
25 * 
26 * @author Christian Busch
27 * @generated
28 */
29public class AssemblyConnectorReorientCommand extends EditElementCommand {
30 
31        /**
32         * @generated
33         */
34        private final int reorientDirection;
35 
36        /**
37         * @generated
38         */
39        private final EObject oldEnd;
40 
41        /**
42         * @generated
43         */
44        private final EObject newEnd;
45 
46        /**
47         * @generated
48         */
49        public AssemblyConnectorReorientCommand(ReorientRelationshipRequest request) {
50                super(request.getLabel(), request.getRelationship(), request);
51                reorientDirection = request.getDirection();
52                oldEnd = request.getOldRelationshipEnd();
53                newEnd = request.getNewRelationshipEnd();
54        }
55 
56        /**
57         * @generated
58         */
59        public boolean canExecute() {
60                if (false == getElementToEdit() instanceof AssemblyConnector) {
61                        return false;
62                }
63                if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
64                        return canReorientSource();
65                }
66                if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
67                        return canReorientTarget();
68                }
69                return false;
70        }
71 
72        /**
73         * @generated
74         */
75        protected boolean canReorientSource() {
76                if (!(oldEnd instanceof OperationRequiredRole && newEnd instanceof OperationRequiredRole)) {
77                        return false;
78                }
79                OperationProvidedRole target = getLink()
80                                .getProvidedRole_AssemblyConnector();
81                if (!(getLink().eContainer() instanceof ComposedStructure)) {
82                        return false;
83                }
84                ComposedStructure container = (ComposedStructure) getLink()
85                                .eContainer();
86                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
87                                .canExistAssemblyConnector_4004(container, getNewSource(),
88                                                target);
89        }
90 
91        /**
92         * @generated
93         */
94        protected boolean canReorientTarget() {
95                if (!(oldEnd instanceof OperationProvidedRole && newEnd instanceof OperationProvidedRole)) {
96                        return false;
97                }
98                OperationRequiredRole source = getLink()
99                                .getRequiredRole_AssemblyConnector();
100                if (!(getLink().eContainer() instanceof ComposedStructure)) {
101                        return false;
102                }
103                ComposedStructure container = (ComposedStructure) getLink()
104                                .eContainer();
105                return PalladioComponentModelBaseItemSemanticEditPolicy.LinkConstraints
106                                .canExistAssemblyConnector_4004(container, source,
107                                                getNewTarget());
108        }
109 
110        /**
111         * @generated
112         */
113        protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
114                        IAdaptable info) throws ExecutionException {
115                if (!canExecute()) {
116                        throw new ExecutionException(
117                                        "Invalid arguments in reorient link command"); //$NON-NLS-1$
118                }
119                if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
120                        return reorientSource();
121                }
122                if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
123                        return reorientTarget();
124                }
125                throw new IllegalStateException();
126        }
127 
128        /**
129         * @generated NOT
130         */
131        protected CommandResult reorientSource() throws ExecutionException {
132                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
133                                .getShell();
134                MessageBox messageBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
135                messageBox.setText("Notice");
136                messageBox
137                                .setMessage("Please delete the link and create a new one instead of reorienting it.");
138                messageBox.open();
139                return CommandResult.newCancelledCommandResult();
140        }
141 
142        /**
143         * @generated NOT
144         */
145        protected CommandResult reorientTarget() throws ExecutionException {
146                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
147                                .getShell();
148                MessageBox messageBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
149                messageBox.setText("Notice");
150                messageBox
151                                .setMessage("Please delete the link and create a new one instead of reorienting it.");
152                messageBox.open();
153                return CommandResult.newCancelledCommandResult();
154        }
155 
156        /**
157         * @generated
158         */
159        protected AssemblyConnector getLink() {
160                return (AssemblyConnector) getElementToEdit();
161        }
162 
163        /**
164         * @generated
165         */
166        protected OperationRequiredRole getOldSource() {
167                return (OperationRequiredRole) oldEnd;
168        }
169 
170        /**
171         * @generated
172         */
173        protected OperationRequiredRole getNewSource() {
174                return (OperationRequiredRole) newEnd;
175        }
176 
177        /**
178         * @generated
179         */
180        protected OperationProvidedRole getOldTarget() {
181                return (OperationProvidedRole) oldEnd;
182        }
183 
184        /**
185         * @generated
186         */
187        protected OperationProvidedRole getNewTarget() {
188                return (OperationProvidedRole) newEnd;
189        }
190}

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