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

COVERAGE SUMMARY FOR SOURCE FILE [EventTypeAddActionListener.java]

nameclass, %method, %block, %line, %
EventTypeAddActionListener.java0%   (0/2)0%   (0/7)0%   (0/85)0%   (0/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EventTypeAddActionListener0%   (0/1)0%   (0/5)0%   (0/34)0%   (0/12)
EventTypeAddActionListener (): void 0%   (0/1)0%   (0/3)0%   (0/1)
access$0 (EventTypeAddActionListener): EventGroup 0%   (0/1)0%   (0/3)0%   (0/1)
getSelectedEventGroup (): EventGroup 0%   (0/1)0%   (0/3)0%   (0/1)
setSelectedInterface (EventGroup): void 0%   (0/1)0%   (0/4)0%   (0/2)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/21)0%   (0/7)
     
class EventTypeAddActionListener$10%   (0/1)0%   (0/2)0%   (0/51)0%   (0/16)
EventTypeAddActionListener$1 (EventTypeAddActionListener, TransactionalEditin... 0%   (0/1)0%   (0/7)0%   (0/2)
doExecute (): void 0%   (0/1)0%   (0/44)0%   (0/14)

1package de.uka.ipd.sdq.pcmbench.tabs.operations;
2 
3import org.eclipse.core.runtime.Assert;
4import org.eclipse.emf.transaction.RecordingCommand;
5import org.eclipse.emf.transaction.TransactionalEditingDomain;
6import org.eclipse.emf.transaction.util.TransactionUtil;
7import org.eclipse.swt.events.SelectionAdapter;
8import org.eclipse.swt.events.SelectionEvent;
9 
10import de.uka.ipd.sdq.pcm.repository.EventGroup;
11import de.uka.ipd.sdq.pcm.repository.EventType;
12import de.uka.ipd.sdq.pcm.repository.Parameter;
13import de.uka.ipd.sdq.pcm.repository.PrimitiveDataType;
14import de.uka.ipd.sdq.pcm.repository.PrimitiveTypeEnum;
15import de.uka.ipd.sdq.pcm.repository.RepositoryFactory;
16 
17/**
18 * Event Listener for the creation of a new event type.
19 * 
20 * This event listener initialises the new event type. 
21 * I.e. it sets the default event type name and adds a default parameter.
22 * 
23 * @author Benjamin Klatt
24 *
25 */
26public class EventTypeAddActionListener extends SelectionAdapter {
27 
28        /**
29         * Define the selected interface. The variable is set not during the class
30         * production, separates later.
31         */
32        private EventGroup selectedEventGroup;
33 
34        /* (non-Javadoc)
35         * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
36         */
37        @Override
38        public void widgetSelected(SelectionEvent e) {
39                Assert.isNotNull(selectedEventGroup);
40 
41                /**
42                 * The transactional editing domain which is used to get the commands
43                 * and alter the model
44                 */
45                TransactionalEditingDomain editingDomain = TransactionUtil
46                                .getEditingDomain(selectedEventGroup);
47 
48                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
49                        @Override
50                        protected void doExecute() {
51                                
52                                // create the new event type
53                                EventType eventType = RepositoryFactory.eINSTANCE
54                                                .createEventType();
55                                eventType
56                                                .setEntityName("EventTypeName"
57                                                                + (selectedEventGroup.getEventTypes__EventGroup()
58                                                                                .size() + 1));
59                                
60                                // create the event content parameter with a default name and String data type
61                                Parameter parameter = RepositoryFactory.eINSTANCE.createParameter();
62                                parameter.setParameterName("eventConent");
63                                PrimitiveDataType dataType = RepositoryFactory.eINSTANCE.createPrimitiveDataType();
64                                dataType.setType(PrimitiveTypeEnum.STRING);
65                                parameter.setDataType__Parameter(dataType);
66                                eventType.setParameter__EventType(parameter);
67                                
68                                // add the prepared event type
69                                selectedEventGroup.getEventTypes__EventGroup().add(eventType);
70                        }
71                };
72 
73                recCommand.setDescription("Add new event type");
74                editingDomain.getCommandStack().execute(recCommand);
75        }
76 
77        /**
78         * @return the selected event group
79         */
80        public EventGroup getSelectedEventGroup() {
81                return selectedEventGroup;
82        }
83 
84        /**
85         * @param selectedEventGroup The event group to set
86         */
87        public void setSelectedInterface(EventGroup selectedEventGroup) {
88                this.selectedEventGroup = selectedEventGroup;
89        }
90}

[all classes][de.uka.ipd.sdq.pcmbench.tabs.operations]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov