1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.sensorframework.visualisation.tabs.sensors; |
5 | |
6 | import java.util.Collection; |
7 | |
8 | import org.eclipse.jface.viewers.ILabelProviderListener; |
9 | import org.eclipse.jface.viewers.ITableLabelProvider; |
10 | import org.eclipse.swt.graphics.Image; |
11 | |
12 | import de.uka.ipd.sdq.sensorframework.entities.Sensor; |
13 | import de.uka.ipd.sdq.sensorframework.visualisation.VisualisationImages; |
14 | import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEntry; |
15 | |
16 | /** |
17 | * @author admin |
18 | * |
19 | */ |
20 | public class SensorsTabLabelProvider implements ITableLabelProvider { |
21 | |
22 | /* (non-Javadoc) |
23 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) |
24 | */ |
25 | public Image getColumnImage(Object element, int columnIndex) { |
26 | if (columnIndex == SensorsPropertySection.ICON_COLUMN_INDEX) |
27 | return VisualisationImages.imageRegistry.get(VisualisationImages.RUN); |
28 | return null; |
29 | } |
30 | |
31 | /* (non-Javadoc) |
32 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) |
33 | */ |
34 | public String getColumnText(Object element, int columnIndex) { |
35 | String result = ""; |
36 | |
37 | ConfigEntry entry = (ConfigEntry) element; |
38 | |
39 | switch (columnIndex) { |
40 | case SensorsPropertySection.ICON_COLUMN_INDEX: |
41 | break; |
42 | case SensorsPropertySection.CONTEXT_COLUMN_INDEX: |
43 | result = entry.getExperimentRun().getClass().getSimpleName(); |
44 | break; |
45 | case SensorsPropertySection.RUN_COLUMN_INDEX: |
46 | result = entry.getExperimentRun().getExperimentDateTime(); |
47 | break; |
48 | case SensorsPropertySection.SENSORS_COLUMN_INDEX: |
49 | result = setSenssorsArrayToString(entry); |
50 | break; |
51 | default: |
52 | break; |
53 | } |
54 | return result; |
55 | } |
56 | |
57 | |
58 | private String setSenssorsArrayToString(ConfigEntry entry){ |
59 | String result = ""; |
60 | Collection<Sensor> sensors= entry.getSensors(); |
61 | |
62 | for(Sensor s: sensors){ |
63 | result = result + s.getSensorName() + ", "; |
64 | } |
65 | return deleteComma(result); |
66 | } |
67 | |
68 | /** |
69 | * Comma of the sentence deletes ends |
70 | */ |
71 | public String deleteComma(String result) { |
72 | if (!result.equals("")) { |
73 | result = result.substring(0, result.length() - 2); |
74 | } |
75 | return result; |
76 | } |
77 | |
78 | /* (non-Javadoc) |
79 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) |
80 | */ |
81 | public void addListener(ILabelProviderListener listener) { |
82 | // TODO Auto-generated method stub |
83 | |
84 | } |
85 | |
86 | /* (non-Javadoc) |
87 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() |
88 | */ |
89 | public void dispose() { |
90 | // TODO Auto-generated method stub |
91 | |
92 | } |
93 | |
94 | /* (non-Javadoc) |
95 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) |
96 | */ |
97 | public boolean isLabelProperty(Object element, String property) { |
98 | // TODO Auto-generated method stub |
99 | return false; |
100 | } |
101 | |
102 | /* (non-Javadoc) |
103 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) |
104 | */ |
105 | public void removeListener(ILabelProviderListener listener) { |
106 | // TODO Auto-generated method stub |
107 | |
108 | } |
109 | |
110 | } |