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

COVERAGE SUMMARY FOR SOURCE FILE [SensorsDialog.java]

nameclass, %method, %block, %line, %
SensorsDialog.java0%   (0/3)0%   (0/10)0%   (0/244)0%   (0/51)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SensorsDialog0%   (0/1)0%   (0/6)0%   (0/196)0%   (0/44)
<static initializer> 0%   (0/1)0%   (0/16)0%   (0/3)
SensorsDialog (Shell, ConfigEntry): void 0%   (0/1)0%   (0/7)0%   (0/3)
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/145)0%   (0/29)
getInitialSize (): Point 0%   (0/1)0%   (0/6)0%   (0/1)
     
class SensorsDialog$10%   (0/1)0%   (0/2)0%   (0/13)0%   (0/4)
SensorsDialog$1 (SensorsDialog, TableViewer): void 0%   (0/1)0%   (0/9)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class SensorsDialog$20%   (0/1)0%   (0/2)0%   (0/35)0%   (0/6)
SensorsDialog$2 (SensorsDialog): void 0%   (0/1)0%   (0/6)0%   (0/2)
compare (Viewer, Object, Object): int 0%   (0/1)0%   (0/29)0%   (0/4)

1package de.uka.ipd.sdq.sensorframework.visualisation.dialogs;
2 
3import org.eclipse.jface.dialogs.IDialogConstants;
4import org.eclipse.jface.dialogs.TitleAreaDialog;
5import org.eclipse.jface.viewers.CellEditor;
6import org.eclipse.jface.viewers.CheckboxCellEditor;
7import org.eclipse.jface.viewers.ISelectionChangedListener;
8import org.eclipse.jface.viewers.SelectionChangedEvent;
9import org.eclipse.jface.viewers.TableViewer;
10import org.eclipse.jface.viewers.Viewer;
11import org.eclipse.jface.viewers.ViewerComparator;
12import org.eclipse.swt.SWT;
13import org.eclipse.swt.graphics.Point;
14import org.eclipse.swt.layout.GridData;
15import org.eclipse.swt.layout.GridLayout;
16import org.eclipse.swt.widgets.Composite;
17import org.eclipse.swt.widgets.Control;
18import org.eclipse.swt.widgets.Shell;
19import org.eclipse.swt.widgets.Table;
20import org.eclipse.swt.widgets.TableColumn;
21 
22import de.uka.ipd.sdq.sensorframework.entities.Sensor;
23import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEntry;
24 
25/**
26 * TODO
27 * @author admin
28 *
29 */
30public class SensorsDialog extends TitleAreaDialog {
31 
32        private ConfigEntry entry;
33 
34        public static final int CHECK_COLUMN_INDEX = 0;
35        public static final int SENSOR_ID_INDEX = 1;
36        public static final int SENSOR_NAME_COLUMN_INDEX = 2;
37 
38        /**
39         * Columns of a table, which is used into ParameterEditDialog
40         */
41        public final static String CHECK_COLUMN = "";
42        public final static String SENSOR_ID_COLUMN = "Id";
43        public final static String SENSOR_NAME_COLUMN = "Sensorname";
44 
45        // Set column names of Tabele
46        public static String[] columnNames = new String[] { CHECK_COLUMN,
47                        SENSOR_ID_COLUMN, SENSOR_NAME_COLUMN };
48 
49        private Table table;
50 
51        public SensorsDialog(Shell parentShell, ConfigEntry entry) {
52                super(parentShell);
53                this.entry = entry;
54        }
55 
56        /* (non-Javadoc)
57         * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
58         */
59        @Override
60        protected Control createDialogArea(Composite parent) {
61                Composite area = (Composite) super.createDialogArea(parent);
62                Composite container = new Composite(area, SWT.NONE);
63                container.setLayout(new GridLayout());
64                container.setLayoutData(new GridData(GridData.FILL_BOTH));
65 
66                final TableViewer tableViewer = new TableViewer(container, SWT.BORDER);
67                                //| SWT.CHECK);
68                table = tableViewer.getTable();
69                table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
70                table.setLinesVisible(true);
71                table.setHeaderVisible(true);
72 
73                final TableColumn checkColumn = new TableColumn(table, SWT.LEFT);
74                checkColumn.setWidth(24);
75                checkColumn.setText(CHECK_COLUMN);
76 
77                final TableColumn experimentColumn = new TableColumn(table, SWT.LEFT);
78                experimentColumn.setWidth(40);
79                experimentColumn.setText(SENSOR_ID_COLUMN);
80 
81                final TableColumn sensorColumn = new TableColumn(table, SWT.LEFT);
82                sensorColumn.setWidth(260);
83                sensorColumn.setText(SENSOR_NAME_COLUMN);
84 
85                CellEditor[] editors = new CellEditor[columnNames.length];
86 
87                // Column 1 : Completed (Checkbox)
88                editors[0] = new CheckboxCellEditor(table);
89 
90                tableViewer.addSelectionChangedListener(new ISelectionChangedListener(){
91 
92                        public void selectionChanged(SelectionChangedEvent event) {
93                                tableViewer.refresh();
94                        }
95                });
96                // Assign the cell editors to the viewer
97                tableViewer.setColumnProperties(columnNames);
98                tableViewer.setCellEditors(editors);
99                tableViewer.setCellModifier(new SensorsDialogCellModifier(entry));
100                tableViewer.setContentProvider(new SensorsDialogContentProvider());
101                tableViewer.setLabelProvider(new SensorsDialogLabelProvider(entry));
102                tableViewer.setComparator(new ViewerComparator() {
103                    
104                    @Override
105                    public int compare(Viewer viewer, Object e1, Object e2) {
106                        if (e1 instanceof Sensor  && e2 instanceof Sensor ) {
107                            return ((Sensor ) e1).getSensorName().compareToIgnoreCase(
108                                   ((Sensor ) e2).getSensorName());
109                        }
110                        throw new IllegalArgumentException("Not comparable: " + e1 + " " + e2);
111                    }
112 
113                });
114 
115                tableViewer.setInput(entry);
116                
117                //
118                return area;
119        }
120 
121        /* (non-Javadoc)
122         * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
123         */
124        @Override
125        protected void createButtonsForButtonBar(Composite parent) {
126                createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
127                                true);
128                createButton(parent, IDialogConstants.CANCEL_ID,
129                                IDialogConstants.CANCEL_LABEL, false);
130        }
131 
132        /* (non-Javadoc)
133         * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
134         */
135        @Override
136        protected Point getInitialSize() {
137                return new Point(400, 350);
138        }
139 
140        /* (non-Javadoc)
141         * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
142         */
143        @Override
144        protected void configureShell(Shell newShell) {
145                super.configureShell(newShell);
146                newShell.setText("Select sensors");
147        }
148}

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