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

COVERAGE SUMMARY FOR SOURCE FILE [TreeLabelProvider.java]

nameclass, %method, %block, %line, %
TreeLabelProvider.java0%   (0/1)0%   (0/5)0%   (0/164)0%   (0/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TreeLabelProvider0%   (0/1)0%   (0/5)0%   (0/164)0%   (0/41)
TreeLabelProvider (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getImage (Object): Image 0%   (0/1)0%   (0/61)0%   (0/20)
getText (Object): String 0%   (0/1)0%   (0/70)0%   (0/18)
runRepresentation (ExperimentRun): String 0%   (0/1)0%   (0/15)0%   (0/1)
sensorRepresentation (Sensor): String 0%   (0/1)0%   (0/15)0%   (0/1)

1package de.uka.ipd.sdq.sensorframework.visualisation.views;
2 
3import org.eclipse.jface.viewers.LabelProvider;
4import org.eclipse.swt.graphics.Image;
5import org.eclipse.ui.ISharedImages;
6import org.eclipse.ui.PlatformUI;
7 
8import de.uka.ipd.sdq.sensorframework.dialogs.dataset.DatasourceListLabelProvider;
9import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun;
10import de.uka.ipd.sdq.sensorframework.entities.Sensor;
11import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory;
12import de.uka.ipd.sdq.sensorframework.visualisation.VisualisationImages;
13 
14/**
15 * The label provider to define how model objects should be presented in the
16 * view. Each view can present the same model objects using different labels and
17 * icons, if needed. Alternatively, a single label provider can be shared
18 * between views in order to ensure that objects of the same type are presented
19 * in the same way everywhere.
20 * 
21 */
22public class TreeLabelProvider extends LabelProvider {
23 
24        /* (non-Javadoc)
25         * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
26         */
27        @Override
28        public String getText(Object obj) {
29                if (obj instanceof ExperimentAndDAO)
30                        return ((ExperimentAndDAO) obj).getExperiment().getExperimentName();
31 
32                if (obj instanceof TreeContainer)
33                        return ((TreeContainer) obj).getName();
34                
35                if (obj instanceof TreeObject) {
36                        TreeObject object = (TreeObject) obj;
37 
38                        if (object.getObject() instanceof ExperimentRun) {
39                                ExperimentRun run = (ExperimentRun) object.getObject();
40                                return runRepresentation(run);
41                        }
42 
43                        if (object.getObject() instanceof Sensor) {
44                                Sensor sensor = (Sensor) object.getObject();
45                                if (object.isEmpty())
46                                        return "EMPTY -"+ sensorRepresentation(sensor);
47                                return sensorRepresentation(sensor);
48                        }
49                }
50                        
51                if (obj instanceof IDAOFactory) {
52                        IDAOFactory factory = (IDAOFactory) obj;
53                        return DatasourceListLabelProvider.dataSetRepresentation(factory);
54                }
55 
56                return obj.toString();
57        }
58 
59        /*
60         * (non-Javadoc)
61         * 
62         * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
63         */
64        @Override
65        public Image getImage(Object obj) {
66 
67                if (obj instanceof ExperimentAndDAO)
68                        return VisualisationImages.imageRegistry.get(VisualisationImages.EXPERIMENT);
69 
70                if (obj instanceof TreeContainer){
71                        String icon = "";
72                        TreeContainer container = (TreeContainer) obj;
73                        switch (container.getType()) {
74                        case TreeContentProvider.EXPERIMENT_RUNS:
75                                icon = VisualisationImages.RUNS;
76                                break;
77                        case TreeContentProvider.SENSORS:
78                                icon = VisualisationImages.SENSORS;
79                                break;
80                        }
81                        return VisualisationImages.imageRegistry.get(icon);
82                }
83 
84                if (obj instanceof TreeObject) {
85                        TreeObject object = (TreeObject) obj;
86 
87                        if (object.getObject() instanceof ExperimentRun)
88                                return VisualisationImages.imageRegistry.get(VisualisationImages.RUN);
89 
90                        if (object.getObject() instanceof Sensor)
91                                return VisualisationImages.imageRegistry.get(VisualisationImages.SENSOR);
92                }
93                
94                if (obj instanceof IDAOFactory)
95                        return VisualisationImages.imageRegistry.get(VisualisationImages.TREEROOT);
96 
97                return PlatformUI.getWorkbench().getSharedImages().getImage(
98                                ISharedImages.IMG_OBJ_ELEMENT);
99        }
100 
101        public String sensorRepresentation(Sensor sensor) {
102                return sensor.getSensorName() + " [ID:" + sensor.getSensorID() + "]";
103        }
104        
105        public String runRepresentation(ExperimentRun run) {
106                return run.getExperimentDateTime() + " [ID:" + run.getExperimentRunID() + "]";
107        }
108}

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