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 [TreeDragSourceListener.java]

nameclass, %method, %block, %line, %
TreeDragSourceListener.java0%   (0/1)0%   (0/4)0%   (0/165)0%   (0/55)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TreeDragSourceListener0%   (0/1)0%   (0/4)0%   (0/165)0%   (0/55)
TreeDragSourceListener (TreeViewer): void 0%   (0/1)0%   (0/6)0%   (0/3)
dragFinished (DragSourceEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
dragSetData (DragSourceEvent): void 0%   (0/1)0%   (0/125)0%   (0/40)
dragStart (DragSourceEvent): void 0%   (0/1)0%   (0/33)0%   (0/11)

1package de.uka.ipd.sdq.sensorframework.visualisation.views;
2 
3import org.eclipse.jface.util.LocalSelectionTransfer;
4import org.eclipse.jface.viewers.IStructuredSelection;
5import org.eclipse.jface.viewers.TreeViewer;
6import org.eclipse.swt.dnd.DragSourceEvent;
7import org.eclipse.swt.dnd.DragSourceListener;
8import org.eclipse.ui.part.EditorInputTransfer;
9 
10import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun;
11import de.uka.ipd.sdq.sensorframework.entities.Sensor;
12import de.uka.ipd.sdq.sensorframework.visualisation.dialogs.ViewAndAdapterFactory;
13import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEditorInput;
14import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEntry;
15import de.uka.ipd.sdq.sensorframework.visualisation.editor.SensorValidationToView;
16 
17/**
18 * @author admin
19 */
20public class TreeDragSourceListener implements DragSourceListener {
21 
22        TreeViewer viewer;
23        
24        public TreeDragSourceListener(TreeViewer viewer) {
25                this.viewer = viewer;
26        }
27        
28        /* (non-Javadoc)
29         * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
30         */
31        public void dragSetData(DragSourceEvent event) {
32                IStructuredSelection selection = (IStructuredSelection) viewer
33                                .getSelection();
34                Object object = selection.getFirstElement();
35                Object[] viewers = null;
36 
37                if (EditorInputTransfer.getInstance().isSupportedType(event.dataType)) {
38                        TreeObject treeObject = (TreeObject) object;
39                        Object innerObject = treeObject.getObject();
40 
41                        /** Sensor */
42                        if (innerObject instanceof Sensor) {
43                                Sensor sensor = (Sensor) innerObject;
44                                /** return all view, which can represent the sensor */
45                                viewers = SensorValidationToView.findViews(treeObject.getRun()
46                                                .getMeasurementsOfSensor(sensor));
47                        }
48                        /** Experiment Run */
49                        if (innerObject instanceof ExperimentRun) {
50                                /** return all view */
51                                viewers = SensorValidationToView.getConfigurationElements();
52                        }
53 
54                        ViewAndAdapterFactory selectedView = SensorValidationToView.getSelectedAction(event.display
55                                        .getActiveShell(), viewers);
56                        if (selectedView != null) {
57 
58                                ConfigEditorInput editorInput = new ConfigEditorInput(selectedView.getFactory().getAdapterFactoryID());
59                                /** Sensor */
60                                if (innerObject instanceof Sensor) {
61                                        Sensor sensor = (Sensor) innerObject;
62                                        ConfigEntry configEntry = new ConfigEntry(
63                                                        treeObject.getDatasource(),
64                                                        treeObject.getRun(),
65                                                        treeObject.getExperiment(), sensor);
66                                        editorInput.addConfigEntry(configEntry);
67                                }
68                                /** Experiment Run */
69                                if (innerObject instanceof ExperimentRun) {
70                                        ExperimentRun run = (ExperimentRun) innerObject;
71                                        ConfigEntry configEntry = new ConfigEntry(treeObject.getDatasource(),
72                                                        run, treeObject
73                                                        .getExperiment(), null);
74                                        editorInput.addConfigEntry(configEntry);
75                                }
76                                EditorInputTransfer.EditorInputData[] transferArray = new EditorInputTransfer.EditorInputData[] { EditorInputTransfer
77                                                .createEditorInputData(selectedView.getView().getAttribute("editorID"),
78                                                                editorInput) };
79                                event.data = transferArray;
80                        } else {
81                                event.data = null;
82                                event.doit = false;
83                        }
84                } else if (LocalSelectionTransfer.getTransfer().isSupportedType(
85                                event.dataType)) {
86                        LocalSelectionTransfer.getTransfer().setSelection(selection);
87                }
88        }
89 
90        /* (non-Javadoc)
91         * @see org.eclipse.swt.dnd.DragSourceListener#dragStart(org.eclipse.swt.dnd.DragSourceEvent)
92         */
93        public void dragStart(DragSourceEvent event) {
94                IStructuredSelection selection = (IStructuredSelection) viewer
95                                .getSelection();
96                Object object = selection.getFirstElement();
97 
98                event.doit = false;
99 
100                if (object instanceof TreeObject) {
101                        event.doit = true;
102                        // if the sensor is not a child from ExperimentRun
103                        TreeObject treeObject = (TreeObject) object;
104                        ExperimentRun run = treeObject.getRun();
105                        if (treeObject.getObject() instanceof Sensor && run == null)
106                                event.doit = false;
107                }
108        }
109 
110        public void dragFinished(DragSourceEvent event) {
111        }
112}

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