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

COVERAGE SUMMARY FOR SOURCE FILE [InnerDeclarationCellModifier.java]

nameclass, %method, %block, %line, %
InnerDeclarationCellModifier.java0%   (0/3)0%   (0/12)0%   (0/154)0%   (0/43)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InnerDeclarationCellModifier0%   (0/1)0%   (0/8)0%   (0/120)0%   (0/38)
InnerDeclarationCellModifier (PalladioDataTypeDialog, TransactionalEditingDom... 0%   (0/1)0%   (0/13)0%   (0/6)
access$0 (InnerDeclarationCellModifier): InnerDeclaration 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)
reloadDeclarationViewer (): void 0%   (0/1)0%   (0/4)0%   (0/2)
setDataType (DataType): void 0%   (0/1)0%   (0/25)0%   (0/6)
setDeclarationName (String): void 0%   (0/1)0%   (0/25)0%   (0/6)
     
class InnerDeclarationCellModifier$10%   (0/1)0%   (0/2)0%   (0/17)0%   (0/4)
InnerDeclarationCellModifier$1 (InnerDeclarationCellModifier, TransactionalEd... 0%   (0/1)0%   (0/10)0%   (0/2)
doExecute (): void 0%   (0/1)0%   (0/7)0%   (0/2)
     
class InnerDeclarationCellModifier$20%   (0/1)0%   (0/2)0%   (0/17)0%   (0/4)
InnerDeclarationCellModifier$2 (InnerDeclarationCellModifier, TransactionalEd... 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.datatype;
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.swt.widgets.TableItem;
11 
12import de.uka.ipd.sdq.pcm.dialogs.parameters.CreateEditorContents;
13import de.uka.ipd.sdq.pcm.repository.DataType;
14import de.uka.ipd.sdq.pcm.repository.InnerDeclaration;
15 
16public class InnerDeclarationCellModifier implements ICellModifier {
17 
18        private PalladioDataTypeDialog dialog;
19        private List<String> columnNames;
20        private InnerDeclaration declaration;
21        
22        private TransactionalEditingDomain editingDomain;
23 
24        public InnerDeclarationCellModifier(PalladioDataTypeDialog dialog, TransactionalEditingDomain editingDomain) {
25                this.editingDomain = editingDomain;
26                this.dialog = dialog;
27                this.columnNames = Arrays.asList(CreateEditorContents
28                                .getColumnNames());
29        }
30 
31        /* (non-Javadoc)
32         * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object,
33         *      java.lang.String)
34         */
35        public boolean canModify(Object element, String property) {
36                return true;
37        }
38 
39        /* (non-Javadoc)
40         * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object,
41         *      java.lang.String)
42         */
43        public Object getValue(Object element, String property) {
44                return (new InnerDeclarationItemProvider(null)).getColumnText(element,
45                                columnNames.indexOf(property));
46        }
47 
48        /* (non-Javadoc)
49         * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object,
50         *      java.lang.String, java.lang.Object)
51         */
52        public void modify(Object element, String property, Object value) {
53                // Find the index of the column
54                int columnIndex = columnNames.indexOf(property);
55 
56                Assert.isNotNull(element);
57                TableItem item = (TableItem) element;
58                declaration = (InnerDeclaration) item.getData();
59 
60                switch (columnIndex) {
61                case CreateEditorContents.ICON_COLUMN_INDEX: // COMPLETED_COLUMN
62                        break;
63                case CreateEditorContents.CONTEXT_COLUMN_INDEX: // RETURNTYPE_COLUMN
64                        break;
65                case CreateEditorContents.NAME_COLUMN_INDEX: // SERVICENAME_COLUMN
66                        String valueString = ((String) value).trim();
67                        setDeclarationName(valueString);
68                        break;
69                case CreateEditorContents.TYPE_COLUMN_INDEX: // OWNEDPARAMETER_COLUMN
70                        if (value instanceof DataType) {
71                                DataType valueDataType = (DataType) value;
72                                setDataType(valueDataType);
73                        }
74                        break;
75                default:
76                }
77        }
78 
79        /**
80         * @param - inner datatype of declaration
81         */
82        private void setDataType(final DataType dataType) {
83 
84                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
85                        @Override
86                        protected void doExecute() {
87                                declaration.setDatatype_InnerDeclaration(dataType);
88                        }
89                };
90 
91                if (!dataType.equals(declaration.getDatatype_InnerDeclaration())) {
92                        recCommand.setLabel("Set InnerDeclaration DataType");
93                        editingDomain.getCommandStack().execute(recCommand);
94                }
95                reloadDeclarationViewer();
96        }
97 
98        /** set the name of innerdeclaration */
99        private void setDeclarationName(final String valueString) {
100 
101                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
102                        @Override
103                        protected void doExecute() {
104                                declaration.setEntityName(valueString);
105                        }
106                };
107 
108                if (!valueString.equals(declaration.getEntityName())) {
109                        recCommand.setLabel("Set InnerDeclaration name");
110                        editingDomain.getCommandStack().execute(recCommand);
111                }
112                
113                reloadDeclarationViewer();
114        }
115 
116        private void reloadDeclarationViewer() {
117                dialog.refresh();
118        }
119}

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