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

nameclass, %method, %block, %line, %
ParametricResourceDemandConfigureCommand.java0%   (0/1)0%   (0/4)0%   (0/153)0%   (0/52)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ParametricResourceDemandConfigureCommand0%   (0/1)0%   (0/4)0%   (0/153)0%   (0/52)
ParametricResourceDemandConfigureCommand (ConfigureRequest): void 0%   (0/1)0%   (0/10)0%   (0/4)
doExecuteWithResult (IProgressMonitor, IAdaptable): CommandResult 0%   (0/1)0%   (0/26)0%   (0/10)
setRequiredResource_ParametricResourceDemand (IProgressMonitor, IAdaptable): ... 0%   (0/1)0%   (0/73)0%   (0/24)
setSpecification_ParametricResourceDemand (IProgressMonitor, IAdaptable): Com... 0%   (0/1)0%   (0/44)0%   (0/14)

1package de.uka.ipd.sdq.pcm.gmf.seff.helper;
2 
3import java.util.ArrayList;
4 
5import org.eclipse.core.commands.ExecutionException;
6import org.eclipse.core.runtime.IAdaptable;
7import org.eclipse.core.runtime.IProgressMonitor;
8import org.eclipse.emf.ecore.EObject;
9import org.eclipse.emf.ecore.EReference;
10import org.eclipse.gmf.runtime.common.core.command.CommandResult;
11import org.eclipse.gmf.runtime.common.core.command.ICommand;
12import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
13import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
14import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
15import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
16import org.eclipse.jface.dialogs.Dialog;
17import org.eclipse.ui.PlatformUI;
18 
19import de.uka.ipd.sdq.pcm.dialogs.selection.PalladioSelectEObjectDialog;
20import de.uka.ipd.sdq.pcm.dialogs.stoex.StochasticExpressionEditDialog;
21import de.uka.ipd.sdq.pcm.resourcetype.ProcessingResourceType;
22import de.uka.ipd.sdq.pcm.resourcetype.ResourceRepository;
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/** @author roman */
29public class ParametricResourceDemandConfigureCommand extends
30                ConfigureElementCommand {
31 
32        private ConfigureRequest request = null;
33        
34        public ParametricResourceDemandConfigureCommand(ConfigureRequest request){
35                super(request);
36                this.request = request;
37        }
38 
39        /* (non-Javadoc)
40         * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
41         */
42        @Override
43        protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
44                        IAdaptable info) throws ExecutionException {
45 
46                CommandResult commandResult = setRequiredResource_ParametricResourceDemand(
47                                monitor, info);
48                if (!isOK(commandResult)) {
49                        return CommandResult
50                                        .newErrorCommandResult("Set RequiredResource for the ParametricResourceDemand failed!");
51                }
52                commandResult = setSpecification_ParametricResourceDemand(monitor, info);
53                if (!isOK(commandResult)) {
54                        return CommandResult
55                                        .newErrorCommandResult("Set Action for the ParametricResourceDemand failed!");
56                }
57                return CommandResult.newOKCommandResult();
58        }
59 
60        private CommandResult setRequiredResource_ParametricResourceDemand(
61                        IProgressMonitor monitor, IAdaptable info)
62                        throws ExecutionException {
63 
64                EObject resource = null;
65                ArrayList<Object> filterList = new ArrayList<Object>();
66                filterList.add(ResourceRepository.class);
67                filterList.add(ProcessingResourceType.class);
68 
69                ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
70                PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(
71                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
72                                filterList, additionalReferences, request.getEditingDomain()
73                                                .getResourceSet());
74                dialog.setProvidedService(ProcessingResourceType.class);
75                dialog.open();
76                if (dialog.getResult() == null)
77                        return CommandResult.newCancelledCommandResult();
78                if (!(dialog.getResult() instanceof ProcessingResourceType))
79                        return CommandResult.newCancelledCommandResult();
80                resource = (ProcessingResourceType) dialog.getResult();
81                
82                ICommand cmd = new SetValueCommand(
83                                new SetRequest(
84                                                request.getElementToConfigure(),
85                                                Seff_performancePackage.eINSTANCE
86                                                                .getParametricResourceDemand_RequiredResource_ParametricResourceDemand(),
87                                                resource));
88                cmd.execute(monitor, info);
89 
90                return cmd.getCommandResult();
91        }
92 
93        private CommandResult setSpecification_ParametricResourceDemand(
94                        IProgressMonitor monitor, IAdaptable info)
95                        throws ExecutionException {
96 
97                StochasticExpressionEditDialog dialog = new StochasticExpressionEditDialog(
98                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
99                                TypeEnum.DOUBLE, request.getElementToConfigure());
100                dialog.open();
101 
102                if (dialog.getReturnCode() == Dialog.CANCEL)
103                        return CommandResult.newCancelledCommandResult();
104 
105                ICommand cmd = new SetValueCommand(
106                                new SetRequest(((ParametricResourceDemand)request
107                                        .getElementToConfigure()).getSpecification_ParametericResourceDemand(),
108                                StoexPackage.eINSTANCE
109                                        .getRandomVariable_Specification(),
110                                dialog.getResultText()));
111                cmd.execute(monitor, info);
112 
113                return cmd.getCommandResult();
114        }
115}

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