1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.sensorframework.visualisation.dialogs; |
5 | |
6 | import org.eclipse.jface.viewers.ILabelProviderListener; |
7 | import org.eclipse.jface.viewers.ITableLabelProvider; |
8 | import org.eclipse.swt.graphics.Image; |
9 | |
10 | import de.uka.ipd.sdq.sensorframework.entities.Sensor; |
11 | import de.uka.ipd.sdq.sensorframework.visualisation.VisualisationImages; |
12 | import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEntry; |
13 | |
14 | /** |
15 | * @author admin |
16 | * |
17 | */ |
18 | public class SensorsDialogLabelProvider implements ITableLabelProvider { |
19 | |
20 | |
21 | private ConfigEntry entry ; |
22 | |
23 | /** |
24 | * @param entry |
25 | */ |
26 | public SensorsDialogLabelProvider(ConfigEntry entry) { |
27 | this.entry = entry; |
28 | } |
29 | |
30 | /* (non-Javadoc) |
31 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) |
32 | */ |
33 | public Image getColumnImage(Object element, int columnIndex) { |
34 | return (columnIndex == 0) ? // COMPLETED_COLUMN? |
35 | getImage(entry.isSensorChecked((Sensor) element)) : |
36 | null; |
37 | } |
38 | |
39 | /* (non-Javadoc) |
40 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) |
41 | */ |
42 | public String getColumnText(Object element, int columnIndex) { |
43 | String result = ""; |
44 | |
45 | Sensor sensor = (Sensor) element; |
46 | |
47 | switch (columnIndex) { |
48 | case SensorsDialog.CHECK_COLUMN_INDEX: |
49 | break; |
50 | case SensorsDialog.SENSOR_ID_INDEX: |
51 | // TODO |
52 | result = "" + sensor.getSensorID(); |
53 | break; |
54 | case SensorsDialog.SENSOR_NAME_COLUMN_INDEX: |
55 | result = sensor.getSensorName(); |
56 | break; |
57 | default: |
58 | break; |
59 | } |
60 | return result; |
61 | } |
62 | |
63 | |
64 | /** |
65 | * Returns the image with the given key, or <code>null</code> if not found. |
66 | */ |
67 | private Image getImage(boolean isSelected) { |
68 | String key = isSelected ? VisualisationImages.CHECKED_IMAGE : VisualisationImages.UNCHECKED_IMAGE; |
69 | return VisualisationImages.imageRegistry.get(key); |
70 | } |
71 | |
72 | /* (non-Javadoc) |
73 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) |
74 | */ |
75 | public void addListener(ILabelProviderListener listener) { |
76 | // TODO Auto-generated method stub |
77 | |
78 | } |
79 | |
80 | /* (non-Javadoc) |
81 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() |
82 | */ |
83 | public void dispose() { |
84 | // TODO Auto-generated method stub |
85 | |
86 | } |
87 | |
88 | /* (non-Javadoc) |
89 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) |
90 | */ |
91 | public boolean isLabelProperty(Object element, String property) { |
92 | // TODO Auto-generated method stub |
93 | return false; |
94 | } |
95 | |
96 | /* (non-Javadoc) |
97 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) |
98 | */ |
99 | public void removeListener(ILabelProviderListener listener) { |
100 | // TODO Auto-generated method stub |
101 | |
102 | } |
103 | |
104 | } |