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

nameclass, %method, %block, %line, %
EventTypesCellModifier.java0%   (0/4)0%   (0/14)0%   (0/248)0%   (0/61)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EventTypesCellModifier0%   (0/1)0%   (0/8)0%   (0/169)0%   (0/48)
EventTypesCellModifier (): void 0%   (0/1)0%   (0/10)0%   (0/4)
access$0 (EventTypesCellModifier): EventType 0%   (0/1)0%   (0/3)0%   (0/1)
canModify (Object, String): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
getValue (Object, String): Object 0%   (0/1)0%   (0/11)0%   (0/2)
modify (Object, String, Object): void 0%   (0/1)0%   (0/47)0%   (0/16)
setEventTypeName (String): void 0%   (0/1)0%   (0/28)0%   (0/7)
setEventTypeParameterName (String): void 0%   (0/1)0%   (0/33)0%   (0/8)
setParameterType (DataType): void 0%   (0/1)0%   (0/35)0%   (0/9)
     
class EventTypesCellModifier$10%   (0/1)0%   (0/2)0%   (0/17)0%   (0/4)
EventTypesCellModifier$1 (EventTypesCellModifier, TransactionalEditingDomain,... 0%   (0/1)0%   (0/10)0%   (0/2)
doExecute (): void 0%   (0/1)0%   (0/7)0%   (0/2)
     
class EventTypesCellModifier$20%   (0/1)0%   (0/2)0%   (0/31)0%   (0/7)
EventTypesCellModifier$2 (EventTypesCellModifier, TransactionalEditingDomain,... 0%   (0/1)0%   (0/10)0%   (0/2)
doExecute (): void 0%   (0/1)0%   (0/21)0%   (0/5)
     
class EventTypesCellModifier$30%   (0/1)0%   (0/2)0%   (0/31)0%   (0/7)
EventTypesCellModifier$3 (EventTypesCellModifier, TransactionalEditingDomain,... 0%   (0/1)0%   (0/10)0%   (0/2)
doExecute (): void 0%   (0/1)0%   (0/21)0%   (0/5)

1package de.uka.ipd.sdq.pcmbench.tabs.operations;
2 
3import java.util.Arrays;
4import java.util.List;
5 
6import org.eclipse.core.runtime.Assert;
7import org.eclipse.emf.transaction.RecordingCommand;
8import org.eclipse.emf.transaction.TransactionalEditingDomain;
9import org.eclipse.emf.transaction.util.TransactionUtil;
10import org.eclipse.swt.widgets.TableItem;
11 
12import de.uka.ipd.sdq.pcm.repository.DataType;
13import de.uka.ipd.sdq.pcm.repository.EventType;
14import de.uka.ipd.sdq.pcm.repository.Parameter;
15import de.uka.ipd.sdq.pcm.repository.RepositoryFactory;
16import de.uka.ipd.sdq.pcmbench.tabs.generic.ObservableCellModifier;
17 
18/**
19 * This class implements an ICellModifier for the modification of event types. 
20 * An ICellModifier is called when the user modifies a cell in the tableViewer
21 * 
22 * @author Benjamin Klatt
23 */
24 
25public class EventTypesCellModifier extends ObservableCellModifier {
26 
27        private List<String> columnNames;
28        private EventType eventType;
29 
30        /**
31         * The transactional editing domain which is used to get the commands and
32         * alter the model
33         */
34        protected TransactionalEditingDomain editingDomain = null;
35 
36        public EventTypesCellModifier() {
37                this.columnNames = Arrays.asList(EventTypesEditorSection.columnNames);
38        }
39 
40        /* (non-Javadoc)
41         * @see org.eclipse.jface.viewers.ICellModifier#canModify(Object element,
42         *      String property)
43         */
44        public boolean canModify(Object element, String property) {
45                return true;
46        }
47 
48        public Object getValue(Object element, String property) {
49                return (new EventTypesTabItemProvider(null)).getColumnText(element,
50                                columnNames.indexOf(property));
51        }
52 
53        public void modify(Object element, String property, Object value) {
54 
55                // Find the index of the column
56                int columnIndex = columnNames.indexOf(property);
57 
58                Assert.isNotNull(element);
59                TableItem item = (TableItem) element;
60                eventType = (EventType) item.getData();
61                editingDomain = TransactionUtil.getEditingDomain(eventType);
62 
63                switch (columnIndex) {
64                case EventTypesEditorSection.ICON_COLUMN_INDEX: // COMPLETED_COLUMN
65                        break;
66                case EventTypesEditorSection.EVENTTYPENAME_COLUMN_INDEX: // EVENT TYPE NAME_COLUMN
67                        String valueString = ((String) value).trim();
68                        setEventTypeName(valueString);
69                        break;
70                case EventTypesEditorSection.PARAMETER_NAME_COLUMN_INDEX: // OWNEDPARAMETER_COLUMN
71                        String parameterNameString = ((String) value).trim();
72                        setEventTypeParameterName(parameterNameString);
73                        break;
74                case EventTypesEditorSection.PARAMETER_TYPE_COLUMN_INDEX: // OWNEDPARAMETER TYPE COLUMN
75                        if (value instanceof DataType)
76                                setParameterType((DataType) value);
77                        break;
78                default:
79                }
80        }
81 
82        /**
83         * Set the name of the event type.
84         * @param valueString The name to be set.
85         */
86        private void setEventTypeName(String valueString) {
87                final String value = valueString;
88 
89                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
90                        @Override
91                        protected void doExecute() {
92                                eventType.setEntityName(value);
93                        }
94                };
95 
96                if (!value.equals(eventType.getEntityName())) {
97                        recCommand.setDescription("Edit EventType Property");
98                        recCommand.setLabel("Set name");
99                        editingDomain.getCommandStack().execute(recCommand);
100                }
101        }
102 
103        /**
104         * Set the name of the event type parameter.
105         * @param valueString The name to be set.
106         */
107        private void setEventTypeParameterName(String valueString) {
108                final String value = valueString;
109                
110                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
111                        @Override
112                        protected void doExecute() {
113 
114                                // create the parameter object if it did not exist before
115                                if(eventType.getParameter__EventType() == null){
116                                        Parameter parameter = RepositoryFactory.eINSTANCE.createParameter();
117                                        eventType.setParameter__EventType(parameter);
118                                }
119 
120                                // set the parameter name
121                                eventType.getParameter__EventType().setParameterName(value);
122                        }
123                };
124 
125                if (eventType.getParameter__EventType() == null || 
126                                !value.equals(eventType.getParameter__EventType().getParameterName())) {
127                        recCommand.setDescription("Edit EventType Parameter Property");
128                        recCommand.setLabel("Set name");
129                        editingDomain.getCommandStack().execute(recCommand);
130                }
131        }
132 
133        /**
134         * Set the data type of the parameter
135         * @param type The type to be set
136         */
137        private void setParameterType(DataType type) {
138                final DataType dataType = type;
139 
140                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
141                        @Override
142                        protected void doExecute() {
143 
144                                // create the parameter object if it did not exist before
145                                if(eventType.getParameter__EventType() == null){
146                                        Parameter parameter = RepositoryFactory.eINSTANCE.createParameter();
147                                        eventType.setParameter__EventType(parameter);
148                                }
149                                
150                                // set the parameter data type
151                                eventType.getParameter__EventType().setDataType__Parameter(dataType);
152                        }
153                };
154 
155                if (eventType.getParameter__EventType() == null || 
156                                !dataType.equals(eventType.getParameter__EventType().getDataType__Parameter())) {
157                        recCommand.setDescription("Edit EventType Parameter Property");
158                        recCommand.setLabel("Set parameter type");
159                        editingDomain.getCommandStack().execute(recCommand);
160                        // sent message to observer
161                        notifyObservers();
162                }
163                
164        }
165}

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