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

COVERAGE SUMMARY FOR SOURCE FILE [ProcessingResourceSpecificationEditHelperAdvice.java]

nameclass, %method, %block, %line, %
ProcessingResourceSpecificationEditHelperAdvice.java0%   (0/1)0%   (0/4)0%   (0/136)0%   (0/44)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ProcessingResourceSpecificationEditHelperAdvice0%   (0/1)0%   (0/4)0%   (0/136)0%   (0/44)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/2)
ProcessingResourceSpecificationEditHelperAdvice (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getAfterConfigureCommand (ConfigureRequest): ICommand 0%   (0/1)0%   (0/51)0%   (0/16)
getBeforeConfigureCommand (ConfigureRequest): ICommand 0%   (0/1)0%   (0/79)0%   (0/26)

1package de.uka.ipd.sdq.pcm.gmf.resource.helper;
2 
3import java.util.ArrayList;
4 
5import org.eclipse.emf.ecore.EObject;
6import org.eclipse.emf.ecore.EReference;
7import org.eclipse.gmf.runtime.common.core.command.ICommand;
8import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
9import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
10import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
11import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
12import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
13import org.eclipse.jface.dialogs.Dialog;
14import org.eclipse.ui.PlatformUI;
15 
16import de.uka.ipd.sdq.pcm.core.CoreFactory;
17import de.uka.ipd.sdq.pcm.core.PCMRandomVariable;
18import de.uka.ipd.sdq.pcm.dialogs.selection.PalladioSelectEObjectDialog;
19import de.uka.ipd.sdq.pcm.dialogs.stoex.StochasticExpressionEditDialog;
20import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage;
21import de.uka.ipd.sdq.pcm.resourcetype.ProcessingResourceType;
22import de.uka.ipd.sdq.pcm.resourcetype.ResourceRepository;
23import de.uka.ipd.sdq.stoex.analyser.visitors.TypeEnum;
24 
25public class ProcessingResourceSpecificationEditHelperAdvice extends AbstractEditHelperAdvice
26                implements IEditHelperAdvice {
27 
28        private static final String DISPLAY_TITLE = "Set Processing Rate";
29        private static boolean ongoing = true;
30 
31        @Override
32        protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
33                PCMRandomVariable rv = CoreFactory.eINSTANCE.createPCMRandomVariable();
34                rv.setSpecification("");
35                if (ongoing){
36                        StochasticExpressionEditDialog dialog = new StochasticExpressionEditDialog(
37                                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
38                                        TypeEnum.DOUBLE, rv);
39                        dialog.setDisplayTitle(DISPLAY_TITLE);
40                        dialog.open();
41 
42                        if (dialog.getReturnCode() == Dialog.CANCEL)
43                                return new CanceledCommand();
44 
45                        rv.setSpecification(dialog.getResultText());
46                }
47                
48                ongoing = true;
49 
50                ICommand cmd = new SetValueCommand(new SetRequest(request
51                                .getElementToConfigure(), ResourceenvironmentPackage.eINSTANCE.getProcessingResourceSpecification_ProcessingRate_ProcessingResourceSpecification(),
52                                rv));
53 
54                return cmd;
55        }
56        
57        @Override
58        protected ICommand getBeforeConfigureCommand(ConfigureRequest request) {
59                EObject resourceType = null;
60                ArrayList<Object> filterList = new ArrayList<Object>(); // positive filter
61                // Set types to show and their super types
62                filterList.add(ProcessingResourceType.class);
63                filterList.add(ResourceRepository.class);
64                ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
65                // set EReference that should be set (in this case: active resource type)
66                additionalReferences.add(ResourceenvironmentPackage.eINSTANCE.getProcessingResourceSpecification_ActiveResourceType_ActiveResourceSpecification());
67                PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(
68                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
69                                filterList, 
70                                additionalReferences,
71                                request.getElementToConfigure().eResource().getResourceSet());
72                dialog.setProvidedService(ProcessingResourceType.class);
73                dialog.open();
74                if (dialog.getResult() == null) {
75                        ongoing = false; //prevents the StoexDialog for the ProcessingRate from being opened
76                        return new CanceledCommand();
77                }
78 
79                if (!(dialog.getResult() instanceof ProcessingResourceType)){
80                        ongoing = false; //prevents the StoexDialog for the ProcessingRate from being opened
81                        return new CanceledCommand();
82                }
83                resourceType = (ProcessingResourceType) dialog.getResult();
84                
85                ICommand cmd = new SetValueCommand(
86                                new SetRequest(
87                                                request.getElementToConfigure(), 
88                                                ResourceenvironmentPackage.eINSTANCE.getProcessingResourceSpecification_ActiveResourceType_ActiveResourceSpecification(),
89                                                resourceType));
90                return cmd;
91        }
92}

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