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

nameclass, %method, %block, %line, %
SetVariableActionEditHelperAdvice.java0%   (0/1)0%   (0/3)0%   (0/90)0%   (0/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SetVariableActionEditHelperAdvice0%   (0/1)0%   (0/3)0%   (0/90)0%   (0/28)
SetVariableActionEditHelperAdvice (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getBeforeConfigureCommand (ConfigureRequest): ICommand 0%   (0/1)0%   (0/31)0%   (0/10)
hasReturn (ConfigureRequest): boolean 0%   (0/1)0%   (0/56)0%   (0/17)

1package de.uka.ipd.sdq.pcm.gmf.seff.helper;
2 
3import org.eclipse.emf.ecore.EObject;
4import org.eclipse.gmf.runtime.common.core.command.ICommand;
5import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
6import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
7import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
8import org.eclipse.swt.SWT;
9import org.eclipse.swt.widgets.MessageBox;
10import org.eclipse.swt.widgets.Shell;
11import org.eclipse.ui.PlatformUI;
12 
13import de.uka.ipd.sdq.pcm.repository.OperationSignature;
14import de.uka.ipd.sdq.pcm.repository.Parameter;
15import de.uka.ipd.sdq.pcm.repository.ParameterModifier;
16import de.uka.ipd.sdq.pcm.seff.ResourceDemandingSEFF;
17 
18/**
19 * This class defines an EditHelper to handle the creation of an SetVariableAction.
20 *
21 * @author Christian Busch
22 */
23public class SetVariableActionEditHelperAdvice extends
24AbstractEditHelperAdvice implements IEditHelperAdvice {
25 
26        /* (non-Javadoc)
27         * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest)
28         */
29        @Override
30        protected ICommand getBeforeConfigureCommand(ConfigureRequest request) {
31 
32                if (hasReturn(request)) {
33                        return new OKCommand();
34                } else {
35                        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
36 
37                        MessageBox messageBox =
38                                new MessageBox(shell ,
39                                                SWT.OK
40                                                | SWT.ICON_WARNING);
41                        messageBox.setText("Notice");
42                        messageBox.setMessage("In order to create a SetVariableAction there must be a return type specified for the signature of the interface.");
43                        messageBox.open();
44 
45                        return new CanceledCommand();
46                }
47        }
48 
49        /**
50         * Checks whether the SEFF corresponding to the request
51         * has a signature with at least one return type specified.
52         *
53         * @param request to be checked
54         * @return true if return parameter(s) of signature specified
55         */
56        protected boolean hasReturn(ConfigureRequest request) {
57 
58                boolean hasReturn = false;
59                EObject node = request.getElementToConfigure();
60 
61                /* walk through the tree */
62                while (!(node instanceof ResourceDemandingSEFF)) {
63                        node = node.eContainer();
64                        if (node == null) {
65                                return false;
66                        }
67                }
68                node = ((ResourceDemandingSEFF) node).getDescribedService__SEFF();
69                if (node instanceof OperationSignature) {
70                        OperationSignature signature = (OperationSignature) node;
71                        /* check signature */
72                        for (Parameter p : signature.getParameters__OperationSignature()) {
73                                if (p.getModifier__Parameter() == ParameterModifier.OUT
74                                                || p.getModifier__Parameter() == ParameterModifier.INOUT) {
75                                        hasReturn = true;
76                                        break;
77                                }
78                        }
79                        if (signature.getReturnType__OperationSignature() != null) {
80                                hasReturn = true;
81                        }
82                }
83                return hasReturn;
84        }
85}
86 

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