EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.sensorframework.visualisation.tabs.filters]

COVERAGE SUMMARY FOR SOURCE FILE [FiltersTabCellModifier.java]

nameclass, %method, %block, %line, %
FiltersTabCellModifier.java0%   (0/1)0%   (0/6)0%   (0/78)0%   (0/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FiltersTabCellModifier0%   (0/1)0%   (0/6)0%   (0/78)0%   (0/28)
FiltersTabCellModifier (FiltersPropertySection): void 0%   (0/1)0%   (0/10)0%   (0/4)
canModify (Object, String): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
getShell (): Shell 0%   (0/1)0%   (0/5)0%   (0/2)
getValue (Object, String): Object 0%   (0/1)0%   (0/10)0%   (0/2)
modify (Object, String, Object): void 0%   (0/1)0%   (0/25)0%   (0/10)
setFilteringParameter (IFilteredCollectionFactory, String): void 0%   (0/1)0%   (0/26)0%   (0/9)

1package de.uka.ipd.sdq.sensorframework.visualisation.tabs.filters;
2 
3import java.util.Arrays;
4import java.util.List;
5import java.util.Properties;
6 
7import org.eclipse.jface.dialogs.MessageDialog;
8import org.eclipse.jface.viewers.ICellModifier;
9import org.eclipse.swt.widgets.Shell;
10import org.eclipse.swt.widgets.TableItem;
11 
12import de.uka.ipd.sdq.sensorframework.filter.IFilteredCollectionFactory;
13import de.uka.ipd.sdq.sensorframework.visualisation.VisualisationPlugin;
14 
15/**
16 * @author Roman Andrej
17 */
18public class FiltersTabCellModifier implements ICellModifier {
19 
20        private FiltersPropertySection section;
21        private List<String> columnNames;
22        
23        public FiltersTabCellModifier(FiltersPropertySection section) {
24                this.section = section;
25                this.columnNames = Arrays.asList(FiltersPropertySection.columnNames);
26        }
27 
28        /* (non-Javadoc)
29         * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
30         */
31        public boolean canModify(Object element, String property) {
32                return true;
33        }
34 
35        /* (non-Javadoc)
36         * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
37         */
38        public Object getValue(Object element, String property) {
39                return (new FiltersTabLabelProvider()).getColumnText(element,
40                                columnNames.indexOf(property));
41        }
42 
43        /* (non-Javadoc)
44         * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
45         */
46        public void modify(Object element, String property, Object value) {
47                // Find the index of the column
48                int columnIndex = columnNames.indexOf(property);
49 
50                TableItem item = (TableItem) element;
51        
52                IFilteredCollectionFactory factory = (IFilteredCollectionFactory) item.getData();
53 
54                switch (columnIndex) {
55                case FiltersPropertySection.ICON_COLUMN_INDEX: // ICON_COLUMN
56                        break;
57                case FiltersPropertySection.FILTERNAME_COLUMN_INDEX: // FILTERNAME_COLUMN
58                        break;
59                case FiltersPropertySection.PARAMETER_TYPE_COLUMN_INDEX: // PARAMETER_TYPE_COLUMN
60                        break;
61                case FiltersPropertySection.PARAMETER_DESCRIPTION_COLUMN_INDEX: // PARAMETER_DESCRIPTION
62                        break;
63                case FiltersPropertySection.PARAMETER_VALUE_COLUMN_INDEX: // PARAMETER_VALUE_COLUMN
64                        setFilteringParameter(factory, ((String) value).trim());
65                        break;
66                default:
67                }
68        }
69        
70        /**
71         * The method set the new parameter value to the filter.
72         * 
73         * @param selected
74         *            filter
75         * @param new
76         *            parameter value
77         */
78        private void setFilteringParameter(IFilteredCollectionFactory factory, String input) {
79                try {
80                        // get properties
81                        Properties properties = factory.getProperties();
82                        // get first property description
83                        String desc = properties.propertyNames().nextElement().toString();
84                        // set new parameter
85                        properties.put(desc, factory.convertToType(input));
86                        // refresh section viewer
87                        section.refresh();
88 
89                } catch (NumberFormatException e) {
90                        MessageDialog.openInformation(getShell(),
91                                        "Parameter conversion Error ",
92                                        "The entered parameter is not of the type Number!");
93                }
94        }
95        
96        /** The method get the active shell. */
97        private Shell getShell(){
98                return VisualisationPlugin.getDefault()
99                .getWorkbench().getActiveWorkbenchWindow().getShell();
100        }
101}

[all classes][de.uka.ipd.sdq.sensorframework.visualisation.tabs.filters]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov