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

COVERAGE SUMMARY FOR SOURCE FILE [OpenStoExDialog.java]

nameclass, %method, %block, %line, %
OpenStoExDialog.java0%   (0/1)0%   (0/6)0%   (0/121)0%   (0/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OpenStoExDialog0%   (0/1)0%   (0/6)0%   (0/121)0%   (0/35)
OpenStoExDialog (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getContext (EObject): Parameter [] 0%   (0/1)0%   (0/30)0%   (0/7)
getExpectedType (RandomVariable): TypeEnum 0%   (0/1)0%   (0/11)0%   (0/4)
getOpenCommand (Request): Command 0%   (0/1)0%   (0/55)0%   (0/15)
getRandomVariable (EObject): RandomVariable 0%   (0/1)0%   (0/3)0%   (0/1)
getSEFF (EObject): ResourceDemandingSEFF 0%   (0/1)0%   (0/19)0%   (0/7)

1package de.uka.ipd.sdq.pcm.dialogs.usage;
2 
3import org.eclipse.emf.ecore.EObject;
4import org.eclipse.gef.Request;
5import org.eclipse.gef.commands.Command;
6import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
7import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
8import org.eclipse.gmf.runtime.diagram.ui.editpolicies.OpenEditPolicy;
9import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
10import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
11import org.eclipse.gmf.runtime.notation.View;
12import org.eclipse.jface.dialogs.Dialog;
13import org.eclipse.ui.PlatformUI;
14 
15import de.uka.ipd.sdq.pcm.dialogs.stoex.StochasticExpressionEditDialog;
16import de.uka.ipd.sdq.pcm.parameter.VariableCharacterisation;
17import de.uka.ipd.sdq.pcm.repository.OperationSignature;
18import de.uka.ipd.sdq.pcm.repository.Parameter;
19import de.uka.ipd.sdq.pcm.seff.ResourceDemandingSEFF;
20import de.uka.ipd.sdq.pcm.stochasticexpressions.PCMStoExPrettyPrintVisitor;
21import de.uka.ipd.sdq.stoex.RandomVariable;
22import de.uka.ipd.sdq.stoex.StoexPackage;
23import de.uka.ipd.sdq.stoex.analyser.visitors.TypeEnum;
24 
25// Manually written open policy to open the StoEx Dialog. It's
26// called via a CustomBehaviour in the genmap
27public class OpenStoExDialog extends OpenEditPolicy {
28 
29        protected RandomVariable getRandomVariable(EObject parent) {
30                // Default Implementation. Override as necessary
31                return (RandomVariable)parent;
32        }
33        
34        @Override
35        protected Command getOpenCommand(Request request) {
36                IGraphicalEditPart host = (IGraphicalEditPart) getHost();
37                RandomVariable rv = getRandomVariable(((View)host.getModel()).getElement());
38                StochasticExpressionEditDialog dialog = new StochasticExpressionEditDialog(
39                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
40                                getExpectedType(rv));
41                dialog.setInitialExpression(rv);
42                dialog.open();
43                if (dialog.getReturnCode() == Dialog.OK) {
44                        SetRequest setRequest = new SetRequest(
45                                        rv, 
46                                        StoexPackage.eINSTANCE.getRandomVariable_Specification(), 
47                                        new PCMStoExPrettyPrintVisitor().prettyPrint(dialog.getResult()));
48                        SetValueCommand cmd = new SetValueCommand(setRequest);
49                        return new ICommandProxy(cmd);
50                }
51                return null;
52        }
53 
54        protected TypeEnum getExpectedType(RandomVariable rv) {
55                TypeEnum expectedType = TypeEnum.ANY; 
56                if (rv instanceof VariableCharacterisation){
57                        expectedType = StochasticExpressionEditDialog.getTypeFromVariableCharacterisation((VariableCharacterisation) rv);
58                }
59                return expectedType;
60        }
61        
62        private Parameter[] getContext(EObject rv) {
63                Parameter[] parameters = new Parameter[]{};
64 
65                ResourceDemandingSEFF seff = getSEFF(
66                                rv);
67 
68                if (seff != null && seff.getDescribedService__SEFF() != null){
69                        if(seff.getDescribedService__SEFF() instanceof OperationSignature && ((OperationSignature) seff.getDescribedService__SEFF()).getParameters__OperationSignature() != null)
70                                        parameters = (Parameter[]) ((OperationSignature) seff.getDescribedService__SEFF()).getParameters__OperationSignature().toArray();
71                        }
72                return parameters;
73        }
74 
75        private ResourceDemandingSEFF getSEFF(EObject a) {
76                EObject container = a;
77                while (!(container instanceof ResourceDemandingSEFF))
78                        container = container.eContainer();
79                if (!(container instanceof ResourceDemandingSEFF)) 
80                        return null;
81                ResourceDemandingSEFF seff = (ResourceDemandingSEFF) container;
82                return seff;
83        }
84 
85}

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