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

nameclass, %method, %block, %line, %
OperationsCellModifier.java0%   (0/3)0%   (0/11)0%   (0/159)0%   (0/43)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OperationsCellModifier0%   (0/1)0%   (0/7)0%   (0/125)0%   (0/38)
OperationsCellModifier (): void 0%   (0/1)0%   (0/10)0%   (0/4)
access$0 (OperationsCellModifier): OperationSignature 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/41)0%   (0/15)
setReturnType (DataType): void 0%   (0/1)0%   (0/30)0%   (0/8)
setServiceName (String): void 0%   (0/1)0%   (0/28)0%   (0/7)
     
class OperationsCellModifier$10%   (0/1)0%   (0/2)0%   (0/17)0%   (0/4)
OperationsCellModifier$1 (OperationsCellModifier, TransactionalEditingDomain,... 0%   (0/1)0%   (0/10)0%   (0/2)
doExecute (): void 0%   (0/1)0%   (0/7)0%   (0/2)
     
class OperationsCellModifier$20%   (0/1)0%   (0/2)0%   (0/17)0%   (0/4)
OperationsCellModifier$2 (OperationsCellModifier, TransactionalEditingDomain,... 0%   (0/1)0%   (0/10)0%   (0/2)
doExecute (): void 0%   (0/1)0%   (0/7)0%   (0/2)

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.OperationSignature;
14import de.uka.ipd.sdq.pcmbench.tabs.generic.ObservableCellModifier;
15 
16/**
17 * @author Roman Andrej
18 * 
19 * This class implements an ICellModifier. An ICellModifier is called when the
20 * user modifes a cell in the tableViewer
21 */
22 
23public class OperationsCellModifier extends ObservableCellModifier {
24 
25        private List<String> columnNames;
26        private OperationSignature signature;
27 
28        /**
29         * The transactional editing domain which is used to get the commands and
30         * alter the model
31         */
32        protected TransactionalEditingDomain editingDomain = null;
33 
34        public OperationsCellModifier() {
35                this.columnNames = Arrays.asList(OperationsEditorSection.columnNames);
36        }
37 
38        /* (non-Javadoc)
39         * @see org.eclipse.jface.viewers.ICellModifier#canModify(Object element,
40         *      String property)
41         */
42        public boolean canModify(Object element, String property) {
43                return true;
44        }
45 
46        public Object getValue(Object element, String property) {
47                return (new OperationsTabItemProvider(null)).getColumnText(element,
48                                columnNames.indexOf(property));
49        }
50 
51        public void modify(Object element, String property, Object value) {
52 
53                // Find the index of the column
54                int columnIndex = columnNames.indexOf(property);
55 
56                Assert.isNotNull(element);
57                TableItem item = (TableItem) element;
58                signature = (OperationSignature) item.getData();
59                editingDomain = TransactionUtil.getEditingDomain(signature);
60 
61                switch (columnIndex) {
62                case OperationsEditorSection.ICON_COLUMN_INDEX: // COMPLETED_COLUMN
63                        break;
64                case OperationsEditorSection.RETURNTYPE_COLUMN_INDEX: // RETURNTYPE_COLUMN
65                        if (value instanceof DataType)
66                                setReturnType((DataType) value);
67                        break;
68                case OperationsEditorSection.SIGNATURENAME_COLUMN_INDEX: // SERVICENAME_COLUMN
69                        String valueString = ((String) value).trim();
70                        setServiceName(valueString);
71                        break;
72                case OperationsEditorSection.PARAMETER_COLUMN_INDEX: // OWNEDPARAMETER_COLUMN
73                        break;
74                case OperationsEditorSection.EXCEPTIONS_COLUMN_INDEX: // EXEPTIONTYPE_COLUM
75                        break;
76                default:
77                }
78        }
79 
80        private void setServiceName(String valueString) {
81                final String value = valueString;
82 
83                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
84                        @Override
85                        protected void doExecute() {
86                                signature.setEntityName(value);
87                        }
88                };
89 
90                if (!value.equals(signature.getEntityName())) {
91                        recCommand.setDescription("Edit Signature Property");
92                        recCommand.setLabel("Set name");
93                        editingDomain.getCommandStack().execute(recCommand);
94                }
95        }
96 
97        private void setReturnType(DataType type) {
98                final DataType dataType = type;
99 
100                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
101                        @Override
102                        protected void doExecute() {
103                                signature.setReturnType__OperationSignature(dataType);
104                        }
105                };
106 
107                if (!dataType.equals(signature.getReturnType__OperationSignature())) {
108                        recCommand.setDescription("Edit Signature Property");
109                        recCommand.setLabel("Set return type");
110                        editingDomain.getCommandStack().execute(recCommand);
111                        // sent message to observer
112                        notifyObservers();
113                }
114                
115        }
116}

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