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

nameclass, %method, %block, %line, %
ConfigEditorInput.java0%   (0/1)0%   (0/21)0%   (0/174)0%   (0/54)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ConfigEditorInput0%   (0/1)0%   (0/21)0%   (0/174)0%   (0/54)
ConfigEditorInput (String): void 0%   (0/1)0%   (0/16)0%   (0/5)
ConfigEditorInput (String, ConfigEntry): void 0%   (0/1)0%   (0/19)0%   (0/6)
addConfigEntry (ConfigEntry): void 0%   (0/1)0%   (0/11)0%   (0/4)
editConfigEntry (IDAOFactory, ExperimentRun, Experiment, Sensor, String): void 0%   (0/1)0%   (0/29)0%   (0/8)
exists (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
getAdapter (Class): Object 0%   (0/1)0%   (0/7)0%   (0/3)
getAdapterFactoryID (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getConfigEntryToRun (ExperimentRun): ConfigEntry 0%   (0/1)0%   (0/21)0%   (0/4)
getConfigEntrys (): List 0%   (0/1)0%   (0/3)0%   (0/1)
getFactoryId (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getFiltersManager (): FilteredCollectionsManager 0%   (0/1)0%   (0/3)0%   (0/1)
getImageDescriptor (): ImageDescriptor 0%   (0/1)0%   (0/2)0%   (0/1)
getName (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getPathToConfigFile (): String 0%   (0/1)0%   (0/15)0%   (0/2)
getPersistable (): IPersistableElement 0%   (0/1)0%   (0/2)0%   (0/1)
getToolTipText (): String 0%   (0/1)0%   (0/2)0%   (0/1)
isEmpty (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
notifyObserver (): void 0%   (0/1)0%   (0/6)0%   (0/3)
removeConfigEntry (ConfigEntry): void 0%   (0/1)0%   (0/16)0%   (0/5)
saveState (IMemento): void 0%   (0/1)0%   (0/6)0%   (0/3)
update (Observable, Object): void 0%   (0/1)0%   (0/3)0%   (0/2)

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.IAdaptable;
9import org.eclipse.core.runtime.IPath;
10import org.eclipse.jface.resource.ImageDescriptor;
11import org.eclipse.ui.IEditorInput;
12import org.eclipse.ui.IMemento;
13import org.eclipse.ui.IPersistableElement;
14 
15import de.uka.ipd.sdq.sensorframework.entities.Experiment;
16import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun;
17import de.uka.ipd.sdq.sensorframework.entities.Sensor;
18import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory;
19import de.uka.ipd.sdq.sensorframework.filter.FilteredCollectionsManager;
20import de.uka.ipd.sdq.sensorframework.visualisation.VisualisationPlugin;
21 
22/** @author Roman Andrej */
23public class ConfigEditorInput extends Observable
24                implements IEditorInput, IPersistableElement,IAdaptable, Observer {
25        
26        /** Create the filter manager instance. */
27        private FilteredCollectionsManager filtersManager = new FilteredCollectionsManager();
28        
29        private List<ConfigEntry> configEntrys;
30        private String adapterFactoryID;
31        
32        public ConfigEditorInput(String adapterFactoryID) {
33                this.configEntrys = new ArrayList<ConfigEntry>();
34                this.adapterFactoryID = adapterFactoryID;
35        }
36        
37        public ConfigEditorInput(String adapterFactoryID, ConfigEntry configEntry) {
38                this.configEntrys = new ArrayList<ConfigEntry>();
39                this.adapterFactoryID = adapterFactoryID;
40                addConfigEntry(configEntry);
41        }
42        
43        /** Edit command of ConfigEntry */
44        public void editConfigEntry(IDAOFactory datasource, ExperimentRun run, Experiment experiment, Sensor sensor, String adapterFactoryID) {
45                ConfigEntry configEntry = getConfigEntryToRun(run);
46                
47                if (configEntry == null) {
48                        ConfigEntry confEntry = new ConfigEntry(datasource,run,experiment,sensor);
49                        confEntry.addObserver(this);
50                        configEntrys.add(confEntry);
51                } else
52                        configEntry.setSensorChecked(sensor);
53                notifyObserver();
54        }
55        
56        /** Add new ConfigEntry */
57        public void addConfigEntry(ConfigEntry configEntry){
58                configEntry.addObserver(this);
59                configEntrys.add(configEntry);
60                notifyObserver();
61        }
62        
63        /** Remove a ConfigEntry */
64        public void removeConfigEntry(ConfigEntry entry){
65                if (configEntrys.contains(entry)){
66                        entry.deleteObserver(this);
67                        configEntrys.remove(entry);
68                        notifyObserver();
69                }
70        }
71        
72        public ConfigEntry getConfigEntryToRun(ExperimentRun run){
73                for(ConfigEntry re : configEntrys){
74                        if (re.getExperimentRun().equals(run))
75                                return re;
76                }
77                return null;
78        }
79        
80        public List<ConfigEntry> getConfigEntrys() {
81                return configEntrys;
82        }
83        
84        public boolean isEmpty(){
85                return configEntrys.isEmpty();
86        }
87 
88        /* (non-Javadoc)
89         * @see org.eclipse.ui.IEditorInput#exists()
90         */
91        public boolean exists() {
92                return false;
93        }
94 
95        /* (non-Javadoc)
96         * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
97         */
98        public ImageDescriptor getImageDescriptor() {
99                 return ImageDescriptor.getMissingImageDescriptor();
100        }
101 
102        /* (non-Javadoc)
103         * @see org.eclipse.ui.IEditorInput#getName()
104         */
105        public String getName() {
106                return "";
107        }
108 
109        /* (non-Javadoc)
110         * @see org.eclipse.ui.IEditorInput#getPersistable()
111         */
112        public IPersistableElement getPersistable() {
113                return this;
114        }
115 
116        /* (non-Javadoc)
117         * @see org.eclipse.ui.IEditorInput#getToolTipText()
118         */
119        public String getToolTipText() {
120                return "";
121        }
122 
123        /* (non-Javadoc)
124         * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
125         */
126        @SuppressWarnings("unchecked")
127        public Object getAdapter(Class adapter) {
128                if (adapter == ConfigEditorInput.class)
129                        return this;
130                return null;
131        }
132 
133        
134        
135        /* (non-Javadoc)
136         * @see org.eclipse.ui.IPersistableElement#getFactoryId()
137         */
138        public String getFactoryId() {
139                return ConfigEditorInputFactory.getFactoryId();
140        }
141 
142        /* (non-Javadoc)
143         * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
144         */
145        public void saveState(IMemento memento) {
146                try
147                {
148                        ConfigEditorInputFactory.saveState(memento, this);
149                } catch (Exception e) {
150                        /* ignore errors if they happen, most likely the corresponding  
151                         * sensor entities have been deleted meanwhile
152                         */
153                }
154        }
155 
156        /**Set the status of this class to changed and notifies all
157         * listening observers.
158         */
159        private void notifyObserver() {
160                setChanged();
161                notifyObservers(this);
162        }
163 
164        /** {@inheritDoc}
165         */
166        public void update(Observable o, Object arg) {
167                // call the local method.
168                notifyObserver();
169        }
170        
171        /**
172         * Return absolute path of the config file. It develops out location in the
173         * local file system of the plug-in state area for this plug-in and defined
174         * name.
175         * 
176         * @return path to configurations file.
177         */
178        public static String getPathToConfigFile() {
179                IPath path = VisualisationPlugin.getDefault().getStateLocation();
180 
181                return path.toPortableString() + "/" + "persistable_element.xml";
182        }
183 
184        public String getAdapterFactoryID() {
185                return this.adapterFactoryID;
186        }
187 
188        public FilteredCollectionsManager getFiltersManager() {
189                return filtersManager;
190        }
191}

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