32 import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
32 import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
33 import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; |
33 import org.eclipse.wst.common.project.facet.core.runtime.IRuntime; |
34 import org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard; |
34 import org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard; |
35 import org.symbian.tools.tmw.core.TMWCore; |
35 import org.symbian.tools.tmw.core.TMWCore; |
36 import org.symbian.tools.tmw.core.projects.IFProjSupport; |
36 import org.symbian.tools.tmw.core.projects.IFProjSupport; |
|
37 import org.symbian.tools.tmw.ui.project.INewApplicationWizardPage; |
|
38 import org.symbian.tools.tmw.ui.project.IProjectTemplate; |
37 |
39 |
38 /** |
40 /** |
39 * @author Eugene Ostroukhov (eugeneo@symbian.org) |
41 * @author Eugene Ostroukhov (eugeneo@symbian.org) |
40 */ |
42 */ |
41 public final class NewApplicationWizard extends ModifyFacetedProjectWizard implements INewWizard { |
43 public final class NewApplicationWizard extends ModifyFacetedProjectWizard implements INewWizard { |
|
44 private final PageContributions contributions = new PageContributions(); |
42 private final DataBindingContext databindingContext = new DataBindingContext(); |
45 private final DataBindingContext databindingContext = new DataBindingContext(); |
|
46 private NewApplicationFacetsWizardPage facetsPage; |
43 private NewApplicationDetailsWizardPage firstPage; |
47 private NewApplicationDetailsWizardPage firstPage; |
44 private IStructuredSelection selection; |
48 private IStructuredSelection selection; |
|
49 private NewApplicationTemplateWizardPage templatesPage; |
45 private final WizardContext wizardContext = new WizardContext(); |
50 private final WizardContext wizardContext = new WizardContext(); |
46 private IWorkbench workbench; |
51 private IWorkbench workbench; |
47 private FacetsSelectionPage facetsPage; |
|
48 private NewApplicationTemplateWizardPage templatesPage; |
|
49 |
52 |
50 public NewApplicationWizard() { |
53 public NewApplicationWizard() { |
51 setShowFacetsSelectionPage(false); |
54 setShowFacetsSelectionPage(false); |
52 } |
55 } |
53 |
56 |
59 if (project == null) { |
62 if (project == null) { |
60 facets = Collections.emptySet(); |
63 facets = Collections.emptySet(); |
61 } else { |
64 } else { |
62 facets = project.getProjectFacets(); |
65 facets = project.getProjectFacets(); |
63 } |
66 } |
64 facetsPage = new FacetsSelectionPage(facets, getFacetedProjectWorkingCopy()); |
67 facetsPage = new NewApplicationFacetsWizardPage(facets, getFacetedProjectWorkingCopy()); |
65 addPage(facetsPage); |
68 addPage(facetsPage); |
66 templatesPage = new NewApplicationTemplateWizardPage(wizardContext, databindingContext); |
69 templatesPage = new NewApplicationTemplateWizardPage(wizardContext, databindingContext); |
67 addPage(templatesPage); |
70 addPage(templatesPage); |
68 super.addPages(); |
71 super.addPages(); |
69 } |
72 } |
94 |
97 |
95 IWizardPage nextPage = super.getNextPage(page); |
98 IWizardPage nextPage = super.getNextPage(page); |
96 return nextPage; |
99 return nextPage; |
97 } |
100 } |
98 |
101 |
|
102 private IProjectTemplate template = null; |
|
103 private INewApplicationWizardPage[] templatePages = new INewApplicationWizardPage[0]; |
|
104 |
99 public IWizardPage[] getPages() { |
105 public IWizardPage[] getPages() { |
|
106 final IProjectTemplate current = wizardContext.getTemplate(); |
|
107 if (template != current) { |
|
108 for (INewApplicationWizardPage page : templatePages) { |
|
109 page.remove(); |
|
110 page.dispose(); |
|
111 } |
|
112 if (current == null) { |
|
113 template = null; |
|
114 templatePages = new INewApplicationWizardPage[0]; |
|
115 } else { |
|
116 template = current; |
|
117 templatePages = contributions.createPages(template.getId()); |
|
118 for (INewApplicationWizardPage page : templatePages) { |
|
119 page.setWizard(this); |
|
120 page.init(wizardContext, databindingContext); |
|
121 } |
|
122 } |
|
123 } |
100 final IWizardPage[] base = super.getPages(); |
124 final IWizardPage[] base = super.getPages(); |
101 final IWizardPage[] pages = new IWizardPage[base.length + 3]; |
125 final IWizardPage[] pages = new IWizardPage[base.length + 3 + templatePages.length]; |
102 |
126 |
103 pages[0] = this.firstPage; |
127 pages[0] = this.firstPage; |
104 pages[1] = this.templatesPage; |
128 pages[1] = this.templatesPage; |
105 pages[2] = this.facetsPage; |
129 pages[2] = this.facetsPage; |
|
130 if (templatePages.length > 0) { |
|
131 System.arraycopy(templatePages, 0, pages, 3, templatePages.length); |
|
132 } |
106 System.arraycopy(base, 0, pages, 2, base.length); |
133 System.arraycopy(base, 0, pages, 2, base.length); |
107 |
134 |
108 return pages; |
135 return pages; |
109 } |
136 } |
110 |
137 |
120 * Returns the selection that this wizard was launched from. |
147 * Returns the selection that this wizard was launched from. |
121 * |
148 * |
122 * @return the selection that this wizard was launched from |
149 * @return the selection that this wizard was launched from |
123 * @since 1.4 |
150 * @since 1.4 |
124 */ |
151 */ |
125 |
|
126 public IStructuredSelection getSelection() { |
152 public IStructuredSelection getSelection() { |
127 return this.selection; |
153 return this.selection; |
128 } |
154 } |
129 |
155 |
130 /** |
156 /** |
131 * Returns the workbench that this wizard belongs to. |
157 * Returns the workbench that this wizard belongs to. |
132 * |
158 * |
133 * @return the workbench that this wizard belongs to |
159 * @return the workbench that this wizard belongs to |
134 * @since 1.4 |
160 * @since 1.4 |
135 */ |
161 */ |
136 |
|
137 public IWorkbench getWorkbench() { |
162 public IWorkbench getWorkbench() { |
138 return this.workbench; |
163 return this.workbench; |
139 } |
164 } |
140 |
165 |
141 public void init(final IWorkbench workbench, final IStructuredSelection selection) { |
166 public void init(final IWorkbench workbench, final IStructuredSelection selection) { |