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

nameclass, %method, %block, %line, %
ViewDropTargetListener.java0%   (0/1)0%   (0/6)0%   (0/129)0%   (0/42)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ViewDropTargetListener0%   (0/1)0%   (0/6)0%   (0/129)0%   (0/42)
ViewDropTargetListener (IEditorInput): void 0%   (0/1)0%   (0/7)0%   (0/3)
dragEnter (DropTargetEvent): void 0%   (0/1)0%   (0/17)0%   (0/5)
dragLeave (DropTargetEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
dragOperationChanged (DropTargetEvent): void 0%   (0/1)0%   (0/17)0%   (0/5)
drop (DropTargetEvent): void 0%   (0/1)0%   (0/86)0%   (0/27)
dropAccept (DropTargetEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)

1package de.uka.ipd.sdq.sensorframework.visualisation.views;
2 
3import org.eclipse.jface.dialogs.MessageDialog;
4import org.eclipse.jface.viewers.IStructuredSelection;
5import org.eclipse.swt.dnd.DND;
6import org.eclipse.swt.dnd.DropTargetAdapter;
7import org.eclipse.swt.dnd.DropTargetEvent;
8import org.eclipse.ui.IEditorInput;
9import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
10 
11import de.uka.ipd.sdq.sensorframework.entities.Experiment;
12import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun;
13import de.uka.ipd.sdq.sensorframework.entities.Sensor;
14import de.uka.ipd.sdq.sensorframework.entities.SensorAndMeasurements;
15import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEditorInput;
16import de.uka.ipd.sdq.sensorframework.visualisation.editor.ConfigEntry;
17import de.uka.ipd.sdq.sensorframework.visualisation.editor.SensorValidationToView;
18 
19/** @author admin */
20public class ViewDropTargetListener extends DropTargetAdapter {
21 
22        private ConfigEditorInput configEditorInput;
23 
24        public ViewDropTargetListener(IEditorInput editorInput) {
25                this.configEditorInput = (ConfigEditorInput)editorInput;
26        }
27 
28        /* (non-Javadoc)
29         * @see org.eclipse.swt.dnd.DropTargetListener#dragEnter(org.eclipse.swt.dnd.DropTargetEvent)
30         */
31        @Override
32        public void dragEnter(DropTargetEvent event) {
33                if (event.detail == DND.DROP_DEFAULT) 
34                {
35                         if ((event.operations & DND.DROP_COPY) != 0)
36                                 event.detail = DND.DROP_COPY;
37                         else 
38                                 event.detail = DND.DROP_NONE; 
39                }
40        }
41 
42        /*
43         * (non-Javadoc)
44         * 
45         * @see org.eclipse.swt.dnd.DropTargetListener#dragLeave(org.eclipse.swt.dnd.DropTargetEvent)
46         */
47        @Override
48        public void dragLeave(DropTargetEvent event) {
49                // TODO Auto-generated method stub
50        }
51 
52        /* (non-Javadoc)
53         * @see org.eclipse.swt.dnd.DropTargetListener#dragOperationChanged(org.eclipse.swt.dnd.DropTargetEvent)
54         */
55        @Override
56        public void dragOperationChanged(DropTargetEvent event) {
57                if (event.detail == DND.DROP_DEFAULT) 
58                {
59                         if ((event.operations & DND.DROP_COPY) != 0)
60                                 event.detail = DND.DROP_COPY;
61                         else 
62                                 event.detail = DND.DROP_NONE; 
63                }
64        }
65 
66        /* (non-Javadoc)
67         * @see org.eclipse.swt.dnd.DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
68         */
69        @Override
70        public void drop(DropTargetEvent event) {
71                IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer
72                                .getTransfer().getSelection();
73                Object object = selection.getFirstElement();
74                if (object instanceof TreeObject) {
75                        TreeObject treeObject = (TreeObject) object;
76                        Object innerObject = treeObject.getObject();
77                        /** Drop a sensor */
78                        if (innerObject instanceof Sensor) {
79                                Sensor sensor = (Sensor) innerObject;
80                                ExperimentRun run = treeObject.getRun();
81                                Experiment experiment = treeObject.getExperiment();
82                                SensorAndMeasurements sam = run.getMeasurementsOfSensor(sensor);
83                                if (sam.getMeasurements().size() > 0){
84                                        /**
85                                         * sensor validation - if view do support the representation of
86                                         * the selected sensor
87                                         */
88                                        if (SensorValidationToView.canViewSensor(sam)) {
89                                                configEditorInput.editConfigEntry(treeObject.getDatasource(), run, experiment, sensor, null);
90                                        } else {
91                                                SensorValidationToView.showMessage(event.display
92                                                                .getActiveShell());
93                                        }
94                                } else {
95                                        MessageDialog.openWarning(event.display.getActiveShell(), 
96                                                        "Empty Sensor", 
97                                                        "The dropped sensor does not contain measurements in the selected Experiment Run." +
98                                                        " Refused to add sensor to view.");
99                                }
100                        }
101                        /** Drop a experiment run */
102                        if (innerObject instanceof ExperimentRun) {
103                                ExperimentRun run = (ExperimentRun) innerObject;
104                                if (configEditorInput.getConfigEntryToRun(run) == null) {
105                                        ConfigEntry configEntry = new ConfigEntry(treeObject.getDatasource(),
106                                                        run, treeObject
107                                                        .getExperiment(), null);
108                                        configEditorInput.addConfigEntry(configEntry);
109                                }
110                        }
111                }
112        }
113 
114        
115        /* (non-Javadoc)
116         * @see org.eclipse.swt.dnd.DropTargetListener#dropAccept(org.eclipse.swt.dnd.DropTargetEvent)
117         */
118        @Override
119        public void dropAccept(DropTargetEvent event) {
120                // TODO Auto-generated method stub
121        }
122}

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