Package: ImportExamplesWizard

ImportExamplesWizard

nameinstructionbranchcomplexitylinemethod
ImportExamplesWizard()
M: 20 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
addPages()
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
createPageControls(Composite)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getNextPage(IWizardPage)
M: 8 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: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
performCancel()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
performFinish()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
updateImportPage()
M: 14 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.help
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.help.wizard;
23:
24: import java.io.IOException;
25:
26: import org.eclipse.jface.viewers.IStructuredSelection;
27: import org.eclipse.jface.wizard.IWizardPage;
28: import org.eclipse.jface.wizard.Wizard;
29: import org.eclipse.swt.widgets.Composite;
30: import org.eclipse.ui.IImportWizard;
31: import org.eclipse.ui.IWorkbench;
32: import org.overture.ide.help.IVdmHelpConstants;
33: import org.overture.ide.help.VdmHelpPlugin;
34: import org.overture.ide.help.wizard.SelectDialectWizardPage.DialectSelectedHandler;
35: import org.overture.ide.ui.wizard.pages.WizardProjectsImportPageProxy;
36:
37: public class ImportExamplesWizard extends Wizard implements IImportWizard
38: {
39:
40:         private WizardProjectsImportPageProxy importPageProxy = new WizardProjectsImportPageProxy();
41:         private SelectDialectWizardPage dialectSelectionPage = new SelectDialectWizardPage(new DialectSelectedHandler()
42:         {
43:
44:                 @Override
45:                 public void dialectSelected(String dialect)
46:                 {
47:
48:                         String dialectName = "SL";
49:                         if (dialect.equalsIgnoreCase("VDM-SL"))
50:                         {
51:                                 dialectName = "VDMSL";
52:                         } else if (dialect.equalsIgnoreCase("VDM-PP"))
53:                         {
54:                                 dialectName = "VDM++";
55:                         } else if (dialect.equalsIgnoreCase("VDM-RT"))
56:                         {
57:                                 dialectName = "VDMRT";
58:                         }
59:
60:                         archiveInputPath = "html/Example_package_" + dialectName + ".zip";
61:
62:                         updateImportPage();
63:                 }
64:         });
65:         private String archiveInputPath = "html/Example_package_VDMSL.zip";
66:
67:         public ImportExamplesWizard()
68:         {
69:         }
70:
71:         @Override
72:         public void createPageControls(Composite pageContainer)
73:         {
74:                 super.createPageControls(pageContainer);
75:         }
76:
77:         void updateImportPage()
78:         {
79:                 try
80:                 {
81:                         this.importPageProxy.setBundleRelativeInputPath(IVdmHelpConstants.PLUGIN_ID, this.archiveInputPath);
82:                 } catch (IOException e)
83:                 {
84:                         VdmHelpPlugin.logErrorMessage("Failed to get path for embedded exmaples.zip");
85:                 }
86:                 this.importPageProxy.createPageControlsPostconfig();
87:         }
88:
89:         @Override
90:         public void addPages()
91:         {
92:                 super.addPages();
93:                 addPage(this.dialectSelectionPage);
94:                 addPage(this.importPageProxy.getPage());
95:         }
96:
97:         @Override
98:         public void init(IWorkbench workbench, IStructuredSelection selection)
99:         {
100:
101:         }
102:         
103:         @Override
104:         public IWizardPage getNextPage(IWizardPage page)
105:         {
106:                 IWizardPage p = super.getNextPage(page);
107:                 updateImportPage();
108:                 return p;
109:         }
110:         
111:
112:         @Override
113:         public boolean performFinish()
114:         {
115:                 updateImportPage();
116:                 this.importPageProxy.performFinish();
117:                 return true;
118:         }
119:
120:         @Override
121:         public boolean performCancel()
122:         {
123:                 this.importPageProxy.performCancel();
124:                 return true;
125:         }
126:
127: }