1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.sensorframework.visualisation.dialogs; |
5 | |
6 | import java.util.ArrayList; |
7 | import java.util.Collection; |
8 | |
9 | import org.eclipse.jface.viewers.IStructuredContentProvider; |
10 | import org.eclipse.jface.viewers.Viewer; |
11 | |
12 | import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun; |
13 | import de.uka.ipd.sdq.sensorframework.entities.Sensor; |
14 | import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEntry; |
15 | import de.uka.ipd.sdq.sensorframework.visualisation.editor.SensorValidationToView; |
16 | |
17 | /** @author roman */ |
18 | public class SensorsDialogContentProvider implements IStructuredContentProvider { |
19 | |
20 | Collection<Sensor> sensors; |
21 | |
22 | /* (non-Javadoc) |
23 | * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) |
24 | */ |
25 | public Object[] getElements(Object inputElement) { |
26 | if (inputElement instanceof ConfigEntry) |
27 | return sensorsValidation((ConfigEntry) inputElement); |
28 | return null; |
29 | } |
30 | |
31 | /** |
32 | * This function get a sensors list, which can be indicated by |
33 | * current View. |
34 | */ |
35 | private Object[] sensorsValidation(ConfigEntry entry) { |
36 | ExperimentRun run = entry.getExperimentRun(); |
37 | Collection<Sensor> sensors = entry.getExperiment().getSensors(); |
38 | ArrayList<Sensor> validSensors = new ArrayList<Sensor>(); |
39 | |
40 | for (Sensor sensor : sensors) { |
41 | if (SensorValidationToView.canViewSensor(run |
42 | .getMeasurementsOfSensor(sensor))) |
43 | validSensors.add(sensor); |
44 | } |
45 | |
46 | return validSensors.toArray(); |
47 | } |
48 | |
49 | /* (non-Javadoc) |
50 | * @see org.eclipse.jface.viewers.IContentProvider#dispose() |
51 | */ |
52 | public void dispose() { |
53 | // TODO Auto-generated method stub |
54 | |
55 | } |
56 | |
57 | /* (non-Javadoc) |
58 | * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
59 | */ |
60 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
61 | // TODO Auto-generated method stub |
62 | |
63 | } |
64 | } |