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

COVERAGE SUMMARY FOR SOURCE FILE [FeatureModelInstanceContributor.java]

nameclass, %method, %block, %line, %
FeatureModelInstanceContributor.java0%   (0/2)0%   (0/13)0%   (0/329)0%   (0/71)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FeatureModelInstanceContributor0%   (0/1)0%   (0/9)0%   (0/134)0%   (0/38)
FeatureModelInstanceContributor (): void 0%   (0/1)0%   (0/12)0%   (0/4)
addGlobalActions (IMenuManager): void 0%   (0/1)0%   (0/11)0%   (0/3)
contributeToMenu (IMenuManager): void 0%   (0/1)0%   (0/29)0%   (0/7)
fillContextMenu (IMenuManager): void 0%   (0/1)0%   (0/6)0%   (0/2)
removeAllReferencesOnDelete (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/13)0%   (0/4)
setActiveEditor (IEditorPart): void 0%   (0/1)0%   (0/43)0%   (0/11)
setConfiguration (Configuration): void 0%   (0/1)0%   (0/9)0%   (0/3)
setShell (Shell): void 0%   (0/1)0%   (0/9)0%   (0/3)
     
class InstanceValidateAction0%   (0/1)0%   (0/4)0%   (0/195)0%   (0/33)
InstanceValidateAction (): void 0%   (0/1)0%   (0/3)0%   (0/1)
run (): void 0%   (0/1)0%   (0/184)0%   (0/28)
setConfiguration (Configuration): void 0%   (0/1)0%   (0/4)0%   (0/2)
setShell (Shell): void 0%   (0/1)0%   (0/4)0%   (0/2)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.featureinstance;
5 
6import org.eclipse.emf.common.EMFPlugin;
7import org.eclipse.emf.common.util.Diagnostic;
8import org.eclipse.emf.ecore.resource.Resource;
9import org.eclipse.emf.ecore.util.Diagnostician;
10import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
11import org.eclipse.emf.edit.ui.action.ValidateAction;
12import org.eclipse.emf.edit.ui.action.ValidateAction.EclipseResourcesUtil;
13import org.eclipse.jface.action.IMenuManager;
14import org.eclipse.jface.action.MenuManager;
15import org.eclipse.jface.action.Separator;
16import org.eclipse.jface.dialogs.MessageDialog;
17import org.eclipse.jface.viewers.ISelection;
18import org.eclipse.jface.viewers.ISelectionChangedListener;
19import org.eclipse.jface.viewers.ISelectionProvider;
20import org.eclipse.jface.viewers.IStructuredSelection;
21import org.eclipse.jface.viewers.SelectionChangedEvent;
22import org.eclipse.swt.widgets.Shell;
23import org.eclipse.ui.IEditorPart;
24 
25import de.uka.ipd.sdq.dialogs.error.ErrorDisplayDialog;
26import de.uka.ipd.sdq.featureconfig.Configuration;
27 
28class InstanceValidateAction extends ValidateAction {
29        
30        Configuration config;
31        Shell shell;
32        
33        @Override
34        /**
35         * {@inheritDoc}
36         */
37        /* starts the validation-process and processes the results*/
38        public void run() {
39                Diagnostician diagnostician = new Diagnostician();
40                Diagnostic d = diagnostician.validate(config);
41                ErrorDisplayDialog errord;
42 
43                switch (d.getSeverity()) {
44                case Diagnostic.CANCEL: 
45                        String errorMsg = "The validation was cancelled:\n\n";
46                        for (Diagnostic currentD : d.getChildren()) {
47                                errorMsg = errorMsg + currentD.getMessage() + "\n";
48                        }
49                        errord = new ErrorDisplayDialog(shell,new Throwable(errorMsg));
50                        errord.open(); break;
51                case Diagnostic.ERROR: 
52                        errorMsg = "The validation finished with errors:\n\n";
53                        for (Diagnostic currentD : d.getChildren()) {
54                                errorMsg = errorMsg + currentD.getMessage() + "\n";
55                        }
56                        errord = new ErrorDisplayDialog(shell,new Throwable(errorMsg));
57                        errord.open(); break;
58                case Diagnostic.WARNING:
59                        errorMsg = "The validation finished with warnings:\n\n";
60                        for (Diagnostic currentD : d.getChildren()) {
61                                errorMsg = errorMsg + currentD.getMessage() + "\n";
62                        }
63                        errord = new ErrorDisplayDialog(shell,new Throwable(errorMsg));
64                        errord.open(); break;
65                case Diagnostic.OK: 
66                        MessageDialog.openInformation(shell, "Validation success", "The validation completed successfully");
67                        break;
68                case Diagnostic.INFO: 
69                        MessageDialog.openInformation(shell, "Validation", "The validation completed with informational messages");
70                        break;
71                default:
72                        errorMsg = "The validation finished with an unknown status:\n\n";
73                
74                for (Diagnostic currentD : d.getChildren()) {
75                        errorMsg = errorMsg + currentD.getMessage() + "\n";
76                }
77 
78//                EclipseResourcesUtil eclipseResourcesUtil = 
79//                        EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE ?
80//                                        new EclipseResourcesUtil() :
81//                                                null;
82//
83//                                        if (eclipseResourcesUtil != null)
84//                                        {
85//                                                Resource resource = domain.getResourceSet().getResources().get(0);
86//                                                if (resource != null)
87//                                                {
88//                                                        eclipseResourcesUtil.deleteMarkers(resource);
89//                                                        for (Diagnostic childDiagnostic : d.getChildren())
90//                                                        {
91//                                                                eclipseResourcesUtil.createMarkers(resource, childDiagnostic);
92//                                                        }
93//                                                }
94//                                        }
95 
96                errord = new ErrorDisplayDialog(shell,new Throwable(errorMsg));
97                errord.open(); break;
98                }
99        }
100        
101        /**
102         * Setter for the Configuration object needed in the validation
103         * 
104         * @param config the Configuration object
105         */
106        public void setConfiguration (Configuration config) {
107                this.config = config;        
108        }
109        
110        /**
111         * Setter for the Shell object needed for the validation-result dialogs
112         * 
113         * @param shell the Shell object
114         */
115        public void setShell (Shell shell) {
116                this.shell = shell;
117        }
118 
119}
120/**
121 * @author Grischa Liebel
122 *
123 */
124public class FeatureModelInstanceContributor extends
125                EditingDomainActionBarContributor implements ISelectionChangedListener {
126 
127        /**
128         * This keeps track of the active editor.
129         * <!-- begin-user-doc -->
130         * <!-- end-user-doc -->
131         * @generated
132         */
133        protected IEditorPart activeEditorPart;
134        
135        protected InstanceValidateAction myValidate;
136 
137        /**
138         * This keeps track of the current selection provider.
139         * <!-- begin-user-doc -->
140         * <!-- end-user-doc -->
141         * @generated
142         */
143        protected ISelectionProvider selectionProvider;
144 
145        /**
146         * This creates an instance of the contributor.
147         * <!-- begin-user-doc -->
148         * <!-- end-user-doc -->
149         * @generated
150         */
151        public FeatureModelInstanceContributor() {
152                super(ADDITIONS_LAST_STYLE);
153                validateAction = null;
154                myValidate = new InstanceValidateAction();
155        }
156        
157        
158        public void fillContextMenu(IMenuManager manager)
159        {
160                manager.appendToGroup("Validate", myValidate);
161        }
162        
163        /**
164         * This adds to the menu bar a menu and some separators for editor additions,
165         * as well as the sub-menus for object creation items.
166         * <!-- begin-user-doc -->
167         * <!-- end-user-doc -->
168         * @generated
169         */
170        @Override
171        public void contributeToMenu(IMenuManager menuManager) {
172                super.contributeToMenu(menuManager);
173 
174                IMenuManager submenuManager = new MenuManager("FeatureModelInstance", "de.uka.ipd.sdq.FeatureInstanceMenuID");
175                menuManager.insertAfter("additions", submenuManager);
176                submenuManager.add(new Separator("additions"));
177                submenuManager.add(new Separator("additions-end"));
178 
179                addGlobalActions(submenuManager);
180        }
181        
182        /**
183         * Setter for the Configuration object needed in the validation
184         * 
185         * @param config the Configuration object
186         */
187        public void setConfiguration(Configuration config) {
188                if (myValidate instanceof InstanceValidateAction) {
189                        ((InstanceValidateAction)myValidate).setConfiguration(config);
190                }
191        }
192        
193        /**
194         * Setter for the Shell object needed for the validation-result dialogs
195         * 
196         * @param shell the Shell object
197         */
198        public void setShell (Shell shell) {
199                if (myValidate instanceof InstanceValidateAction) {
200                        ((InstanceValidateAction)myValidate).setShell(shell);
201                }
202        }
203 
204        /**
205         * When the active editor changes, this remembers the change and registers with it as a selection provider.
206         * <!-- begin-user-doc -->
207         * <!-- end-user-doc -->
208         * @generated
209         */
210        @Override
211        public void setActiveEditor(IEditorPart part) {
212                super.setActiveEditor(part);
213                activeEditorPart = part;
214 
215                // Switch to the new selection provider.
216                //
217                if (selectionProvider != null) {
218                        selectionProvider.removeSelectionChangedListener(this);
219                }
220                if (part == null) {
221                        selectionProvider = null;
222                }
223                else {
224                        selectionProvider = part.getSite().getSelectionProvider();
225                        selectionProvider.addSelectionChangedListener(this);
226 
227                        // Fake a selection changed event to update the menus.
228                        //
229                        if (selectionProvider.getSelection() != null) {
230                                selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
231                        }
232                }
233        }
234 
235        public void selectionChanged(SelectionChangedEvent event) {
236                ISelection selection = event.getSelection();
237                if (selection instanceof IStructuredSelection) {
238                        myValidate.updateSelection((IStructuredSelection)selection);
239                }
240        }
241 
242        /**
243         * This inserts global actions before the "additions-end" separator.
244         * <!-- begin-user-doc -->
245         * <!-- end-user-doc -->
246         * @generated
247         */
248        @Override
249        protected void addGlobalActions(IMenuManager menuManager) {
250                menuManager.insertAfter("additions-end", new Separator("ui-actions"));
251 
252                super.addGlobalActions(menuManager);
253        }
254 
255        /**
256         * This ensures that a delete action will clean up all references to deleted objects.
257         * <!-- begin-user-doc -->
258         * <!-- end-user-doc -->
259         * @generated
260         */
261        @Override
262        protected boolean removeAllReferencesOnDelete() {
263                return true;
264        }
265 
266}

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