plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/project/NewApplicationWizard.java
--- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/project/NewApplicationWizard.java Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/project/NewApplicationWizard.java Tue Aug 24 15:17:50 2010 -0700
@@ -51,27 +51,27 @@
import org.symbian.tools.tmw.internal.ui.wizard.WizardContext;
/**
+ * This is the wizard that guides through new mobile application project creation.
+ *
* @author Eugene Ostroukhov (eugeneo@symbian.org)
*/
public final class NewApplicationWizard extends ModifyFacetedProjectWizard implements INewWizard {
public static final String ID = "org.symbian.tools.tmw.newproject";
+
private final PageContributions contributions = new PageContributions();
private final DataBindingContext databindingContext = new DataBindingContext();
- private NewApplicationFacetsWizardPage facetsPage;
+ private IWizardPage[] staticPages;
private NewApplicationDetailsWizardPage firstPage;
- private IStructuredSelection selection;
private IProjectTemplate template = null;
private INewApplicationWizardPage[] templatePages = new INewApplicationWizardPage[0];
- private NewApplicationTemplateWizardPage templatesPage;
private final WizardContext wizardContext = new WizardContext();
- private IWorkbench workbench;
public NewApplicationWizard() {
setShowFacetsSelectionPage(false);
}
public void addPages() {
- this.firstPage = createFirstPage();
+ firstPage = new NewApplicationDetailsWizardPage(wizardContext, databindingContext);
addPage(this.firstPage);
final IFacetedProject project = getFacetedProject();
final Set<IProjectFacetVersion> facets;
@@ -80,10 +80,14 @@
} else {
facets = project.getProjectFacets();
}
- facetsPage = new NewApplicationFacetsWizardPage(facets, getFacetedProjectWorkingCopy());
+ final IWizardPage facetsPage = new NewApplicationFacetsWizardPage(facets, getFacetedProjectWorkingCopy());
addPage(facetsPage);
- templatesPage = new NewApplicationTemplateWizardPage(wizardContext, databindingContext);
+ final IWizardPage templatesPage = new NewApplicationTemplateWizardPage(wizardContext, databindingContext);
addPage(templatesPage);
+ staticPages = new IWizardPage[3];
+ staticPages[0] = firstPage;
+ staticPages[1] = templatesPage;
+ staticPages[2] = facetsPage;
super.addPages();
}
@@ -92,11 +96,6 @@
&& super.canFinish();
}
- protected NewApplicationDetailsWizardPage createFirstPage() {
- firstPage = new NewApplicationDetailsWizardPage(wizardContext, databindingContext);
- return firstPage;
- }
-
@Override
public IWizardPage getNextPage(final IWizardPage page) {
final IFacetedProjectWorkingCopy fpjwc = getFacetedProjectWorkingCopy();
@@ -107,15 +106,6 @@
IRuntime runtime = fprojSupport.getRuntime(wizardContext.getRuntime());
fpjwc.setTargetedRuntimes(Collections.singleton(runtime));
fpjwc.setPrimaryRuntime(runtime);
- Set<IProjectFacetVersion> facets = getCurrentFixedFacetVersions();
- facets.addAll(fpjwc.getProjectFacets());
- fpjwc.setProjectFacets(facets);
- fpjwc.setFixedProjectFacets(getCurrentFixedFacets());
- } else if (page == this.templatesPage) {
- Set<IProjectFacetVersion> facets = getCurrentFixedFacetVersions();
- facets.addAll(fpjwc.getProjectFacets());
- fpjwc.setProjectFacets(facets);
- fpjwc.setFixedProjectFacets(getCurrentFixedFacets());
}
final Collection<Action> actions = fpjwc.getProjectFacetActions();
final Collection<Action> toReplace = new HashSet<IFacetedProject.Action>();
@@ -127,11 +117,35 @@
for (Action action : toReplace) {
fpjwc.setProjectFacetActionConfig(action.getProjectFacetVersion().getProjectFacet(), wizardContext);
}
-
- IWizardPage nextPage = super.getNextPage(page);
+ final IWizardPage nextPage = super.getNextPage(page);
+ synchronized (currentFacets) {
+ if (nextPage instanceof NewApplicationFacetsWizardPage && !reentry) {
+ try {
+ reentry = true;
+ final IFacetedProjectWorkingCopy projectWorkingCopy = getFacetedProjectWorkingCopy();
+ final Set<IProjectFacetVersion> facets = projectWorkingCopy.getProjectFacets();
+ final Set<IProjectFacet> fixed = projectWorkingCopy.getFixedProjectFacets();
+ currentFacets.retainAll(facets);
+ for (IProjectFacetVersion facetVersion : facets) {
+ if (!fixed.contains(facetVersion.getProjectFacet())) {
+ currentFacets.add(facetVersion);
+ }
+ }
+ final Set<IProjectFacetVersion> f = getCurrentFixedFacetVersions();
+ f.addAll(currentFacets);
+ fpjwc.setProjectFacets(f);
+ fpjwc.setFixedProjectFacets(getCurrentFixedFacets());
+ } finally {
+ reentry = false;
+ }
+ }
+ }
return nextPage;
}
+ private boolean reentry = false;
+ private final Collection<IProjectFacetVersion> currentFacets = new HashSet<IProjectFacetVersion>();
+
private Set<IProjectFacet> getCurrentFixedFacets() {
final Set<IProjectFacetVersion> fixedFacets = getCurrentFixedFacetVersions();
final Set<IProjectFacet> facets = new HashSet<IProjectFacet>();
@@ -171,11 +185,8 @@
}
}
final IWizardPage[] base = super.getPages();
- final IWizardPage[] pages = new IWizardPage[base.length + 3 + templatePages.length];
-
- pages[0] = this.firstPage;
- pages[1] = this.templatesPage;
- pages[2] = this.facetsPage;
+ final IWizardPage[] pages = new IWizardPage[staticPages.length + templatePages.length];
+ System.arraycopy(staticPages, 0, pages, 0, 3);
if (templatePages.length > 0) {
System.arraycopy(templatePages, 0, pages, 3, templatePages.length);
}
@@ -192,29 +203,8 @@
return wizardContext.getProjectName();
}
- /**
- * Returns the selection that this wizard was launched from.
- *
- * @return the selection that this wizard was launched from
- * @since 1.4
- */
- public IStructuredSelection getSelection() {
- return this.selection;
- }
-
- /**
- * Returns the workbench that this wizard belongs to.
- *
- * @return the workbench that this wizard belongs to
- * @since 1.4
- */
- public IWorkbench getWorkbench() {
- return this.workbench;
- }
-
public void init(final IWorkbench workbench, final IStructuredSelection selection) {
- this.workbench = workbench;
- this.selection = selection;
+ // Do nothing
}
@Override