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

COVERAGE SUMMARY FOR SOURCE FILE [RepositoryEditorSeffEditHelperAdvice.java]

nameclass, %method, %block, %line, %
RepositoryEditorSeffEditHelperAdvice.java0%   (0/2)0%   (0/4)0%   (0/199)0%   (0/60)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ConfigureSEFFCommand0%   (0/1)0%   (0/2)0%   (0/104)0%   (0/31)
ConfigureSEFFCommand (ConfigureRequest): void 0%   (0/1)0%   (0/7)0%   (0/3)
doExecuteWithResult (IProgressMonitor, IAdaptable): CommandResult 0%   (0/1)0%   (0/97)0%   (0/28)
     
class RepositoryEditorSeffEditHelperAdvice0%   (0/1)0%   (0/2)0%   (0/95)0%   (0/29)
RepositoryEditorSeffEditHelperAdvice (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getAfterConfigureCommand (ConfigureRequest): ICommand 0%   (0/1)0%   (0/92)0%   (0/28)

1package de.uka.ipd.sdq.pcm.gmf.repository.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.CompositeCommand;
12import org.eclipse.gmf.runtime.common.core.command.ICommand;
13import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
14import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
15import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
16import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
17import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
18import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
19import org.eclipse.ui.PlatformUI;
20 
21import de.uka.ipd.sdq.pcm.dialogs.selection.PalladioSelectEObjectDialog;
22import de.uka.ipd.sdq.pcm.repository.Interface;
23import de.uka.ipd.sdq.pcm.repository.ProvidedRole;
24import de.uka.ipd.sdq.pcm.repository.RepositoryPackage;
25import de.uka.ipd.sdq.pcm.repository.Signature;
26import de.uka.ipd.sdq.pcm.seff.ResourceDemandingSEFF;
27import de.uka.ipd.sdq.pcm.seff.SeffFactory;
28import de.uka.ipd.sdq.pcm.seff.SeffPackage;
29import de.uka.ipd.sdq.pcm.seff.StartAction;
30import de.uka.ipd.sdq.pcm.seff.StopAction;
31 
32class ConfigureSEFFCommand extends ConfigureElementCommand {
33        private ConfigureRequest myRequest;
34 
35        public ConfigureSEFFCommand(ConfigureRequest request) {
36                super(request);
37                myRequest = request;
38        }
39 
40        @Override
41        protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
42                        IAdaptable info) throws ExecutionException {
43 
44        ResourceDemandingSEFF seff = (ResourceDemandingSEFF) myRequest.getElementToConfigure();
45        StartAction start = SeffFactory.eINSTANCE.createStartAction(); 
46        SetRequest setter2 = new SetRequest(seff,
47                        SeffPackage.eINSTANCE.getResourceDemandingBehaviour_Steps_Behaviour(), 
48                        start);
49        SetValueCommand setCommand2 = new SetValueCommand(setter2);
50        setCommand2.execute(monitor, info);
51        CommandResult result = setCommand2.getCommandResult();
52        if (!isOK(result))
53        {
54                return CommandResult.newErrorCommandResult("Create SEFF failed!");
55        }
56        StopAction stop = SeffFactory.eINSTANCE.createStopAction(); 
57        SetRequest setter3 = new SetRequest(seff,
58                        SeffPackage.eINSTANCE.getResourceDemandingBehaviour_Steps_Behaviour(), 
59                        stop);
60        SetValueCommand setCommand3 = new SetValueCommand(setter3);
61        setCommand3.execute(monitor, info);
62        result = setCommand3.getCommandResult();
63        if (!isOK(result))
64        {
65                return CommandResult.newErrorCommandResult("Create SEFF failed!");
66        }
67        SetRequest setter4 = new SetRequest(start,
68                        SeffPackage.eINSTANCE.getAbstractAction_Successor_AbstractAction(), 
69                        stop);
70        SetValueCommand setCommand4 = new SetValueCommand(setter4);
71        setCommand4.execute(monitor, info);
72        result = setCommand4.getCommandResult();
73        if (!isOK(result))
74        {
75                return CommandResult.newErrorCommandResult("Create SEFF failed!");
76        }
77        return CommandResult.newOKCommandResult();
78        }
79}
80 
81public class RepositoryEditorSeffEditHelperAdvice extends AbstractEditHelperAdvice implements
82                IEditHelperAdvice {
83 
84        @Override
85        /**
86         * Sets signature of a provided role
87         */
88        protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
89                EObject signature = null;
90                ArrayList<Object> filterList = new ArrayList<Object>();        // positive filter
91                // Set types to show and their super types
92                filterList.add(ProvidedRole.class);
93                filterList.add(Interface.class);
94                filterList.add(Signature.class);
95                ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
96                // set EReference that should be set (in this case: provided role)
97                additionalReferences.add(RepositoryPackage.eINSTANCE.getOperationProvidedRole_ProvidedInterface__OperationProvidedRole());
98                PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(
99                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
100                                filterList, 
101                                additionalReferences,
102                                request.getElementToConfigure().eContainer());
103                dialog.setProvidedService(Signature.class);
104                dialog.open();
105                if (dialog.getResult() == null)
106                        return new CanceledCommand();
107                if (!(dialog.getResult() instanceof Signature))
108                        return new CanceledCommand();
109                signature = (Signature) dialog.getResult();
110                
111                ICommand cmd = new SetValueCommand(
112                                new SetRequest(
113                                                request.getElementToConfigure(), 
114                                                SeffPackage.eINSTANCE.getServiceEffectSpecification_DescribedService__SEFF(),
115                                                signature));
116                CompositeCommand cc = new CompositeCommand("Configure SEFF");
117                cc.add(cmd);
118                cc.add(new ConfigureSEFFCommand(request));
119                return cc;
120        }        
121        
122}

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