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

COVERAGE SUMMARY FOR SOURCE FILE [ExceptionsDialog.java]

nameclass, %method, %block, %line, %
ExceptionsDialog.java0%   (0/4)0%   (0/19)0%   (0/507)0%   (0/117)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExceptionsDialog0%   (0/1)0%   (0/13)0%   (0/434)0%   (0/102)
<static initializer> 0%   (0/1)0%   (0/16)0%   (0/3)
ExceptionsDialog (Shell, Signature): void 0%   (0/1)0%   (0/26)0%   (0/8)
access$0 (ExceptionsDialog): Text 0%   (0/1)0%   (0/3)0%   (0/1)
access$1 (ExceptionsDialog, String): void 0%   (0/1)0%   (0/4)0%   (0/1)
access$2 (ExceptionsDialog, ExceptionType): void 0%   (0/1)0%   (0/4)0%   (0/1)
access$3 (ExceptionsDialog): ExceptionType 0%   (0/1)0%   (0/3)0%   (0/1)
configureShell (Shell): void 0%   (0/1)0%   (0/7)0%   (0/3)
createButtonsForButtonBar (Composite): void 0%   (0/1)0%   (0/15)0%   (0/5)
createDialogArea (Composite): Control 0%   (0/1)0%   (0/230)0%   (0/49)
createTableViewer (Table): void 0%   (0/1)0%   (0/101)0%   (0/25)
getColumnNames (): String [] 0%   (0/1)0%   (0/2)0%   (0/1)
getInitialSize (): Point 0%   (0/1)0%   (0/6)0%   (0/1)
setExceptionTypeMessage (String): void 0%   (0/1)0%   (0/17)0%   (0/4)
     
