1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.sensorframework.visualisation.dialogs; |
5 | |
6 | |
7 | import org.eclipse.jface.viewers.ICellModifier; |
8 | |
9 | import de.uka.ipd.sdq.sensorframework.entities.Sensor; |
10 | import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEntry; |
11 | |
12 | /** |
13 | * @author admin |
14 | * |
15 | */ |
16 | public class SensorsDialogCellModifier implements ICellModifier { |
17 | |
18 | private ConfigEntry entry; |
19 | private Sensor selectedSensor; |
20 | |
21 | public SensorsDialogCellModifier(ConfigEntry entry) { |
22 | this.entry = entry; |
23 | } |
24 | |
25 | /* (non-Javadoc) |
26 | * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String) |
27 | */ |
28 | public boolean canModify(Object element, String property) { |
29 | return true; |
30 | } |
31 | |
32 | /* (non-Javadoc) |
33 | * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String) |
34 | */ |
35 | public Object getValue(Object element, String property) { |
36 | selectedSensor = (Sensor) element; |
37 | return new Boolean(entry.isSensorChecked(selectedSensor)); |
38 | } |
39 | |
40 | /* (non-Javadoc) |
41 | * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object) |
42 | */ |
43 | public void modify(Object element, String property, Object value) { |
44 | boolean checked = (((Boolean) value).booleanValue()); |
45 | |
46 | if (checked) |
47 | entry.setSensorChecked(selectedSensor); |
48 | if (!checked) |
49 | entry.setSensorUnchecked(selectedSensor); |
50 | } |
51 | |
52 | } |