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

COVERAGE SUMMARY FOR SOURCE FILE [DatasourceDialog.java]

nameclass, %method, %block, %line, %
DatasourceDialog.java0%   (0/3)0%   (0/19)0%   (0/452)0%   (0/100)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DatasourceDialog0%   (0/1)0%   (0/15)0%   (0/411)0%   (0/90)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/2)
DatasourceDialog (Shell, String, Object, boolean): void 0%   (0/1)0%   (0/16)0%   (0/6)
access$0 (DatasourceDialog, IDAOFactory): void 0%   (0/1)0%   (0/4)0%   (0/1)
access$1 (DatasourceDialog): IDAOFactory 0%   (0/1)0%   (0/3)0%   (0/1)
access$2 (DatasourceDialog, Object): void 0%   (0/1)0%   (0/4)0%   (0/1)
configureShell (Shell): void 0%   (0/1)0%   (0/14)0%   (0/4)
createButtonsForButtonBar (Composite): void 0%   (0/1)0%   (0/20)0%   (0/6)
createDialogArea (Composite): Control 0%   (0/1)0%   (0/286)0%   (0/50)
getInitialSize (): Point 0%   (0/1)0%   (0/6)0%   (0/1)
getResult (): Object 0%   (0/1)0%   (0/3)0%   (0/1)
refresh (): void 0%   (0/1)0%   (0/4)0%   (0/2)
setAddButtonAction (SelectionListener): void 0%   (0/1)0%   (0/5)0%   (0/2)
setOpenButtonAction (SelectionListener): void 0%   (0/1)0%   (0/5)0%   (0/2)
setRemoveButtonAction (SelectionListener): void 0%   (0/1)0%   (0/5)0%   (0/2)
validationOKButton (Object): void 0%   (0/1)0%   (0/33)0%   (0/10)
     
