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

nameclass, %method, %block, %line, %
EventTypesEditorSection.java0%   (0/2)0%   (0/15)0%   (0/185)0%   (0/46)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EventTypesEditorSection0%   (0/1)0%   (0/13)0%   (0/131)0%   (0/31)
<static initializer> 0%   (0/1)0%   (0/20)0%   (0/3)
EventTypesEditorSection (Composite): void 0%   (0/1)0%   (0/4)0%   (0/2)
canAddButonCreated (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
canDeleteButonCreated (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
createAddButtonActionListener (): SelectionListener 0%   (0/1)0%   (0/8)0%   (0/2)
createDeleteButtonListener (): SelectionListener 0%   (0/1)0%   (0/4)0%   (0/1)
createTableColumns (Table): void 0%   (0/1)0%   (0/37)0%   (0/8)
createViewerCellEditors (Table): CellEditor [] 0%   (0/1)0%   (0/39)0%   (0/8)
createViewerCellModifier (): ObservableCellModifier 0%   (0/1)0%   (0/4)0%   (0/1)
getAddButtonListener (): EventTypeAddActionListener 0%   (0/1)0%   (0/3)0%   (0/1)
getSelectedEventType (): EventType 0%   (0/1)0%   (0/4)0%   (0/1)
getTableColumnNames (): String [] 0%   (0/1)0%   (0/2)0%   (0/1)
inputValidation (EObject): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
     
class EventTypesEditorSection$10%   (0/1)0%   (0/2)0%   (0/54)0%   (0/16)
EventTypesEditorSection$1 (EventTypesEditorSection, Composite, SelectionListe... 0%   (0/1)0%   (0/8)0%   (0/2)
openDialogBox (Control): Object 0%   (0/1)0%   (0/46)0%   (0/14)

1package de.uka.ipd.sdq.pcmbench.tabs.operations;
2 
3 
4import java.util.ArrayList;
5 
6import org.eclipse.emf.ecore.EObject;
7import org.eclipse.emf.ecore.EReference;
8import org.eclipse.emf.transaction.TransactionalEditingDomain;
9import org.eclipse.emf.transaction.util.TransactionUtil;
10import org.eclipse.jface.viewers.CellEditor;
11import org.eclipse.jface.viewers.TextCellEditor;
12import org.eclipse.swt.SWT;
13import org.eclipse.swt.events.SelectionListener;
14import org.eclipse.swt.widgets.Composite;
15import org.eclipse.swt.widgets.Control;
16import org.eclipse.swt.widgets.Table;
17import org.eclipse.swt.widgets.TableColumn;
18 
19import de.uka.ipd.sdq.pcm.dialogs.datatype.CallDataTypeDialog;
20import de.uka.ipd.sdq.pcm.repository.DataType;
21import de.uka.ipd.sdq.pcm.repository.EventType;
22import de.uka.ipd.sdq.pcm.repository.Repository;
23import de.uka.ipd.sdq.pcmbench.tabs.generic.EditorSection;
24import de.uka.ipd.sdq.pcmbench.tabs.generic.ObservableCellModifier;
25 
26public class EventTypesEditorSection extends EditorSection{
27 
28        public static final int ICON_COLUMN_INDEX = 0;
29        public static final int EVENTTYPENAME_COLUMN_INDEX = 1;
30        public static final int PARAMETER_NAME_COLUMN_INDEX = 2;
31        public static final int PARAMETER_TYPE_COLUMN_INDEX = 3;
32        
33        /**
34         * Columns of a table, which is used into operations table
35         */
36        public final static String OPERATIONS_ICON_COLUMN        = "";
37        public final static String OWNEDPARAMETER_NAME_COLUMN         = "Event Name";
38        public final static String OWNEDPARAMETER_TYPE_COLUMN         = "Event DataType";
39        public final static String SERVICENAME_COLUMN                 = "EventTypeName";
40        
41        //         Set column names of Table
42        public static String[] columnNames = new String[] { OPERATIONS_ICON_COLUMN,
43                        SERVICENAME_COLUMN, OWNEDPARAMETER_NAME_COLUMN,OWNEDPARAMETER_TYPE_COLUMN };
44        
45        /** Define the Add-Button listener. Listener must by later initialized. */
46        private EventTypeAddActionListener addButtonListener;
47 
48        /** Constructor */
49        public EventTypesEditorSection(Composite composite) {
50                super(composite);
51        }
52 
53        /* (non-Javadoc)
54         * @see de.uka.ipd.sdq.pcmbench.tabs.generic.EditorSection#createViewerCellEditors(org.eclipse.swt.widgets.Table)
55         */
56        @Override
57        protected CellEditor[] createViewerCellEditors(Table table) {
58                CellEditor[] editors = new CellEditor[columnNames.length];
59 
60                editors[EVENTTYPENAME_COLUMN_INDEX] = new TextCellEditor(table);
61 
62                // create 'DeleteCellValueListener' and as SelectionListener to the 'TableVewer'
63                EventTypeDeleteCellValueListener cellValueListener = new EventTypeDeleteCellValueListener(viewer);
64                viewer.addSelectionChangedListener(cellValueListener);
65 
66                editors[PARAMETER_NAME_COLUMN_INDEX] = new TextCellEditor(table);
67 
68                editors[PARAMETER_TYPE_COLUMN_INDEX] = new TypeDialogCellEditor(table,
69                                cellValueListener) {
70                        
71                        /* (non-Javadoc)
72                         * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
73                         */
74                        @Override
75                        protected Object openDialogBox(Control cellEditorWindow) {
76                                
77                                TransactionalEditingDomain editingDomain = TransactionUtil
78                                .getEditingDomain(getSelectedEventType());
79 
80                                ArrayList<Object> filterList = new ArrayList<Object>();
81                                filterList.add(DataType.class);
82                                filterList.add(Repository.class);
83                                ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
84        
85                                CallDataTypeDialog dialog = new CallDataTypeDialog(
86                                                cellEditorWindow.getShell(), filterList,
87                                                additionalReferences, editingDomain.getResourceSet());
88                                dialog.setProvidedService(DataType.class);
89                                dialog.open();
90 
91                                if (!(dialog.getResult() instanceof DataType))
92                                        return null;
93 
94                                return dialog.getResult();
95                        }
96                };
97 
98                return editors;
99        }
100        
101        /**
102         * Initialise the cell modifier.
103         * @return The cell modifier.
104         * @see de.uka.ipd.sdq.pcmbench.tabs.generic.EditorSection#createViewerCellModifier()
105         */
106        @Override
107        protected ObservableCellModifier createViewerCellModifier() {
108                return new EventTypesCellModifier();
109        }
110 
111        /**
112         * Create the table columns.
113         * @param table The table object to add the columns to.
114         * 
115         * @see de.uka.ipd.sdq.pcmbench.tabs.generic.EditorSection#createTableColumns(org.eclipse.swt.widgets.Table)
116         */
117        @Override
118        protected void createTableColumns(Table table) {
119                // 1st column
120                TableColumn column = new TableColumn(table, SWT.CENTER, 0);
121                column.setText("");
122                column.setWidth(25);
123 
124                for (int i = 1; i < columnNames.length; i++) {
125                        // n-te column with task Description
126                        column = new TableColumn(table, SWT.LEFT, i);
127                        column.setText((String) columnNames[i]);
128                        column.setWidth(140);
129                }
130        }
131        
132        /**
133         * Add Action button.
134         * Note: This method has been aligned with he OperationsEditorserction and there was no
135         * explanation why the implementation does exactly the opposite of the included comment.
136         * 
137         * @see de.uka.ipd.sdq.pcmbench.tabs.generic.EditorSection#createAddButtonActionListener()
138         */
139        @Override
140        protected SelectionListener createAddButtonActionListener() {
141                // the value must by initialized! (don't return new AddActionListener()) 
142                this.addButtonListener = new EventTypeAddActionListener();
143                
144                return addButtonListener;
145        }
146 
147        /**
148         * Default deletion button.
149         * @see de.uka.ipd.sdq.pcmbench.tabs.generic.EditorSection#createDeleteButtonListener()
150         */
151        @Override
152        protected SelectionListener createDeleteButtonListener() {
153                return new EventTypeDeleteActionListener();
154        }
155 
156        /* (non-Javadoc)
157         * @see de.uka.ipd.sdq.pcmbench.tabs.generic.EditorSection#getViewerColumnProperties()
158         */
159        @Override
160        protected String[] getTableColumnNames() {
161                return columnNames;
162        }
163        
164        /* (non-Javadoc)
165         * @see de.uka.ipd.sdq.pcmbench.tabs.generic.EditorSection#canAddButonCreated()
166         */
167        @Override
168        protected boolean canAddButonCreated() {
169                return true;
170        }
171 
172        /* (non-Javadoc)
173         * @see de.uka.ipd.sdq.pcmbench.tabs.generic.EditorSection#canDeleteButonCreated()
174         */
175        @Override
176        protected boolean canDeleteButonCreated() {
177                return true;
178        }
179        
180        /* (non-Javadoc)
181         * @see de.uka.ipd.sdq.pcmbench.tabs.generic.EditorSection#inputValidation(org.eclipse.emf.ecore.EObject)
182         */
183        @Override
184        protected boolean inputValidation(EObject object) {
185                return true;
186        }
187 
188        public EventType getSelectedEventType() {
189                return (EventType) getSelectedObject();
190        }
191 
192        /**
193         * @return the addButtonListener
194         */
195        public EventTypeAddActionListener getAddButtonListener() {
196                return addButtonListener;
197        }
198}

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