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

COVERAGE SUMMARY FOR SOURCE FILE [OpenStoExDialog.java]

nameclass, %method, %block, %line, %
OpenStoExDialog.java0%   (0/1)0%   (0/6)0%   (0/131)0%   (0/42)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OpenStoExDialog0%   (0/1)0%   (0/6)0%   (0/131)0%   (0/42)
OpenStoExDialog (): void 0%   (0/1)0%   (0/6)0%   (0/3)
OpenStoExDialog (EStructuralFeature): void 0%   (0/1)0%   (0/6)0%   (0/3)
getDialogMessage (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getExpectedType (RandomVariable): TypeEnum 0%   (0/1)0%   (0/28)0%   (0/10)
getOpenCommand (Request): Command 0%   (0/1)0%   (0/64)0%   (0/18)
getRandomVariable (EObject): RandomVariable 0%   (0/1)0%   (0/25)0%   (0/7)

1package de.uka.ipd.sdq.pcm.dialogs;
2 
3import org.eclipse.core.runtime.IStatus;
4import org.eclipse.emf.ecore.EObject;
5import org.eclipse.emf.ecore.EStructuralFeature;
6import org.eclipse.gef.Request;
7import org.eclipse.gef.commands.Command;
8import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
9import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
10import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
11import org.eclipse.gmf.runtime.diagram.ui.editpolicies.OpenEditPolicy;
12import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
13import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
14import org.eclipse.gmf.runtime.notation.View;
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.parameter.VariableCharacterisation;
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/** 
26 * Manually written open policy to open the StoEx Dialog. It's
27 * called via a CustomBehaviour in the genmap
28 */
29public class OpenStoExDialog extends OpenEditPolicy {
30 
31        protected EStructuralFeature randomVariableFeature;
32 
33        public OpenStoExDialog(EStructuralFeature randomVariableFeature) {
34                super();
35                this.randomVariableFeature = randomVariableFeature;
36        }
37 
38        public OpenStoExDialog() {
39                super();
40                this.randomVariableFeature = null;
41        }
42 
43        protected RandomVariable getRandomVariable(EObject parent) {
44                // Default Implementation. Override as necessary
45                if (randomVariableFeature == null && parent instanceof RandomVariable) {
46                        return (RandomVariable) parent;
47                } else if (randomVariableFeature == null
48                                && parent instanceof VariableCharacterisation) {
49                        return ((VariableCharacterisation) parent)
50                                        .getSpecification_VariableCharacterisation();
51                } else {
52                        return (RandomVariable) parent.eGet(randomVariableFeature);
53                }
54        }
55 
56        /* (non-Javadoc)
57         * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.OpenEditPolicy#getOpenCommand(org.eclipse.gef.Request)
58         */
59        @Override
60        protected Command getOpenCommand(Request request) {
61                IGraphicalEditPart host = (IGraphicalEditPart) getHost();
62                RandomVariable rv = getRandomVariable(((View) host.getModel())
63                                .getElement());
64                StochasticExpressionEditDialog dialog = new StochasticExpressionEditDialog(
65                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
66                                getExpectedType(rv), rv);
67                if (rv != null)
68                        dialog.setInitialExpression(rv);
69                if (getDialogMessage() != null)
70                        dialog.setDisplayTitle(getDialogMessage());
71                
72                dialog.open();
73                if (dialog.getReturnCode() == Dialog.OK) {
74                        Object obj = request.getType();
75                        SetRequest setRequest = new SetRequest(rv, StoexPackage.eINSTANCE
76                                        .getRandomVariable_Specification(), dialog.getResultText());
77                        SetValueCommand cmd = new SetValueCommand(setRequest);
78                        return new ICommandProxy(cmd);
79                }
80                return null;
81        }
82        
83        protected String getDialogMessage() {
84                return null;
85        }
86 
87        protected TypeEnum getExpectedType(RandomVariable rv) {
88                TypeEnum expectedType = TypeEnum.ANY;
89                VariableCharacterisation vc = null;
90                
91                if (rv instanceof VariableCharacterisation) {
92                        vc = (VariableCharacterisation) rv;
93                }
94                if (rv instanceof PCMRandomVariable && rv.eContainer() instanceof VariableCharacterisation) {
95                        vc = (VariableCharacterisation) rv.eContainer();
96                }
97                if (vc != null) {
98                        expectedType = StochasticExpressionEditDialog
99                                .getTypeFromVariableCharacterisation(vc);
100                }
101                return expectedType;
102        }
103 
104}

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