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

COVERAGE SUMMARY FOR SOURCE FILE [InfrastructureCallConfigureCommand.java]

nameclass, %method, %block, %line, %
InfrastructureCallConfigureCommand.java0%   (0/1)0%   (0/5)0%   (0/163)0%   (0/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InfrastructureCallConfigureCommand0%   (0/1)0%   (0/5)0%   (0/163)0%   (0/47)
InfrastructureCallConfigureCommand (ConfigureRequest, InfrastructureSignature... 0%   (0/1)0%   (0/25)0%   (0/9)
doExecuteWithResult (IProgressMonitor, IAdaptable): CommandResult 0%   (0/1)0%   (0/38)0%   (0/13)
setInfrastructureRequiredRoleInfrastructureCall (IProgressMonitor, IAdaptable... 0%   (0/1)0%   (0/32)0%   (0/7)
setInfrastructureSignatureInfrastructureCall (IProgressMonitor, IAdaptable): ... 0%   (0/1)0%   (0/32)0%   (0/8)
setNumberOfCallsInfrastructureCall (IProgressMonitor, IAdaptable): CommandResult 0%   (0/1)0%   (0/36)0%   (0/10)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.pcm.gmf.seff.helper;
5 
6import org.eclipse.core.commands.ExecutionException;
7import org.eclipse.core.runtime.IAdaptable;
8import org.eclipse.core.runtime.IProgressMonitor;
9import org.eclipse.gmf.runtime.common.core.command.CommandResult;
10import org.eclipse.gmf.runtime.common.core.command.ICommand;
11import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
12import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
13import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
14import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
15import org.eclipse.jface.dialogs.Dialog;
16import org.eclipse.ui.PlatformUI;
17 
18import de.uka.ipd.sdq.pcm.core.PCMRandomVariable;
19import de.uka.ipd.sdq.pcm.dialogs.stoex.StochasticExpressionEditDialog;
20import de.uka.ipd.sdq.pcm.repository.InfrastructureRequiredRole;
21import de.uka.ipd.sdq.pcm.repository.InfrastructureSignature;
22import de.uka.ipd.sdq.pcm.seff.seff_performance.InfrastructureCall;
23import de.uka.ipd.sdq.pcm.seff.seff_performance.ParametricResourceDemand;
24import de.uka.ipd.sdq.pcm.seff.seff_performance.Seff_performancePackage;
25import de.uka.ipd.sdq.stoex.StoexPackage;
26import de.uka.ipd.sdq.stoex.analyser.visitors.TypeEnum;
27 
28/**Configures a given {@link InfrastructureCall} instance to use given a given signature and role.
29 * 
30 * @author groenda
31 */
32public class InfrastructureCallConfigureCommand extends ConfigureElementCommand {
33 
34        /** Configuration request. */
35        private ConfigureRequest request = null;
36        /** Infrastructure signature. */
37        private InfrastructureSignature signature = null;
38        /** Infrastructure required role.*/
39        private InfrastructureRequiredRole requiredRole = null;
40        /** The specification string for the number of calls. */
41        private String numberOfCalls;
42        
43        /**Creates a new configuration command for an {@link InfrastructureCall}.
44         * @param request Configuration request.
45         * @param signature The target signature.
46         * @param requiredRole The target required role.
47         * @param numberOfCalls The number of calls to the target.
48         */
49        public InfrastructureCallConfigureCommand(ConfigureRequest request,
50                        InfrastructureSignature signature, InfrastructureRequiredRole requiredRole, String numberOfCalls) {
51                super(request);
52                this.request = request;
53                this.signature = signature;
54                this.requiredRole = requiredRole;
55                this.numberOfCalls = numberOfCalls;
56        }
57 
58        /* (non-Javadoc)
59         * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
60         */
61        @Override
62        protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
63                        IAdaptable info) throws ExecutionException {
64                CommandResult commandResult = setInfrastructureSignatureInfrastructureCall(monitor,
65                                info);
66                if (!isOK(commandResult)) {
67                        return CommandResult
68                                        .newErrorCommandResult("Set InfrastructureSignature for the InfrastructureCall failed!");
69                }
70                commandResult = setInfrastructureRequiredRoleInfrastructureCall(monitor, info);
71                if (!isOK(commandResult)) {
72                        return CommandResult
73                                        .newErrorCommandResult("Set InfrastructureRequiredRole for the InfrastructureCall failed!");
74                }
75                commandResult = setNumberOfCallsInfrastructureCall(monitor, info);
76                if (!isOK(commandResult)) {
77                        return CommandResult.newErrorCommandResult("Set NumberOfCalls for the InfrastructureCall failed.");
78                }
79                return CommandResult.newOKCommandResult();
80        }
81        
82        
83        /**Create the command to modify the infrastructure signature for an infrastructure call.
84         * @param monitor Progress monitor.
85         * @param info Adaptation information.
86         * @return Command.
87         * @throws ExecutionException On error.
88         */
89        private CommandResult setInfrastructureSignatureInfrastructureCall(
90                        IProgressMonitor monitor, IAdaptable info)
91                        throws ExecutionException {
92                
93                if (!(request.getElementToConfigure() instanceof InfrastructureCall)) {
94                        throw new ExecutionException("The provided element which should be configured was not of type InfrastructureCall.");
95                }
96 
97                ICommand cmd = new SetValueCommand(new SetRequest(request
98                                .getElementToConfigure(), 
99                                Seff_performancePackage.eINSTANCE.getInfrastructureCall_Signature__InfrastructureCall(),
100                                signature));
101 
102                cmd.execute(monitor, info);
103 
104                return cmd.getCommandResult();
105        }
106        
107        /**Create the command to modify the required role for an infrastructure call.
108         * @param monitor Progress monitor.
109         * @param info Adaptation information.
110         * @return Command.
111         * @throws ExecutionException On error.
112         */
113        private CommandResult setInfrastructureRequiredRoleInfrastructureCall(
114                        IProgressMonitor monitor, IAdaptable info)
115                        throws ExecutionException {
116 
117                if (!(request.getElementToConfigure() instanceof InfrastructureCall)) {
118                        throw new ExecutionException("The provided element which should be configured was not of type InfrastructureCall.");
119                }
120                ICommand cmd = new SetValueCommand(new SetRequest(request
121                                .getElementToConfigure(), Seff_performancePackage.eINSTANCE.getInfrastructureCall_RequiredRole__InfrastructureCall(),
122                                requiredRole));
123 
124                cmd.execute(monitor, info);
125 
126                return cmd.getCommandResult();
127        }
128 
129        /**Create the command to modify the number of calls for an infrastructure call.
130         * @param monitor Progress monitor.
131         * @param info Adaptation information.
132         * @return Command.
133         * @throws ExecutionException On error.
134         */
135        private CommandResult setNumberOfCallsInfrastructureCall(
136                        IProgressMonitor monitor, IAdaptable info)
137                        throws ExecutionException {
138 
139                if (!(request.getElementToConfigure() instanceof InfrastructureCall)) {
140                        throw new ExecutionException("The provided element which should be configured was not of type InfrastructureCall.");
141                }
142                InfrastructureCall call = (InfrastructureCall) request.getElementToConfigure();
143                ICommand cmd = new SetValueCommand(
144                                new SetRequest(
145                                                call.getNumberOfCalls__InfrastructureCall(),
146                                                StoexPackage.eINSTANCE.getRandomVariable_Specification(),
147                                                numberOfCalls));
148                cmd.execute(monitor, info);
149                return cmd.getCommandResult();
150        }
151 
152}

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