1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.sensorframework.visualisation.tabs.filters; |
5 | |
6 | import java.util.Properties; |
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.filter.IFilteredCollectionFactory; |
13 | |
14 | |
15 | /** |
16 | * @author Roman Andrej |
17 | */ |
18 | public class FiltersTabLabelProvider implements ITableLabelProvider { |
19 | |
20 | /* (non-Javadoc) |
21 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) |
22 | */ |
23 | public Image getColumnImage(Object element, int columnIndex) { |
24 | // TODO Auto-generated method stub |
25 | return null; |
26 | } |
27 | |
28 | /* (non-Javadoc) |
29 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) |
30 | */ |
31 | public String getColumnText(Object element, int columnIndex) { |
32 | String result = ""; |
33 | |
34 | IFilteredCollectionFactory entry = (IFilteredCollectionFactory) element; |
35 | |
36 | switch (columnIndex) { |
37 | case FiltersPropertySection.ICON_COLUMN_INDEX: |
38 | break; |
39 | case FiltersPropertySection.FILTERNAME_COLUMN_INDEX: |
40 | result = entry.getFilterFactoryID(); |
41 | break; |
42 | case FiltersPropertySection.PARAMETER_TYPE_COLUMN_INDEX: |
43 | result = getType(entry.getProperties()); |
44 | break; |
45 | case FiltersPropertySection.PARAMETER_DESCRIPTION_COLUMN_INDEX: |
46 | result = getDescription(entry.getProperties()); |
47 | break; |
48 | case FiltersPropertySection.PARAMETER_VALUE_COLUMN_INDEX: |
49 | result = getValue(entry.getProperties()); |
50 | break; |
51 | default: |
52 | break; |
53 | } |
54 | return result; |
55 | } |
56 | |
57 | private String getDescription(Properties properties){ |
58 | return properties.propertyNames().nextElement().toString(); |
59 | } |
60 | |
61 | private String getType(Properties properties){ |
62 | return properties.get(getDescription(properties)).getClass().getSimpleName(); |
63 | } |
64 | |
65 | private String getValue(Properties properties){ |
66 | return properties.get(getDescription(properties)).toString(); |
67 | } |
68 | |
69 | /* (non-Javadoc) |
70 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) |
71 | */ |
72 | public void addListener(ILabelProviderListener listener) { |
73 | // The implementation is not necessary. |
74 | } |
75 | |
76 | /* (non-Javadoc) |
77 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() |
78 | */ |
79 | public void dispose() { |
80 | // The implementation is not necessary. |
81 | } |
82 | |
83 | /* (non-Javadoc) |
84 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) |
85 | */ |
86 | public boolean isLabelProperty(Object element, String property) { |
87 | return false; |
88 | } |
89 | |
90 | /* (non-Javadoc) |
91 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) |
92 | */ |
93 | public void removeListener(ILabelProviderListener listener) { |
94 | // The implementation is not necessary. |
95 | } |
96 | } |