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

COVERAGE SUMMARY FOR SOURCE FILE [AbstractReportView.java]

nameclass, %method, %block, %line, %
AbstractReportView.java0%   (0/2)0%   (0/22)0%   (0/247)0%   (0/74)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractReportView0%   (0/1)0%   (0/17)0%   (0/233)0%   (0/69)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/2)
AbstractReportView (): void 0%   (0/1)0%   (0/9)0%   (0/4)
addDropSupport (Control): void 0%   (0/1)0%   (0/26)0%   (0/8)
changedInputData (): void 0%   (0/1)0%   (0/102)0%   (0/21)
createPartControl (Composite): void 0%   (0/1)0%   (0/16)0%   (0/5)
doSave (IProgressMonitor): void 0%   (0/1)0%   (0/1)0%   (0/1)
doSaveAs (): void 0%   (0/1)0%   (0/1)0%   (0/1)
getAdapter (Class): Object 0%   (0/1)0%   (0/12)0%   (0/3)
getContributorId (): String 0%   (0/1)0%   (0/2)0%   (0/1)
init (IEditorSite, IEditorInput): void 0%   (0/1)0%   (0/7)0%   (0/3)
isDirty (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
isIgnoreDataSettingsChanged (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
isSaveAsAllowed (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
setIgnoreDataSettingsChanged (boolean): void 0%   (0/1)0%   (0/4)0%   (0/2)
setInput (IEditorInput): void 0%   (0/1)0%   (0/12)0%   (0/4)
showMessage (String, String): void 0%   (0/1)0%   (0/7)0%   (0/3)
update (Observable, Object): void 0%   (0/1)0%   (0/24)0%   (0/8)
     
class AbstractReportView$10%   (0/1)0%   (0/5)0%   (0/14)0%   (0/6)
AbstractReportView$1 (AbstractReportView): void 0%   (0/1)0%   (0/6)0%   (0/2)
addSelectionChangedListener (ISelectionChangedListener): void 0%   (0/1)0%   (0/1)0%   (0/1)
getSelection (): ISelection 0%   (0/1)0%   (0/5)0%   (0/1)
removeSelectionChangedListener (ISelectionChangedListener): void 0%   (0/1)0%   (0/1)0%   (0/1)
setSelection (ISelection): void 0%   (0/1)0%   (0/1)0%   (0/1)

1package de.uka.ipd.sdq.sensorframework.visualisation.editor;
2 
3import java.util.ArrayList;
4import java.util.List;
5import java.util.Observable;
6import java.util.Observer;
7 
8import org.eclipse.core.runtime.IProgressMonitor;
9import org.eclipse.jface.dialogs.MessageDialog;
10import org.eclipse.jface.util.LocalSelectionTransfer;
11import org.eclipse.jface.viewers.ISelection;
12import org.eclipse.jface.viewers.ISelectionChangedListener;
13import org.eclipse.jface.viewers.ISelectionProvider;
14import org.eclipse.jface.viewers.StructuredSelection;
15import org.eclipse.swt.dnd.DND;
16import org.eclipse.swt.dnd.DropTarget;
17import org.eclipse.swt.dnd.Transfer;
18import org.eclipse.swt.widgets.Composite;
19import org.eclipse.swt.widgets.Control;
20import org.eclipse.ui.IEditorInput;
21import org.eclipse.ui.IEditorSite;
22import org.eclipse.ui.PartInitException;
23import org.eclipse.ui.part.EditorPart;
24import org.eclipse.ui.views.properties.IPropertySheetPage;
25import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
26import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
27 
28import de.uka.ipd.sdq.sensorframework.adapter.AdapterRegistry;
29import de.uka.ipd.sdq.sensorframework.adapter.DataAdapter;
30import de.uka.ipd.sdq.sensorframework.adapter.IAdapterFactory;
31import de.uka.ipd.sdq.sensorframework.entities.Sensor;
32import de.uka.ipd.sdq.sensorframework.entities.SensorAndMeasurements;
33import de.uka.ipd.sdq.sensorframework.visualisation.views.ViewDropTargetListener;
34 
35public abstract class AbstractReportView extends EditorPart implements
36                ITabbedPropertySheetPageContributor, Observer {
37 
38        /** Contributor identifier. */
39        public static String ABSTRACT_EDITOR_ID = "de.uka.ipd.sdq.sensorframework.visualisation.AbstractReportView";
40 
41        /** Editor input. */
42        protected ConfigEditorInput myInput;
43        
44        /** List of all data adapters used by this report. */
45        private ArrayList<DataAdapter> dataAdapters = null;
46 
47        /**Marks if the SettingsChanged event from DataAdapters are ignored. */
48        private boolean ignoreDataSettingsChanged;
49 
50        public AbstractReportView() {
51                super();
52                ignoreDataSettingsChanged = false;
53        }
54 
55        /* (non-Javadoc)
56         * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
57         */
58        @Override
59        public void createPartControl(Composite parent) {
60                getSite().setSelectionProvider(new ISelectionProvider() {
61 
62                        public void addSelectionChangedListener(
63                                        ISelectionChangedListener listener) {
64                        }
65 
66                        public ISelection getSelection() {
67                                return new StructuredSelection(this);
68                        }
69 
70                        public void removeSelectionChangedListener(
71                                        ISelectionChangedListener listener) {
72                        }
73 
74                        public void setSelection(ISelection selection) {
75                        }
76                });
77 
78                addDropSupport(parent);
79 
80                createReportControls(parent);
81                changedInputData();
82        }
83 
84        /** The method define a 'Template method' pattern. */
85        protected abstract void createReportControls(Composite parent);
86 
87        private void addDropSupport(Control control) {
88 
89                int operations = DND.DROP_COPY | DND.DROP_DEFAULT;
90                DropTarget target = new DropTarget(control, operations);
91 
92                Transfer[] transferTypes = new Transfer[] { 
93                                LocalSelectionTransfer.getTransfer()
94                };
95                target.setTransfer(transferTypes);
96                target.addDropListener(new ViewDropTargetListener(
97                                this.getEditorInput()));
98        }
99 
100        /* (non-Javadoc)
101         * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
102         */
103        @SuppressWarnings("unchecked")
104        @Override
105        public Object getAdapter(Class adapter) {
106                if (adapter == IPropertySheetPage.class)
107                        return new TabbedPropertySheetPage(this);
108                return super.getAdapter(adapter);
109        }
110 
111        /** The method return the contributor identifier for 'ConfigEditorInput'. */
112        public String getContributorId() {
113                return ABSTRACT_EDITOR_ID;
114        }
115 
116 
117        /* (non-Javadoc)
118         * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
119         */
120        @Override
121        public void init(IEditorSite site, IEditorInput input)
122                        throws PartInitException {
123                setSite(site);
124                setInput(input);
125        }
126 
127        /** {@inheritDoc}
128         */
129        @Override
130        protected void setInput(IEditorInput input) {
131                super.setInput(input);
132                myInput = (ConfigEditorInput) input;
133                myInput.addObserver(this);
134        }
135 
136        /** {@inheritDoc}
137         */
138        public void update(Observable o, Object arg) {
139                getSite().getPage().activate(this);
140                if (arg != null) {
141                        if (arg == DataAdapter.SETTINGS_CHANGED)
142                                if (!ignoreDataSettingsChanged)
143                                        generateVisualization(dataAdapters);
144                        if (ConfigEditorInput.class.isInstance(arg))
145                                changedInputData();
146                }
147        }
148 
149        private void changedInputData() {
150                ArrayList<SensorAndMeasurements> list = new ArrayList<SensorAndMeasurements>();
151 
152                for (ConfigEntry re : myInput.getConfigEntrys()) {
153                        for (Sensor s : re.getSensors()) {
154                                try {
155                                        list.add(re.getExperimentRun().getMeasurementsOfSensor(s));
156                                } catch (Exception e1) {
157                                        showMessage(s.getSensorName(),
158                                                        "Missing the Measurements of sensor!");
159                                }
160                        }
161                }
162                // get the adapter factory for input
163                IAdapterFactory adapterFactory = AdapterRegistry.singleton()
164                                .getFactoryByID(myInput.getAdapterFactoryID());
165 
166                /* Add the data sources to this report an observe changes at
167                 * the adapters and their settings.
168                 */
169                ArrayList<DataAdapter> newDataAdapters = new ArrayList<DataAdapter>();
170                DataAdapter usedAdapter = null;
171                for (SensorAndMeasurements sam : list) {
172                        usedAdapter = adapterFactory.getAdapter(myInput
173                                        // set the empty filter of the measurements 
174                                        .getFiltersManager().getFilteredMeasurements(sam));
175                        usedAdapter.addObserver(this);
176                        newDataAdapters.add(usedAdapter);
177                }
178                generateVisualization(newDataAdapters);
179                for (DataAdapter adapter : newDataAdapters) {
180                        adapter.addObserver(this);
181                }
182                dataAdapters = newDataAdapters;
183        }
184 
185        protected abstract void generateVisualization(List<DataAdapter> list);
186        
187        /** Show exception message. */
188        private void showMessage(String title, String message) {
189                MessageDialog.openInformation(this.getEditorSite().getShell(), title,
190                                message);
191        }
192        
193        /* (non-Javadoc)
194         * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
195         */
196        @Override
197        public void doSave(IProgressMonitor monitor) {
198                // The implementation is not necessary.
199        }
200        
201        /* (non-Javadoc)
202         * @see org.eclipse.ui.part.EditorPart#doSaveAs()
203         */
204        @Override
205        public void doSaveAs() {
206                // The implementation is not necessary.
207        }
208 
209        /* (non-Javadoc)
210         * @see org.eclipse.ui.part.EditorPart#isDirty()
211         */
212        @Override
213        public boolean isDirty() {
214                return false;
215        }
216        
217        /* (non-Javadoc)
218         * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
219         */
220        @Override
221        public boolean isSaveAsAllowed() {
222                return false;
223        }
224 
225        public boolean isIgnoreDataSettingsChanged() {
226                return ignoreDataSettingsChanged;
227        }
228 
229        public void setIgnoreDataSettingsChanged(boolean ignoreDataSettingsChanged) {
230                this.ignoreDataSettingsChanged = ignoreDataSettingsChanged;
231        }
232}

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