class DatasourceDialog$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
DatasourceDialog$1 (DatasourceDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
shellClosed (ShellEvent): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class DatasourceDialog$20%   (0/1)0%   (0/2)0%   (0/30)0%   (0/9)
DatasourceDialog$2 (DatasourceDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/24)0%   (0/7)

1package de.uka.ipd.sdq.sensorframework.dialogs.dataset;
2 
3import org.eclipse.jface.dialogs.IDialogConstants;
4import org.eclipse.jface.dialogs.TitleAreaDialog;
5import org.eclipse.jface.viewers.ISelection;
6import org.eclipse.jface.viewers.ISelectionChangedListener;
7import org.eclipse.jface.viewers.IStructuredSelection;
8import org.eclipse.jface.viewers.SelectionChangedEvent;
9import org.eclipse.jface.viewers.TableViewer;
10import org.eclipse.swt.SWT;
11import org.eclipse.swt.events.SelectionListener;
12import org.eclipse.swt.events.ShellAdapter;
13import org.eclipse.swt.events.ShellEvent;
14import org.eclipse.swt.graphics.Point;
15import org.eclipse.swt.layout.FormAttachment;
16import org.eclipse.swt.layout.FormData;
17import org.eclipse.swt.layout.FormLayout;
18import org.eclipse.swt.layout.GridData;
19import org.eclipse.swt.widgets.Button;
20import org.eclipse.swt.widgets.Composite;
21import org.eclipse.swt.widgets.Control;
22import org.eclipse.swt.widgets.Label;
23import org.eclipse.swt.widgets.Shell;
24import org.eclipse.swt.widgets.Table;
25 
26import de.uka.ipd.sdq.sensorframework.dao.memory.MemoryDAOFactory;
27import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory;
28 
29public class DatasourceDialog extends TitleAreaDialog {
30 
31        private static String DIALOG_TITLE = "Create/Load the data source.";
32        
33        private Button addButton, removeButton, okButton, openButton;
34        private Object input;
35        private IDAOFactory selectedDataSet;
36        private TableViewer viewer;
37        private boolean buttonValidation;
38        private String dialogTitle;
39        
40        /** Create the dialog */
41        public DatasourceDialog(Shell parentShell, String dialogTitle,
42                        Object input, boolean makeButtonValidation) {
43                super(parentShell);
44                this.dialogTitle = dialogTitle;
45                this.input = input;
46                this.buttonValidation = makeButtonValidation;
47 
48                /**
49                 * the result of combining the constants which are required to produce a
50                 * typical application top level shell
51                 */
52                setShellStyle(SWT.RESIZE | SWT.MAX | SWT.CLOSE);
53        }
54        
55        /* (non-Javadoc)
56         * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
57         */
58        @Override
59        protected void configureShell(Shell newShell) {
60                super.configureShell(newShell);
61                newShell.setText(dialogTitle);
62                newShell.addShellListener(new ShellAdapter(){
63 
64                        /* (non-Javadoc)
65                         * @see org.eclipse.swt.events.ShellAdapter#shellClosed(org.eclipse.swt.events.ShellEvent)
66                         */
67                        @Override
68                        public void shellClosed(ShellEvent e) {
69                                selectedDataSet= null;
70                        }
71                });
72        }
73 
74        /* (non-Javadoc)
75         * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
76         */
77        @Override
78        protected Control createDialogArea(Composite parent) {
79                Composite area = (Composite) super.createDialogArea(parent);
80                Composite container = new Composite(area, SWT.NONE);
81                container.setLayout(new FormLayout());
82                container.setLayoutData(new GridData(GridData.FILL_BOTH));
83 
84                /** 'Add..' button */
85                addButton = new Button(container, SWT.NONE);
86                final FormData fd_addButton = new FormData();
87                fd_addButton.right = new FormAttachment(100, -5);
88                fd_addButton.bottom = new FormAttachment(0, 31);
89                fd_addButton.top = new FormAttachment(0, 5);
90                addButton.setLayoutData(fd_addButton);
91                addButton.setText("Add..");
92                
93                /** 'Remove' button */
94                removeButton = new Button(container, SWT.NONE);
95                final FormData fd_removeButton = new FormData();
96                fd_removeButton.right = new FormAttachment(100, -5);
97                fd_removeButton.bottom = new FormAttachment(0, 61);
98                fd_removeButton.top = new FormAttachment(0, 35);
99                removeButton.setLayoutData(fd_removeButton);
100                removeButton.setText("Remove");
101 
102                /** 'Open..' button */
103                openButton = new Button(container, SWT.NONE);
104                final FormData fd_openButton = new FormData();
105                fd_openButton.left = new FormAttachment(100, -84);
106                fd_openButton.right = new FormAttachment(100, -5);
107                fd_openButton.bottom = new FormAttachment(0, 91);
108                fd_openButton.top = new FormAttachment(0, 65);
109                openButton.setLayoutData(fd_openButton);
110                openButton.setText("Open..");
111 
112                Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
113                final FormData fd_label = new FormData();
114                fd_label.bottom = new FormAttachment(100, 2);
115                fd_label.right = new FormAttachment(100, 2);
116                fd_label.left = new FormAttachment(0, -6);
117                separator.setLayoutData(fd_label);
118                separator.setText("Label");
119 
120                Table list = new Table(container, SWT.BORDER);
121                fd_label.top = new FormAttachment(list, 28, SWT.DEFAULT);
122                fd_removeButton.left = new FormAttachment(list, 6, SWT.DEFAULT);
123                fd_addButton.left = new FormAttachment(list, 6, SWT.DEFAULT);
124                final FormData fd_list = new FormData();
125                fd_list.bottom = new FormAttachment(100, -32);
126                fd_list.right = new FormAttachment(100, -89);
127                fd_list.top = new FormAttachment(0, 4);
128                fd_list.left = new FormAttachment(0, 5);
129                list.setLayoutData(fd_list);
130 
131                /** create a ListViewer */
132                viewer = new TableViewer(list);
133                viewer.setContentProvider(new DatasourceListContentProvider());
134                viewer.setLabelProvider(new DatasourceListLabelProvider());
135                viewer.addSelectionChangedListener(new ISelectionChangedListener(){
136 
137                        public void selectionChanged(SelectionChangedEvent event) {
138                                ISelection selection = event.getSelection();
139                                if (selection instanceof IStructuredSelection) {
140                                        IStructuredSelection sel = (IStructuredSelection) selection;
141                                        Object object = sel.getFirstElement();
142                                        selectedDataSet = (IDAOFactory) object;
143                                        validationOKButton(selectedDataSet);
144                                }
145                                
146                        }
147                });
148                viewer.setInput(input);
149                
150                setTitle(DIALOG_TITLE);
151 
152                return container;
153        }
154 
155        /* (non-Javadoc)
156         * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
157         */
158        @Override
159        protected void createButtonsForButtonBar(Composite parent) {
160                createButton(parent, IDialogConstants.CANCEL_ID,
161                                IDialogConstants.CANCEL_LABEL, false);
162                okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
163                                true);
164                validationOKButton(selectedDataSet);
165        }
166        
167        private void validationOKButton(Object selection) {
168                setErrorMessage(null);
169                okButton.setEnabled(true);
170 
171                if (buttonValidation && selection == null) {
172                        okButton.setEnabled(false);
173                        setErrorMessage("No Datasource selected!");
174                }
175                
176                if (selection instanceof MemoryDAOFactory) {
177                        MemoryDAOFactory memoryDAO = (MemoryDAOFactory) selection;
178                        setTitle("Description:");
179                        setMessage(memoryDAO.getDescription());
180                }
181        }
182        
183        protected void setAddButtonAction(SelectionListener listener){
184                addButton.addSelectionListener(listener);
185        }
186        
187        protected void setRemoveButtonAction(SelectionListener listener){
188                removeButton.addSelectionListener(listener);
189        }
190        
191        protected void setOpenButtonAction(SelectionListener listener){
192                openButton.addSelectionListener(listener);
193        }
194 
195        /* (non-Javadoc)
196         * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
197         */
198        @Override
199        protected Point getInitialSize() {
200                return new Point(400, 350);
201        }
202 
203        public Object getResult(){
204                return selectedDataSet;
205        }
206        
207        protected void refresh(){
208                viewer.refresh();
209        }
210}

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