class ExceptionsDialog$10%   (0/1)0%   (0/2)0%   (0/14)0%   (0/4)
ExceptionsDialog$1 (ExceptionsDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
modifyText (ModifyEvent): void 0%   (0/1)0%   (0/8)0%   (0/2)
     
class ExceptionsDialog$20%   (0/1)0%   (0/2)0%   (0/42)0%   (0/12)
ExceptionsDialog$2 (ExceptionsDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/36)0%   (0/10)
     
class ExceptionsDialog$30%   (0/1)0%   (0/2)0%   (0/17)0%   (0/4)
ExceptionsDialog$3 (ExceptionsDialog, TransactionalEditingDomain, String): void 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.exception;
2 
3import java.util.ArrayList;
4 
5import org.eclipse.emf.ecore.EReference;
6import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
7import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
8import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
9import org.eclipse.emf.transaction.RecordingCommand;
10import org.eclipse.emf.transaction.TransactionalEditingDomain;
11import org.eclipse.emf.transaction.util.TransactionUtil;
12import org.eclipse.jface.dialogs.IDialogConstants;
13import org.eclipse.jface.dialogs.TitleAreaDialog;
14import org.eclipse.jface.viewers.CellEditor;
15import org.eclipse.jface.viewers.ISelectionChangedListener;
16import org.eclipse.jface.viewers.IStructuredSelection;
17import org.eclipse.jface.viewers.SelectionChangedEvent;
18import org.eclipse.jface.viewers.TableViewer;
19import org.eclipse.jface.viewers.TextCellEditor;
20import org.eclipse.swt.SWT;
21import org.eclipse.swt.events.ModifyEvent;
22import org.eclipse.swt.events.ModifyListener;
23import org.eclipse.swt.events.SelectionAdapter;
24import org.eclipse.swt.graphics.Point;
25import org.eclipse.swt.layout.GridData;
26import org.eclipse.swt.layout.GridLayout;
27import org.eclipse.swt.widgets.Composite;
28import org.eclipse.swt.widgets.Control;
29import org.eclipse.swt.widgets.Group;
30import org.eclipse.swt.widgets.Shell;
31import org.eclipse.swt.widgets.Table;
32import org.eclipse.swt.widgets.TableColumn;
33import org.eclipse.swt.widgets.Text;
34import org.eclipse.swt.widgets.ToolBar;
35import org.eclipse.swt.widgets.ToolItem;
36 
37import de.uka.ipd.sdq.pcm.dialogs.DialogsImages;
38import de.uka.ipd.sdq.dialogs.selection.FilteredItemsAdapterFactory;
39import de.uka.ipd.sdq.pcm.repository.ExceptionType;
40import de.uka.ipd.sdq.pcm.repository.Signature;
41import de.uka.ipd.sdq.pcm.repository.provider.RepositoryItemProviderAdapterFactory;
42import de.uka.ipd.sdq.pcmbench.ui.provider.PalladioItemProviderAdapterFactory;
43 
44public class ExceptionsDialog extends TitleAreaDialog {
45        
46        private Signature signature;
47        private ExceptionType selecedExceptionType;
48        private Text messageField;
49        private SelectionAdapter deleteActionAdapter;
50        
51        public static final int ICON_COLUMN_INDEX = 0;
52        public static final int CONTEXT_COLUMN_INDEX = 1;
53        public static final int NAME_COLUMN_INDEX = 2;
54 
55        /**
56         * Columns of a table, which is used into ParameterEditDialog
57         */
58        public final static String ICON_COLUMN = "";
59        public final static String CONTEXT_COLUMN = "Context";
60        public final static String NAME_COLUMN = "Name";
61        
62        private final String TITLE_DIALOG = "Create/Edit a ExceptionType...";
63 
64        // Set column names of Table
65        private static String[] columnNames = new String[] { ICON_COLUMN,
66                        CONTEXT_COLUMN, NAME_COLUMN };
67 
68        private TableViewer viewer;
69 
70        /**
71         * The transactional editing domain which is used to get the commands and
72         * alter the model
73         */
74        protected TransactionalEditingDomain editingDomain = null;
75        
76        
77        public ExceptionsDialog(Shell parentShell, Signature signature) {
78                super(parentShell);
79                this.signature = signature;
80                this.deleteActionAdapter = new DeleteExctentionAction(signature);
81                this.editingDomain = TransactionUtil.getEditingDomain(signature);
82                
83                /**
84                 * the result of combining the constants which are required
85                 * to produce a typical application top level shell
86                 */
87                setShellStyle(SWT.RESIZE|SWT.TITLE|SWT.CLOSE |SWT.MIN|SWT.MAX);
88        }
89 
90        /* (non-Javadoc)
91         * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
92         */
93        @Override
94        protected void configureShell(Shell newShell) {
95                super.configureShell(newShell);
96                newShell.setText("Exceptions");
97        }
98        
99        
100        /* (non-Javadoc)
101         * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
102         */
103        @Override
104        protected Control createDialogArea(Composite parent) {
105 
106                Composite area = (Composite) super.createDialogArea(parent);
107 
108                Composite container = new Composite(area, SWT.NONE);
109                container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
110                container.setLayout(new GridLayout());
111                
112                final Group exceptionsGroup = new Group(container, SWT.NONE);
113                final GridLayout gridLayout = new GridLayout();
114                gridLayout.numColumns = 2;
115                exceptionsGroup.setLayout(gridLayout);
116                final GridData gd_group = new GridData(SWT.FILL, SWT.FILL, true, true);
117                gd_group.widthHint = 476;
118                exceptionsGroup.setLayoutData(gd_group);
119                exceptionsGroup.setText("Exeptions");
120 
121                final Table table = new Table(exceptionsGroup, SWT.BORDER|SWT.FULL_SELECTION);
122                table.setLinesVisible(true);
123                table.setHeaderVisible(true);
124                final GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true);
125                gd_table.widthHint = 401;
126                table.setLayoutData(gd_table);
127                
128                // Definere the table columns
129                final TableColumn zeroColumn = new TableColumn(table, SWT.NONE);
130                zeroColumn.setResizable(false);
131                zeroColumn.setWidth(30);
132 
133                final TableColumn contextColumn = new TableColumn(table, SWT.NONE);
134                contextColumn.setWidth(100);
135                contextColumn.setText(CONTEXT_COLUMN);
136                
137                final TableColumn nameColumn = new TableColumn(table, SWT.NONE);
138                nameColumn.setWidth(140);
139                nameColumn.setText(NAME_COLUMN);
140 
141                /** set create TableViewer instance*/
142                createTableViewer(table);
143                
144                final ToolBar toolBar = new ToolBar(exceptionsGroup, SWT.VERTICAL);
145                final GridData gd_toolBar = new GridData(SWT.FILL, SWT.FILL, false, true);
146                toolBar.setLayoutData(gd_toolBar);
147                
148                
149                ToolItem addItem = new ToolItem(toolBar, SWT.PUSH);
150                addItem.setImage(DialogsImages.imageRegistry.get(DialogsImages.ADD));
151                addItem.addSelectionListener(new AddExceptionTypeAction(signature));
152                
153                ToolItem deleteItem = new ToolItem(toolBar, SWT.PUSH);
154                deleteItem.setImage(DialogsImages.imageRegistry
155                                .get(DialogsImages.DELETE));
156                deleteItem.addSelectionListener(deleteActionAdapter);
157 
158                final Group exceptionMessageGroup = new Group(container, SWT.NONE);
159                exceptionMessageGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
160                exceptionMessageGroup.setText("Exception Message");
161                exceptionMessageGroup.setLayout(new GridLayout());
162 
163                messageField = new Text(exceptionMessageGroup, SWT.BORDER | SWT.MULTI);
164                final GridData gd_text = new GridData(SWT.FILL, SWT.CENTER, true, false);
165                gd_text.heightHint = 60;
166                messageField.setLayoutData(gd_text);
167                messageField.addModifyListener(new ModifyListener(){
168 
169                        /* (non-Javadoc)
170                         * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
171                         */
172                        public void modifyText(ModifyEvent e) {
173                                setExceptionTypeMessage(messageField.getText());
174                        }
175                });
176                
177                setTitle(TITLE_DIALOG);
178                
179                return container;
180        }
181        
182        /** Initialization of TableViewer */
183        private void createTableViewer(Table table) {
184 
185                
186                ArrayList<Object> filterList = new ArrayList<Object>();
187                filterList.add(ExceptionType.class);
188                ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
189 
190                viewer = new TableViewer(table);
191                viewer.setColumnProperties(columnNames);
192 
193                /** Create the cell editors for Name column */
194                CellEditor[] editors = new CellEditor[columnNames.length];
195 
196                editors[NAME_COLUMN_INDEX] = new TextCellEditor(table);
197 
198                /** Assign the cell editors to the viewer */
199                viewer.setCellEditors(editors);
200                viewer.setCellModifier(new ExceptionsCellModifier(viewer, TransactionUtil
201                                .getEditingDomain(signature)));
202                viewer.addSelectionChangedListener((ISelectionChangedListener) deleteActionAdapter);
203 
204                ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory();
205                adapterFactory
206                                .addAdapterFactory(new RepositoryItemProviderAdapterFactory());
207                viewer.setContentProvider(new AdapterFactoryContentProvider(
208                                new FilteredItemsAdapterFactory(adapterFactory, filterList,
209                                                additionalReferences)));
210                viewer
211                                .setLabelProvider(new AdapterFactoryLabelProvider(
212                                                new ExceptionsItemProviderAdapterFactory(
213                                                                new PalladioItemProviderAdapterFactory(
214                                                                                adapterFactory))));
215                viewer.addSelectionChangedListener(new ISelectionChangedListener() {
216                        public void selectionChanged(SelectionChangedEvent event) {
217                                IStructuredSelection sel = (IStructuredSelection) event
218                                                .getSelection();
219                                Object selection = (Object) sel.getFirstElement();
220                                selecedExceptionType = (ExceptionType) selection;
221                                if (selecedExceptionType != null
222                                                && selecedExceptionType.getExceptionMessage() != null)
223                                        messageField.setText(selecedExceptionType
224                                                        .getExceptionMessage());
225                                else
226                                        messageField.setText("");
227                        }
228                });
229                viewer.setInput(signature);
230        }
231        
232        /* (non-Javadoc)
233         * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
234         */
235        @Override
236        protected void createButtonsForButtonBar(Composite parent) {
237                createButton(parent, IDialogConstants.CANCEL_ID,
238                                IDialogConstants.CANCEL_LABEL, false);
239                createButton(parent, IDialogConstants.OK_ID,
240                                IDialogConstants.OK_LABEL, true);
241        }
242 
243        /* (non-Javadoc)
244         * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
245         */
246        @Override
247        protected Point getInitialSize() {
248                return new Point(500, 375);
249        }
250 
251        public static String[] getColumnNames() {
252                return columnNames;
253        }
254        
255        /** Set a message of ExceptionType*/
256        private void setExceptionTypeMessage(final String msg){
257                RecordingCommand recCommand = new RecordingCommand(editingDomain) {
258                        @Override
259                        protected void doExecute() {
260                                selecedExceptionType.setExceptionMessage(msg);
261                        }
262                };
263 
264                recCommand.setDescription("Delete ...");
265                editingDomain.getCommandStack().execute(recCommand);
266        }
267 
268}

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