Package: VdmAddLibraryWizard

VdmAddLibraryWizard

nameinstructionbranchcomplexitylinemethod
VdmAddLibraryWizard()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
addPages()
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
init(IWorkbench, IStructuredSelection)
M: 48 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
isOoDialect()
M: 19 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
performFinish()
M: 16 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.ui
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.ui.wizard;
23:
24: import org.eclipse.core.resources.IFolder;
25: import org.eclipse.core.resources.IProject;
26: import org.eclipse.core.runtime.CoreException;
27: import org.eclipse.jface.dialogs.MessageDialog;
28: import org.eclipse.jface.viewers.IStructuredSelection;
29: import org.eclipse.jface.wizard.Wizard;
30: import org.eclipse.ui.IWorkbench;
31: import org.eclipse.ui.IWorkbenchWizard;
32: import org.overture.ast.lex.Dialect;
33: import org.overture.ide.core.resources.IVdmProject;
34: import org.overture.ide.ui.VdmUIPlugin;
35: import org.overture.ide.ui.wizard.pages.LibraryIncludePage;
36: import org.overture.ide.ui.wizard.pages.LibraryUtil;
37:
38: public class VdmAddLibraryWizard extends Wizard implements IWorkbenchWizard
39: {
40:         private static final String WIZARD_NAME = "Add Library Wizard";
41:         private IVdmProject project = null;
42:         private LibraryIncludePage _pageTwo;
43:
44:         public VdmAddLibraryWizard() {
45:                 setWindowTitle(WIZARD_NAME);
46:         }
47:
48:         @Override
49:         public boolean performFinish()
50:         {
51:                 try
52:                 {
53:                         LibraryUtil.createSelectedLibraries(project,_pageTwo.getLibrarySelection());
54:                 } catch (CoreException e)
55:                 {
56:•                        if (VdmUIPlugin.DEBUG)
57:                         {
58:                                 e.printStackTrace();
59:                         }
60:                         return false;
61:                 }
62:                 return true;
63:         }
64:
65:         public void init(IWorkbench workbench, IStructuredSelection selection)
66:         {
67:•                if(selection.getFirstElement() instanceof IProject ){
68:                         IProject project = (IProject) selection.getFirstElement();
69:                         this.project = (IVdmProject) project.getAdapter(IVdmProject.class);
70:                 }
71:•                if (selection.getFirstElement() instanceof IVdmProject)
72:                 {                                        
73:                         this.project = (IVdmProject) selection.getFirstElement();
74:•                }else if(selection.getFirstElement() instanceof IFolder)
75:                 {
76:                         IProject project = ((IFolder)selection.getFirstElement()).getProject();
77:                         this.project = (IVdmProject) project.getAdapter(IVdmProject.class);
78:                         
79:•                        if(this.project == null)
80:                         {
81:                                 MessageDialog.openError(getShell(), "Project type error", "Project is not a VDM project");
82:                         }
83:                 }
84:
85:         }
86:
87:         @Override
88:         public void addPages()
89:         {
90:                 _pageTwo = new LibraryIncludePage("Add Library",isOoDialect(),project);
91:                 
92:                 addPage(_pageTwo);
93:         }
94:         
95:         private boolean isOoDialect()
96:         {
97:•                if(project!= null)
98:                 {
99:•                        return project.getDialect() == Dialect.VDM_PP || project.getDialect() == Dialect.VDM_RT;
100:                 }
101:                 return false;
102:         }
103:
104:
105:
106: }