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

COVERAGE SUMMARY FOR SOURCE FILE [SensorsPropertySection.java]

nameclass, %method, %block, %line, %
SensorsPropertySection.java0%   (0/5)0%   (0/20)0%   (0/462)0%   (0/102)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SensorsPropertySection0%   (0/1)0%   (0/12)0%   (0/345)0%   (0/76)
<static initializer> 0%   (0/1)0%   (0/20)0%   (0/3)
SensorsPropertySection (): void 0%   (0/1)0%   (0/9)0%   (0/3)
access$0 (SensorsPropertySection): TableViewer 0%   (0/1)0%   (0/3)0%   (0/1)
access$1 (SensorsPropertySection, ConfigEntry): void 0%   (0/1)0%   (0/4)0%   (0/1)
access$2 (SensorsPropertySection): ConfigEntry 0%   (0/1)0%   (0/3)0%   (0/1)
access$3 (SensorsPropertySection): ToolItem 0%   (0/1)0%   (0/3)0%   (0/1)
access$4 (SensorsPropertySection): ConfigEditorInput 0%   (0/1)0%   (0/3)0%   (0/1)
createControls (Composite, TabbedPropertySheetPage): void 0%   (0/1)0%   (0/266)0%   (0/55)
getSelection (): ISelection 0%   (0/1)0%   (0/3)0%   (0/1)
refresh (): void 0%   (0/1)0%   (0/4)0%   (0/2)
setInput (IWorkbenchPart, ISelection): void 0%   (0/1)0%   (0/21)0%   (0/6)
update (Observable, Object): void 0%   (0/1)0%   (0/6)0%   (0/3)
     
class SensorsPropertySection$10%   (0/1)0%   (0/2)0%   (0/34)0%   (0/9)
SensorsPropertySection$1 (SensorsPropertySection): void 0%   (0/1)0%   (0/6)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/28)0%   (0/7)
     
class SensorsPropertySection$20%   (0/1)0%   (0/2)0%   (0/25)0%   (0/7)
SensorsPropertySection$2 (SensorsPropertySection, Composite): void 0%   (0/1)0%   (0/7)0%   (0/2)
openDialogBox (Control): Object 0%   (0/1)0%   (0/18)0%   (0/5)
     
class SensorsPropertySection$30%   (0/1)0%   (0/2)0%   (0/44)0%   (0/13)
SensorsPropertySection$3 (SensorsPropertySection): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/38)0%   (0/11)
     
class SensorsPropertySection$40%   (0/1)0%   (0/2)0%   (0/14)0%   (0/4)
SensorsPropertySection$4 (SensorsPropertySection): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/8)0%   (0/2)

