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

nameclass, %method, %block, %line, %
EmitEventActionEditHelperAdvice.java0%   (0/1)0%   (0/3)0%   (0/96)0%   (0/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EmitEventActionEditHelperAdvice0%   (0/1)0%   (0/3)0%   (0/96)0%   (0/28)
EmitEventActionEditHelperAdvice (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getAfterConfigureCommand (ConfigureRequest): ICommand 0%   (0/1)0%   (0/82)0%   (0/23)
searchBasicComponent (EObject): EObject 0%   (0/1)0%   (0/11)0%   (0/4)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.pcm.gmf.seff.helper;
5 
6import java.util.ArrayList;
7 
8import org.eclipse.emf.ecore.EObject;
9import org.eclipse.emf.ecore.EReference;
10import org.eclipse.gmf.runtime.common.core.command.ICommand;
11import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
12import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
13import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
14import org.eclipse.ui.PlatformUI;
15 
16import de.uka.ipd.sdq.pcm.dialogs.selection.PalladioSelectEObjectDialog;
17import de.uka.ipd.sdq.pcm.repository.BasicComponent;
18import de.uka.ipd.sdq.pcm.repository.EventGroup;
19import de.uka.ipd.sdq.pcm.repository.EventType;
20import de.uka.ipd.sdq.pcm.repository.RepositoryPackage;
21import de.uka.ipd.sdq.pcm.repository.SourceRole;
22 
23/**
24 * Edit helper for the EmitEventAction.
25 * Features are:
26 * - Open EventType selection dialog when EmitEventAction is created
27 * 
28 * @author Benjamin Klatt
29 * 
30 */
31public class EmitEventActionEditHelperAdvice extends
32                AbstractEditHelperAdvice implements IEditHelperAdvice {
33 
34        /**
35         * When an EmitEventAction is created:
36         * - Open the dialog to select an EventType this action is able to emit
37         * - Get the selected EventType and store it in the action
38         * 
39         * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest)
40         */
41        @Override
42        protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
43                EObject eObject = searchBasicComponent(request.getElementToConfigure());
44                SourceRole sourceRole = null;
45                
46                // define the filter list
47                ArrayList<Object> filterList = new ArrayList<Object>();
48                filterList.add(SourceRole.class);
49                filterList.add(EventGroup.class);
50                filterList.add(EventType.class);
51                
52                // define the additional references
53                ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
54                additionalReferences.add(RepositoryPackage.eINSTANCE
55                                .getSourceRole_EventGroup__SourceRole());
56                
57                // create the dialog
58                PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(
59                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
60                                filterList, additionalReferences, eObject);
61                dialog.setProvidedService(EventType.class);
62                dialog.open();
63                if (dialog.getResult() == null)
64                        return new CanceledCommand();
65                if (!(dialog.getResult() instanceof EventType))
66                        return new CanceledCommand();
67                
68                // set the EventType for EmitEventAction 
69                EventType eventType = (EventType) dialog.getResult();
70                
71                // set the required role for EmitEventAction 
72                if (dialog.getViewerRootElement() instanceof SourceRole) {
73                        sourceRole = (SourceRole) dialog.getRootOfResult();
74                }
75 
76                // create and execute the EmitEventActionConfigureCommand command
77                return new EmitEventActionConfigureCommand(request, eventType,
78                                sourceRole);
79        }
80 
81        private EObject searchBasicComponent(EObject elementToConfigure) {
82                EObject o = elementToConfigure;
83                while (!(o instanceof BasicComponent))
84                        o = o.eContainer();
85                return o;
86        }
87}

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