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

COVERAGE SUMMARY FOR SOURCE FILE [ParametersCellModifier.java]

nameclass, %method, %block, %line, %
ParametersCellModifier.java0%   (0/3)0%   (0/12)0%   (0/162)0%   (0/46)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ParametersCellModifier0%   (0/1)0%   (0/8)0%   (0/128)0%   (0/41)
ParametersCellModifier (TableViewer, TransactionalEditingDomain): void 0%   (0/1)0%   (0/16)0%   (0/7)
access$0 (ParametersCellModifier): Parameter 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/37)0%   (0/14)
reloadParametersViewer (): void 0%   (0/1)0%   (0/4)0%   (0/2)
setDataType (DataType): void 0%   (0/1)0%   (0/28)0%   (0/7)
setParameterName (String): void 0%   (0/1)0%   (0/27)0%   (0/7)
     
class ParametersCellModifier$10%   (0/1)0%   (0/2)0%   (0/17)0%   (0/4)
ParametersCellModifier$1 (ParametersCellModifier, TransactionalEditingDomain,... 0%   (0/1)0%   (0/10)0%   (0/2)
doExecute (): void 0%   (0/1)0%   (0/7)0%   (0/2)
     
class ParametersCellModifier$20%   (0/1)0%   (0/2)0%   (0/17)0%   (0/4)
ParametersCellModifier$2 (ParametersCellModifier, 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.pcm.dialogs.parameters;
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.jface.viewers.ICellModifier;
10import org.eclipse.jface.viewers.TableViewer;
11import org.eclipse.swt.widgets.TableItem;
12 
13import de.uka.ipd.sdq.pcm.repository.DataType;
14import de.uka.ipd.sdq.pcm.repository.Parameter;
15 
16/**
17 * The class define the CellModifire for the ParametersDialog
18 * 
19 * @author Roman Andrej
20 */
21public class ParametersCellModifier implements ICellModifier {
22 
23        private TableViewer viewer;
24        private List<String> columnNames;
25        private Parameter parameter;
26 
27        /**
28         * The transactional editing domain which is used to get the commands and
29         * alter the model
30         */
31        private TransactionalEditingDomain editingDomain = null;
32 
33        public ParametersCellModifier(TableViewer viewer, TransactionalEditingDomain editingDomain) {
34                this.viewer = viewer;
35                this.columnNames = Arrays.asList(CreateEditorContents
36                                .getColumnNames());
37                this.editingDomain = editingDomain;
38        }
39 
40        /*
41         * (non-Javadoc)
42         * 
43         * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object,
44         *      java.lang.String)
45         */
46        public boolean canModify(Object element, String property) {
47                return true;
48        }
49 
50        /* (non-Javadoc)
51         * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object,
52         *      java.lang.String)
53         */
54        public Object getValue(Object element, String property) {
55                return (new ParametersItemProvider(null)).getColumnText(element,
56                                columnNames.indexOf(property));
57        }
58 
59        /* (non-Javadoc)
60         * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object,
61         *      java.lang.String, java.lang.Object)
62         */
63        public void modify(Object element, String property, Object value) {
64 
65                // Find the index of the column
66                int columnIndex = columnNames.indexOf(property);
67 
68                Assert.isNotNull(element);
69                TableItem item = (TableItem) element;
70                parameter = (Parameter) item.getData();
71 
72                switch (columnIndex) {
73                case CreateEditorContents.ICON_COLUMN_INDEX: // COMPLETED_COLUMN
74                        break;
75                case CreateEditorContents.CONTEXT_COLUMN_INDEX: // RETURNTYPE_COLUMN
76                        break;
77                case CreateEditorContents.NAME_COLUMN_INDEX: // SERVICENAME_COLUMN
78                        String valueString = ((String) value).trim();
79                        setParameterName(valueString);
80                        break;
81                case CreateEditorContents.TYPE_COLUMN_INDEX: // OWNEDPARAMETER_COLUMN
82                        if (value instanceof DataType) {
83                                DataType valueDataType = (DataType) value;
84                                setDataType(valueDataType);
85                        }
86                        break;
87                default:
88                }
89        }
90 
91        /** set parameter DataType */
92        private void setDataType(final DataType dataType) {
93 
94                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
95                        @Override
96                        protected void doExecute() {
97                                parameter.setDataType__Parameter(dataType);
98                        }
99                };
100 
101                if (!dataType.equals(parameter.getDataType__Parameter())) {
102                        recCommand.setDescription("Edit Parameter Property");
103                        recCommand.setLabel("Set parameter DataType");
104                        editingDomain.getCommandStack().execute(recCommand);
105                }
106                
107                reloadParametersViewer();
108        }
109 
110        /** set the parameter name */
111        private void setParameterName(String valueString) {
112                final String value = valueString;
113 
114                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
115                        @Override
116                        protected void doExecute() {
117                                parameter.setParameterName(value);
118                        }
119                };
120 
121                if (!value.equals(parameter.getParameterName())) {
122                        recCommand.setLabel("Set ParameterName");
123                        editingDomain.getCommandStack().execute(recCommand);
124                }
125                reloadParametersViewer();
126        }
127 
128        private void reloadParametersViewer() {
129                viewer.refresh();
130        }
131}

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