1package de.uka.ipd.sdq.sensorframework.visualisation.tabs.sensors;
2 
3import java.util.Observable;
4import java.util.Observer;
5 
6import org.eclipse.jface.dialogs.Dialog;
7import org.eclipse.jface.viewers.CellEditor;
8import org.eclipse.jface.viewers.DialogCellEditor;
9import org.eclipse.jface.viewers.ISelection;
10import org.eclipse.jface.viewers.ISelectionChangedListener;
11import org.eclipse.jface.viewers.IStructuredSelection;
12import org.eclipse.jface.viewers.SelectionChangedEvent;
13import org.eclipse.jface.viewers.TableViewer;
14import org.eclipse.jface.window.Window;
15import org.eclipse.swt.SWT;
16import org.eclipse.swt.events.SelectionAdapter;
17import org.eclipse.swt.events.SelectionEvent;
18import org.eclipse.swt.layout.FormAttachment;
19import org.eclipse.swt.layout.FormData;
20import org.eclipse.swt.layout.GridData;
21import org.eclipse.swt.widgets.Composite;
22import org.eclipse.swt.widgets.Control;
23import org.eclipse.swt.widgets.Table;
24import org.eclipse.swt.widgets.TableColumn;
25import org.eclipse.swt.widgets.ToolBar;
26import org.eclipse.swt.widgets.ToolItem;
27import org.eclipse.ui.IWorkbenchPart;
28import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
29import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
30 
31import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun;
32import de.uka.ipd.sdq.sensorframework.visualisation.VisualisationImages;
33import de.uka.ipd.sdq.sensorframework.visualisation.VisualisationPlugin;
34import de.uka.ipd.sdq.sensorframework.visualisation.dialogs.ExperimentRunsDialog;
35import de.uka.ipd.sdq.sensorframework.visualisation.dialogs.SensorsDialog;
36import de.uka.ipd.sdq.sensorframework.visualisation.editor.AbstractReportView;
37import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEditorInput;
38import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEntry;
39import de.uka.ipd.sdq.sensorframework.visualisation.views.TreeObject;
40 
41/**
42 * @author Roman Andrej
43 */
44public class SensorsPropertySection extends AbstractPropertySection implements
45                Observer {
46 
47        /* (non-Javadoc)
48         * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
49         */
50        public void update(Observable subject, Object signal) {
51                if (subject instanceof ConfigEditorInput)
52                        refresh();
53        }
54 
55        private ConfigEditorInput configObject;
56        private ConfigEntry selectedEntry;
57        private TableViewer viewer;
58        private ToolItem deleteRunItem;
59 
60        public static final int ICON_COLUMN_INDEX = 0;
61        public static final int CONTEXT_COLUMN_INDEX = 1;
62        public static final int RUN_COLUMN_INDEX = 2;
63        public static final int SENSORS_COLUMN_INDEX = 3;
64 
65        /**
66         * Columns of a table, which is used into ParameterEditDialog
67         */
68        public final static String ICON_COLUMN = "";
69        public final static String CONTEXT_COLUMN = "Context";
70        public final static String RUN_COLUMN = "Experiment Datetime";
71        public final static String SENSORS_COLUMN = "Sensors";
72 
73        /** ToolBar width. */
74        private final int toolbarWidth = 24;
75        
76        // Set column names of Tabele
77        protected static String[] columnNames = new String[] { ICON_COLUMN,
78                        CONTEXT_COLUMN, RUN_COLUMN, SENSORS_COLUMN };
79 
80        // style the style of table to construct
81        int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
82                        | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
83 
84        /* (non-Javadoc)
85         * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite,
86         *      org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
87         */
88        @Override
89        public void createControls(Composite parent,
90                        TabbedPropertySheetPage aTabbedPropertySheetPage) {
91                super.createControls(parent, aTabbedPropertySheetPage);
92 
93                Composite composite = getWidgetFactory()
94                                .createFlatFormComposite(parent);
95                composite.getParent().setLayoutData(
96                                new GridData(SWT.FILL, SWT.FILL, true, true));
97 
98                /**
99                 * Create the cell editors for Name, Type column
100                 */
101                CellEditor[] editors = new CellEditor[columnNames.length];
102 
103                Table table = new Table(composite, style);
104                final FormData fd_table = new FormData();
105                fd_table.bottom = new FormAttachment(100, 0);
106                fd_table.left = new FormAttachment(0, 0);
107                fd_table.top = new FormAttachment(0, 0);
108                table.setLayoutData(fd_table);
109                table.setLinesVisible(true);
110                table.setHeaderVisible(true);
111 
112                viewer = new TableViewer(table);
113 
114                viewer.setColumnProperties(columnNames);
115                viewer.setContentProvider(new SensorsTabContentProvider());
116                viewer.setLabelProvider(new SensorsTabLabelProvider());
117                viewer.setCellModifier(new SensorsTabCellModifier());
118                viewer.addSelectionChangedListener(new ISelectionChangedListener() {
119                        public void selectionChanged(SelectionChangedEvent event) {
120                                Object object = ((IStructuredSelection) viewer.getSelection())
121                                                .getFirstElement();
122                                selectedEntry = (ConfigEntry) object;
123                                
124                                if (selectedEntry != null)
125                                        deleteRunItem.setEnabled(true);
126                                else deleteRunItem.setEnabled(false);
127                        }
128                });
129                editors[SENSORS_COLUMN_INDEX] = new DialogCellEditor(table) {
130 
131                        @Override
132                        protected Object openDialogBox(Control cellEditorWindow) {
133                                SensorsDialog dialog = new SensorsDialog(cellEditorWindow
134                                                .getShell(), selectedEntry);
135 
136                                if (dialog.open() == Dialog.OK)
137                                        viewer.refresh();
138                                return null;
139                        }
140                };
141                // Assign the cell editors to the viewer
142                viewer.setCellEditors(editors);
143                
144                // Definere the table columns
145                final TableColumn zeroColumn = new TableColumn(table, SWT.NONE);
146                zeroColumn.setResizable(false);
147                zeroColumn.setWidth(30);
148 
149                final TableColumn contextColumn = new TableColumn(table, SWT.NONE);
150                contextColumn.setWidth(100);
151                contextColumn.setText(CONTEXT_COLUMN);
152 
153                final TableColumn runColumn = new TableColumn(table, SWT.NONE);
154                runColumn.setWidth(140);
155                runColumn.setText(RUN_COLUMN);
156 
157                final TableColumn sensorsColumn = new TableColumn(table, SWT.NONE);
158                sensorsColumn.setWidth(200);
159                sensorsColumn.setText(SENSORS_COLUMN);
160 
161                final ToolBar toolBar = new ToolBar(composite, SWT.VERTICAL);
162                fd_table.right = new FormAttachment(toolBar, 0, SWT.LEFT);
163                final FormData fd_toolBar = new FormData();
164                fd_toolBar.left = new FormAttachment(100, - toolbarWidth);
165                fd_toolBar.bottom = new FormAttachment(100, 0);
166                fd_toolBar.right = new FormAttachment(100, 0);
167                fd_toolBar.top = new FormAttachment(0, 0);
168                toolBar.setLayoutData(fd_toolBar);
169 
170                ToolItem addRunItem = new ToolItem(toolBar, SWT.PUSH);
171                addRunItem.setImage(VisualisationImages.imageRegistry.get(VisualisationImages.ADD));
172                addRunItem.addSelectionListener(new SelectionAdapter() {
173                
174                        /* (non-Javadoc)
175                         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
176                         */
177                        @Override
178                        public void widgetSelected(SelectionEvent e) {
179                                ExperimentRunsDialog dialog = new ExperimentRunsDialog(
180                                                e.display.getActiveShell());
181                                if (dialog.open() == Window.OK && dialog.getResult() != null) {
182                                        TreeObject object = dialog.getResult();
183                                        ConfigEntry configEntry = new ConfigEntry(
184                                                        object.getDatasource(),
185                                                        (ExperimentRun) object.getObject(), object
186                                                                        .getExperiment(), null);
187                                        configObject.addConfigEntry(configEntry);
188                                        viewer.refresh();
189                                }
190                        }
191                });
192 
193                deleteRunItem = new ToolItem(toolBar, SWT.PUSH);
194                deleteRunItem.setImage(VisualisationImages.imageRegistry.get(VisualisationImages.DELETE));
195                deleteRunItem.addSelectionListener(new SelectionAdapter(){
196 
197                        /* (non-Javadoc)
198                         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
199                         */
200                        @Override
201                        public void widgetSelected(SelectionEvent e) {
202                                configObject.removeConfigEntry(selectedEntry);
203                        }
204                        
205                });
206                deleteRunItem.setEnabled(false);
207 
208                /** set Observer to the ConfigObject */
209                AbstractReportView view = (AbstractReportView) VisualisationPlugin.getDefault()
210                                .getWorkbench().getActiveWorkbenchWindow().getActivePage()
211                                .getActiveEditor();
212                configObject = (ConfigEditorInput) view.getEditorInput();
213                configObject.addObserver(this);
214        }
215 
216        /* (non-Javadoc)
217         * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#getSelection()
218         */
219        @Override
220        public ISelection getSelection() {
221                // TODO Auto-generated method stub
222                return super.getSelection();
223        }
224 
225        /* (non-Javadoc)
226         * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
227         */
228        @Override
229        public void refresh() {
230                viewer.refresh();
231        }
232 
233        /* (non-Javadoc)
234         * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart,
235         *      org.eclipse.jface.viewers.ISelection)
236         */
237        @Override
238        public void setInput(IWorkbenchPart part, ISelection selection) {
239                super.setInput(part, selection);
240 
241                if (part instanceof AbstractReportView) {
242                        AbstractReportView view = (AbstractReportView) part;
243                        configObject = (ConfigEditorInput) view.getEditorInput();
244                        viewer.setInput(configObject);
245                }
246        }
247}

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