Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.ui')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/build.properties1
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/plugin.xml1
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/schema/newWizardPages.exsd246
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties10
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java28
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPage.java119
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java348
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java740
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCCProjectWizard.java31
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCProjectWizard.java35
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java11
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java24
12 files changed, 1588 insertions, 6 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/build.properties b/build/org.eclipse.cdt.managedbuilder.ui/build.properties
index 7258fc9dfd4..e336bca207a 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/build.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/build.properties
@@ -4,3 +4,4 @@ bin.includes = plugin.xml,\
icons/,\
mgdbuildui.jar
source.mgdbuildui.jar = src/
+src.includes = schema/
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
index 3d0ece08835..b74ed934d5a 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
@@ -23,6 +23,7 @@
<import plugin="org.eclipse.core.variables"/>
</requires>
+ <extension-point id="newWizardPages" name="Custom MBS New Wizard Pages" schema="schema/newWizardPages.exsd"/>
<extension
point="org.eclipse.ui.newWizards">
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/schema/newWizardPages.exsd b/build/org.eclipse.cdt.managedbuilder.ui/schema/newWizardPages.exsd
new file mode 100644
index 00000000000..ebe0d291693
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/schema/newWizardPages.exsd
@@ -0,0 +1,246 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.managedbuilder.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.managedbuilder.ui" id="newWizardPages" name="Custom Wizard Pages for MBS New Project Wizards"/>
+ </appInfo>
+ <documentation>
+ This extension point allows for the specification of pages to the New Managed C/C++ wizards. Via this extension point, the developer may specify one or more wizard pages to add to the wizard, and optionally only add these pages if certain conditions on the project type, project toolchain, and project nature are met. The developer may also specify a Java class which performs any operations pursuant to the state of the wizard when the user clicks Finish.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <documentation>
+ Extensions to this extension point must contain at least one wizardPage child element.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="wizardPage" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="wizardPage">
+ <annotation>
+ <documentation>
+ Each instance of this element defines an additional page which is added to the New Project wizard. Pages are added after the default pages provided by MBS. Pages are added in the order they are discovered.
+
+Note that the IWizardPage interface allows a page to specify programmatically and dynamically at runtime what its previous and next pages are. This element does not trump that behaviour, but rather just specifies the order in which the pages are added to the wizard (and hence the order in which the pages appear if they do not override the previous and next page methods).
+
+Wizard pages as GUI elements by themselves are really not all that useful. More than likely if someone is defining their own wizard pages it’s because they need some additional operations to happen upon project creation in addition to the stock behaviour of creating a basic project, and they want to use their new wizard pages to provide a front end to these operations.
+
+As such, along with a specification of the GUI wizard page, ISVs may specify a runnable operation that will be executed in the wizard’s doRunEpilogue() method. These contributions will all be executed in the order that the wizard pages were added to the wizard. Not all pages need have such a contribution however, as ISVs may need to perform all the operations associated with their pages as a group. In cases such as this the ISV can define an operation for one of the pages and it can pull data from any of the other pages as required.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="nature" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toolchain" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="projectType" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="ID" type="string" use="required">
+ <annotation>
+ <documentation>
+ A unique identifier for the page which will be used to reference the page.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="pageClass" type="string" use="required">
+ <annotation>
+ <documentation>
+ Specifies the Java class which implements the added page. This class must implement the org.eclipse.jface.wizard.IWizardPage interface.
+
+For convenience, there is an org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPage abstract class which provides a default implementation of the getNextPage() and getPreviousPage() members that orders pages in the order they are discovered by the wizard.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="operationClass" type="string">
+ <annotation>
+ <documentation>
+ Specifies the Java class which implements the operations associated with this page. The class must implement the java.lang.Runnable interface.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="nature">
+ <annotation>
+ <documentation>
+ This optional child element of wizardPage specifies the project nature(s) for which the additional pages should apply. One instance of this element is provided per nature supported.
+
+ This would for example allow one to add pages to the New Managed C Project wizard but not the New Managed C++ project wizard, or other hypothetical natures that might be supported by MBS in the future (e.g. someday there might be a Fortran nature).
+If no natureID elements are specified, then it is assumed that the page potentially applies to all project natures, although it may still be excluded based on project type or toolchain.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="natureID" type="string" use="required">
+ <annotation>
+ <documentation>
+ The unique ID of a nature (org.eclipse.core.resources.natures) for which this page should appear.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toolchain">
+ <annotation>
+ <documentation>
+ This is an optional child element of wizardPage which specifies a toolchain for which the additional pages should apply. One instance of this element is provided per toolchain supported by the page.
+
+If no toolchain elements are specified, then it is assumed that the page potentially applies to all toolchains, although it may still be excluded based on project type or project nature.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="toolchainID" type="string" use="required">
+ <annotation>
+ <documentation>
+ The unique ID of a toolchain for which this page should appear.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="versionsSupported" type="string">
+ <annotation>
+ <documentation>
+ A comma separated list of specific versions of the toolchain that are supported by the page. If not specified, it is assumed that this page supports the toolchain regardless of version.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="projectType">
+ <annotation>
+ <documentation>
+ This is an optional child element of wizardPage which specifies a projectType for which the additional pages should apply. One instance of this element is provided per toolchain supported by the page.
+
+If no projectType elements are specified, then it is assumed that the page potentially applies to all projectTypes, although it may still be excluded based on toolchain or nature.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="projectTypeID" type="string" use="required">
+ <annotation>
+ <documentation>
+ The unique ID of a projectType for which this page should appear.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ &lt;extension
+ point=&quot;org.eclipse.cdt.managedbuilder.ui.newWizardPages&quot;&gt;
+ &lt;wizardPage
+ ID=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.AlwaysPresentWizardPage&quot;
+ pageClass=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.AlwaysPresentWizardPage&quot;/&gt;
+ &lt;wizardPage
+ ID=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.NatureAWizardPage&quot;
+ pageClass=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.NatureAWizardPage&quot;&gt;
+ &lt;nature natureID=&quot;A&quot;/&gt;
+ &lt;/wizardPage&gt;
+ &lt;wizardPage
+ ID=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.NatureBWizardPage&quot;
+ pageClass=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.NatureBWizardPage&quot;&gt;
+ &lt;nature natureID=&quot;B&quot;/&gt;
+ &lt;/wizardPage&gt;
+ &lt;wizardPage
+ ID=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ToolchainCWizardPage&quot;
+ pageClass=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ToolchainCWizardPage&quot;&gt;
+ &lt;toolchain toolchainID=&quot;C&quot;/&gt;
+ &lt;/wizardPage&gt;
+ &lt;wizardPage
+ ID=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ProjectTypeDWizardPage&quot;
+ pageClass=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ProjectTypeDWizardPage&quot;&gt;
+ &lt;projectType projectTypeID=&quot;D&quot;/&gt;
+ &lt;/wizardPage&gt;
+ &lt;wizardPage
+ ID=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ProjectTypeEWizardPage&quot;
+ pageClass=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ProjectTypeEWizardPage&quot;&gt;
+ &lt;projectType projectTypeID=&quot;E&quot;/&gt;
+ &lt;/wizardPage&gt;
+ &lt;wizardPage
+ ID=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ToolchainFWizardPage&quot;
+ pageClass=&quot;org.eclipse.cdt.managedbuilder.ui.tests.wizardPages.ToolchainFWizardPage&quot;&gt;
+ &lt;toolchain toolchainID=&quot;F&quot;/&gt;
+ &lt;/wizardPage&gt;
+ &lt;/extension&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ None
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ None.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2005 Texas Instruments Incorporated and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
index 0b461c16d23..3b4505798bb 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties
@@ -66,6 +66,16 @@ BuildPropertyPage.unsupported.proj=The project support is not installed on the s
BuildPropertyPage.unsupported.config=The configuration support is not installed on the system
BuildPropertyPage.config.notselected=No configurations selected
+# ----------- Managed Build Custom Wizard Page Manager Error Strings -----------
+MBSCustomPageManager.error0=Unknown element type
+MBSCustomPageManager.error1=\ for extension point
+MBSCustomPageManager.error2=Unknown child element type
+MBSCustomPageManager.error3=\ for wizardPage element in extension point
+MBSCustomPageManager.error4=Missing projectType ID
+MBSCustomPageManager.error5=Missing projectType ID
+MBSCustomPageManager.error6=Missing nature ID
+
+
# ----------- Managed Build Preference Page -----------
BuildPreferencePage.label.Settings=Workspace Settings
BuildPreferencePage.job.rebuild=Rebuilding the Managed Projects
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
index 8ed99368d06..6753c25384c 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java
@@ -14,6 +14,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
+import java.util.Set;
+import java.util.LinkedHashSet;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -64,7 +66,12 @@ public class CProjectPlatformPage extends WizardPage {
private static final String TARGET_TIP = TIP + ".platform"; //$NON-NLS-1$
private static final String FORCEDCONFIG_TIP = TIP + ".forcedconfigs"; //$NON-NLS-1$
-
+ // support for exporting data to custom wizard pages
+ public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.platformPage"; //$NON-NLS-1$
+ public static final String PROJECT_TYPE = "projectType"; //$NON-NLS-1$
+ public static final String TOOLCHAIN = "toolchain"; //$NON-NLS-1$
+ public static final String NATURE = "nature"; //$NON-NLS-1$
+
protected NewManagedProjectWizard parentWizard;
protected Combo platformSelection;
private ArrayList selectedConfigurations;
@@ -261,6 +268,22 @@ public class CProjectPlatformPage extends WizardPage {
// Get the selections from the table viewer
selectedConfigurations.clear();
selectedConfigurations.addAll(Arrays.asList(tableViewer.getCheckedElements()));
+
+ // support for publishing the toolchains for the selected configs so that custom wizard
+ // pages will know which toolchains have been selected
+
+ // get the toolchains from the selected configs and put them into a set
+ Set toolchainSet = new LinkedHashSet();
+ for(int k = 0; k < selectedConfigurations.size(); k++)
+ {
+ IConfiguration config = (IConfiguration) selectedConfigurations.get(k);
+ IToolChain toolchain = config.getToolChain();
+ toolchainSet.add(toolchain);
+ }
+
+ // publish the set of selected toolchains with the custom page manager
+ MBSCustomPageManager.addPageProperty(PAGE_ID, TOOLCHAIN, toolchainSet);
+
setPageComplete(validatePage());
}
@@ -281,6 +304,9 @@ public class CProjectPlatformPage extends WizardPage {
if (selectedProjectType != (IProjectType) projectTypes.get(index)) {
selectedProjectType = (IProjectType) projectTypes.get(index);
parentWizard.updateProjectTypeProperties();
+
+ // publish which project type has been chosen with the custom wizard page manager
+ MBSCustomPageManager.addPageProperty(PAGE_ID, PROJECT_TYPE, selectedProjectType.getId());
}
}
populateConfigurations(false);
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPage.java
new file mode 100644
index 00000000000..54807776f71
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPage.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Texas Instruments Incorporated and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Texas Instruments - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+
+/**
+ * This abstract class provides a convenient, partial implementation of the IWizardPage interface.
+ * This class consults with the MBSCustomPageManager to determine its actions.
+
+ * If an ISV’s custom pages do not subclass MBSCustomPage then their page implementation must be
+ * carefully coded to function properly while still respecting the rules laid out by the page manager.
+ */
+public abstract class MBSCustomPage implements IWizardPage
+{
+
+ protected String pageID = null;
+ protected IWizard wizard = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizardPage#isCustomPageComplete()
+ */
+ public boolean canFlipToNextPage() {
+ return (getNextPage() != null && isCustomPageComplete());
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizardPage#getWizard()
+ */
+ public IWizard getWizard()
+ {
+ return wizard;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizardPage#setPreviousPage
+ */
+ public void setPreviousPage(IWizardPage page)
+ {
+ // do nothing, we use the page manager
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizardPage#setWizard()
+ */
+ public void setWizard(IWizard newWizard)
+ {
+ wizard = newWizard;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizardPage#getNextPage()
+ */
+ public IWizardPage getNextPage()
+ {
+ // consult with the page manager to determine which pages are to be displayed
+ return MBSCustomPageManager.getNextPage(pageID);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizardPage#getPreviousPage()
+ */
+ public IWizardPage getPreviousPage()
+ {
+ // consult with the page manager to determine which pages are to be displayed
+ return MBSCustomPageManager.getPreviousPage(pageID);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.IWizardPage#isPageComplete()
+ */
+ public boolean isPageComplete()
+ {
+ /* Since the wizard must have all the pages added to it regardless of whether they are visible
+ * or not, this method consults the page manager to see if the page is visible. If it is not,
+ * then the page is always considered complete. If the page is visible then the child class is
+ * consulted to see if it determines the page to be complete based on its own criteria.
+ */
+
+ // if we are not visible then return true so that the wizard can enable the Finish button
+ if (!MBSCustomPageManager.isPageVisible(pageID))
+ {
+ return true;
+ }
+
+ return isCustomPageComplete();
+ }
+
+ /**
+ * @return The unique ID by which this page is referred.
+ */
+ public String getPageID()
+ {
+ return pageID;
+ }
+
+ /**
+ * @return true if the page is complete, false otherwise. This method is called to determine
+ * the status of the wizard's Finish button.
+ *
+ * @see org.eclipse.jface.wizard.IWizardPage#isPageComplete()
+ */
+ protected abstract boolean isCustomPageComplete();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java
new file mode 100644
index 00000000000..be3dd4990df
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java
@@ -0,0 +1,348 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Texas Instruments Incorporated and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Texas Instruments - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.jface.wizard.IWizardPage;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.Iterator;
+
+/**
+ * This class is responsible for storing all of the data associated with a given custom wizard page.
+ */
+public final class MBSCustomPageData
+{
+
+ private Set natureSet = null;
+
+ private Set toolchainSet = null;
+
+ private Set projectTypeSet = null;
+
+ private IWizardPage wizardPage = null;
+
+ private Runnable operation = null;
+
+ private String id = null;
+
+ private boolean isStock = false;
+
+ /**
+ * Stores data on a particular toolchain that a custom wizard page supports.
+ */
+ public class ToolchainData
+ {
+ private String id = null;
+
+ private String[] versionsSupported = null;
+
+ /**
+ * @param id The id to set.
+ * @since 3.0
+ */
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * @return Returns the id.
+ * @since 3.0
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * @param versionsSupported The versionsSupported to set.
+ * @since 3.0
+ */
+ public void setVersionsSupported(String[] versionsSupported)
+ {
+ this.versionsSupported = versionsSupported;
+ }
+
+ /**
+ * @return Returns the versionsSupported.
+ * @since 3.0
+ */
+ public String[] getVersionsSupported()
+ {
+ return versionsSupported;
+ }
+
+ }
+
+ /**
+ * Contstructs a custom page data record
+ *
+ * @param id - Unique ID of the page
+ * @param wizardPage - the IWizardPage that is displayed in the wizard
+ * @param operation - the Runnable() that is executed during the wizard's DoRunEpilogue() method, or null if no operation is specified
+ * @param isStock - true if the page is a stock page provided by Managed Build, false otherwise.
+ * @since 3.0
+ */
+ public MBSCustomPageData(String id, IWizardPage wizardPage,
+ Runnable operation, boolean isStock)
+ {
+
+ this.id = id;
+ this.wizardPage = wizardPage;
+ this.operation = operation;
+ this.isStock = isStock;
+ }
+
+ /**
+ * @return The unique ID by which this page is referred to.
+ * @since 3.0
+ */
+ public String getID()
+ {
+ return id;
+ }
+
+ /**
+ * @return The IWizardPage corresponding to the actual page to be displayed in the wizard.
+ * @since 3.0
+ */
+ public IWizardPage getWizardPage()
+ {
+ return wizardPage;
+ }
+
+ /**
+ * @return true if this page is a stock page provided by the Managed Build System, false otherwise.
+ * @since 3.0
+ */
+ public boolean isStockPage()
+ {
+
+ return isStock;
+ }
+
+ /**
+ * @param nature A fully qualified nature ID (org.eclipse.core.resources.IProjectNature). Currently MBS
+ * only supports creating projects with either one of two natures:
+ * org.eclipse.cdt.core.cnature and org.eclipse.cdt.core.ccnature
+ * @return true if the page should be visible when the project has the given nature, false otherwise.
+ * @since 3.0
+ */
+ public boolean shouldBeVisibleForNature(String nature)
+ {
+ if (natureSet == null)
+ return true;
+
+ return hasNature(nature);
+ }
+
+ private boolean hasNature(String nature)
+ {
+ return natureSet.contains(nature);
+
+ }
+
+ /**
+ * @return An array of nature IDs corresponding to the natures for which this page should appear.
+ * @since 3.0
+ */
+ public String[] getNatures()
+ {
+ Object[] objArray = natureSet.toArray();
+
+ String[] strArray = new String[objArray.length];
+ for (int k = 0; k < objArray.length; k++)
+ {
+ strArray[k] = objArray[k].toString();
+
+ }
+
+ return strArray;
+ }
+
+ /**
+ * @param id - The unique ID of the toolchain
+ * @param version - The version of the toolchain, or <code>null</code> if versions are not to be checked.
+ * @return true if the page should be present for the given toolchain and version, false otherwise.
+ * @since 3.0
+ */
+ public boolean shouldBeVisibleForToolchain(String id, String version)
+ {
+ // if no toolchains specified then always return true
+ if (toolchainSet.size() == 0)
+ return true;
+
+ Iterator iterator = toolchainSet.iterator();
+
+ while (iterator.hasNext())
+ {
+ ToolchainData tcd = (ToolchainData) iterator.next();
+
+ // look for toolchain with same id
+ if (tcd.getId().equals(id))
+ {
+ // if we don't check versions then we're done
+ if (version == null)
+ return true;
+
+ // does the toolchain have a compatible version?
+ for (int k = 0; k < tcd.getVersionsSupported().length; k++)
+ {
+ // TODO: implement version support - should this check for an exact match?
+ // An older version of a tool-chain could use a different custom page
+ // than a newer version.
+ if (tcd.getVersionsSupported()[k].compareTo(version) >= 0)
+ {
+ return true;
+ }
+ }
+
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @return The set of toolchains supported by this page, or null if this page does not specify any
+ * toolchain dependencies.
+ * @since 3.0
+ */
+ public ToolchainData[] getToolchains()
+ {
+ if (toolchainSet == null)
+ return null;
+
+ ToolchainData[] tcd = new ToolchainData[toolchainSet.size()];
+
+ Iterator iterator = toolchainSet.iterator();
+
+ int k = 0;
+
+ while (iterator.hasNext())
+ {
+ tcd[k++] = (ToolchainData) iterator.next();
+ }
+ if (tcd.length > 0)
+ return tcd;
+ else
+ return null;
+ }
+
+ /**
+ * @return The set of project types supported by this page, or null if there are no such dependencies.
+ * @since 3.0
+ */
+ public String[] getProjectTypes()
+ {
+ if (projectTypeSet == null || projectTypeSet.size() == 0)
+ return null;
+
+ Object[] objArray = projectTypeSet.toArray();
+
+ String[] strArray = new String[objArray.length];
+ for (int k = 0; k < objArray.length; k++)
+ {
+ strArray[k] = objArray[k].toString();
+
+ }
+
+ return strArray;
+ }
+
+ /**
+ * Adds a dependency to this page upon a given nature. The page will be visible
+ * iff the given nature is selected by the user.
+ *
+ * @param nature The unique ID of the nature.
+ * @since 3.0
+ */
+ public void addNature(String nature)
+ {
+ if (nature == null)
+ return;
+
+ if (natureSet == null)
+ natureSet = new TreeSet();
+
+ natureSet.add(nature);
+ }
+
+ /**
+ * Adds a dependency to this page upon a given toolchain. The page will be visible
+ * iff one or more of the selected project configurations utilizes the specified toolchain.
+ * If versions are specified, then the version of the toolchain must exactly match one of the specified versions.
+ *
+ * @param toolchainID - The unique ID of the toolchain.
+ * @param versionsSupported - A comma separated list of supported versions, or null if no version checking is to be done.
+ * @since 3.0
+ */
+ public void addToolchain(String toolchainID, String[] versionsSupported)
+ {
+ if(toolchainID == null)
+ return;
+
+ if (toolchainSet == null)
+ toolchainSet = new TreeSet();
+
+ ToolchainData toolchainData = new ToolchainData();
+ toolchainData.setId(toolchainID);
+ toolchainData.setVersionsSupported(versionsSupported);
+
+ toolchainSet.add(toolchainData);
+ }
+
+ /**
+ * @param projectType The unique ID of the project type to check.
+ * @return true if this page should be visible if the given project type is selected, false otherwise.
+ * @since 3.0
+ */
+ public boolean shouldBeVisibleForProjectType(String projectType)
+ {
+ if (projectTypeSet == null)
+ return true;
+
+ if (projectTypeSet.contains(projectType))
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Adds a dependency to this page upon a given project type. The page will be visible
+ * iff the given project type is selected by the user.
+ *
+ * @param projectType - The unique ID of the project type.
+ * @since 3.0
+ */
+ public void addProjectType(String projectType)
+ {
+ if(projectType == null)
+ return;
+
+ if (projectTypeSet == null)
+ projectTypeSet = new TreeSet();
+
+ projectTypeSet.add(projectType);
+ }
+
+ /**
+ * @return the java.lang.Runnable() operation associated with this page that should be run during
+ * the wizard's doRunEpilogue() method. This operation should only be executed if in fact the page
+ * is visible.
+ * @since 3.0
+ */
+ public Runnable getOperation()
+ {
+ return operation;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java
new file mode 100644
index 00000000000..d954058b0a5
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java
@@ -0,0 +1,740 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Texas Instruments Incorporated and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Texas Instruments - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.ui.wizards;
+
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.wizard.IWizardPage;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.Set;
+import java.util.LinkedHashSet;
+import java.util.Iterator;
+import java.util.Stack;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * This class is responsible for managing the use of custom pages in the Managed Build System's
+ * New Project wizards.
+ *
+ * This class is a singleton.
+ */
+public final class MBSCustomPageManager
+{
+
+ /**
+ * ID attribute of nature element
+ */
+ public static final String NATURE_ID = "natureID"; //$NON-NLS-1$
+
+ /**
+ * versions supported attribute of toolchain element
+ */
+ public static final String VERSIONS_SUPPORTED = "versionsSupported"; //$NON-NLS-1$
+
+ /**
+ * ID attribute of toolchain element
+ */
+ public static final String TOOLCHAIN_ID = "toolchainID"; //$NON-NLS-1$
+
+ /**
+ * ID attribute of projectType element
+ */
+ public static final String PROJECT_TYPE_ID = "projectTypeID"; //$NON-NLS-1$
+
+ /**
+ * nature element
+ */
+ public static final String NATURE = "nature"; //$NON-NLS-1$
+
+ /**
+ * toolchain element
+ */
+ public static final String TOOLCHAIN = "toolchain"; //$NON-NLS-1$
+
+ /**
+ * project type element
+ */
+ public static final String PROJECT_TYPE = "projectType"; //$NON-NLS-1$
+
+ /**
+ * attribute for the class associated witha wizardPage element
+ */
+ public static final String PAGE_CLASS = "pageClass"; //$NON-NLS-1$
+
+ /**
+ * attribute for the operation that is run for a wizardPage during the wizard's DoRunEpilogue() method
+ */
+ public static final String OPERATION_CLASS = "operationClass"; //$NON-NLS-1$
+
+ /**
+ * ID attribute for wizardPage
+ */
+ public static final String ID = "ID"; //$NON-NLS-1$
+
+ /**
+ * element for a custom wizard page
+ */
+ public static final String WIZARD_PAGE = "wizardPage"; //$NON-NLS-1$
+
+ /**
+ * Maps String IDs to IWizardPages
+ */
+ private static Map idToPageDataMap = null;
+
+
+ /**
+ * The set of pages that this manager knows about.
+ */
+ private static Set pageSet = null;
+
+ private static boolean extensionsLoaded = false;
+
+ /**
+ * Maps page IDs to the properties that page has set.
+ */
+ private static java.util.Map pageIDtoPagePropertiesMap = null;
+
+ private static boolean initialized = false;
+
+ private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.managedbuilder.ui.newWizardPages"; //$NON-NLS-1$
+
+ /**
+ *
+ * Looks for contributions to the extension point org.eclipse.cdt.managedbuilder.ui.newWizardPages and adds all pages to the manager.
+ * @since 3.0
+ *
+ */
+ public static void loadExtensions() throws BuildException
+ {
+ if (extensionsLoaded)
+ return;
+
+ loadExtensionsSynchronized();
+ }
+
+ private synchronized static void loadExtensionsSynchronized()
+ throws BuildException
+ {
+ // Do this once
+ if (extensionsLoaded)
+ return;
+ extensionsLoaded = true;
+
+ // Get the extensions
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint(EXTENSION_POINT_ID);
+ if (extensionPoint != null)
+ {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ if (extensions != null)
+ {
+
+ for (int i = 0; i < extensions.length; ++i)
+ {
+ IExtension extension = extensions[i];
+
+ // Get the "configuraton elements" defined in the plugin.xml file.
+ // Note that these "configuration elements" are not related to the
+ // managed build system "configurations".
+ // From the PDE Guide:
+ // A configuration element, with its attributes and children, directly
+ // reflects the content and structure of the extension section within the
+ // declaring plug-in's manifest (plugin.xml) file.
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+
+ // process the top level elements for this extension
+ for (int k = 0; k < elements.length; k++)
+ {
+ IConfigurationElement element = elements[k];
+
+ if (element.getName().equals(WIZARD_PAGE))
+ {
+ // load the data associated with the wizard page
+ loadWizardPage(element);
+ }
+
+ else
+ {
+ // there are currently no other supported element types
+ // so throw an exception
+ throw new BuildException(ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error0") //$NON-NLS-1$
+ + element.getName()
+ + ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error1") //$NON-NLS-1$
+ + EXTENSION_POINT_ID);
+ }
+ }
+
+ }
+
+ }
+ }
+ }
+
+ private static void loadWizardPage(IConfigurationElement element)
+ throws BuildException
+ {
+ // get the ID and wizard page
+ String id = element.getAttribute(ID);
+
+ String operationClassName = element.getAttribute(OPERATION_CLASS); // optional element so may be null
+
+ IWizardPage wizardPage = null;
+ Runnable operation = null;
+ // instantiate the classes specified in the manifest
+
+ // first try to create the page class, which is required
+ try
+ {
+ wizardPage = (IWizardPage) element.createExecutableExtension(PAGE_CLASS);
+
+ // the operation is an optional element so it might not be present
+ if (element.getAttribute(OPERATION_CLASS) != null)
+ operation = (Runnable) element.createExecutableExtension(OPERATION_CLASS);
+ }
+ catch (CoreException e)
+ {
+ // convert to a build exception
+ throw new BuildException(e.getMessage());
+ }
+
+ // create the page data and add it to ourselves
+ MBSCustomPageData currentPageData = new MBSCustomPageData(id,
+ wizardPage, operation, false);
+ idToPageDataMap.put(id, currentPageData);
+ pageSet.add(currentPageData);
+
+ // load any child elements
+ IConfigurationElement[] children = element.getChildren();
+
+ for (int k = 0; k < children.length; k++)
+ {
+ IConfigurationElement childElement = children[k];
+
+ if (childElement.getName().equals(PROJECT_TYPE))
+ {
+ loadProjectType(childElement, currentPageData);
+ }
+
+ else
+ {
+ if (childElement.getName().equals(TOOLCHAIN))
+ {
+ loadToolchain(childElement, currentPageData);
+ }
+
+ else
+ {
+ if (childElement.getName().equals(NATURE))
+ {
+ loadNature(childElement, currentPageData);
+ }
+
+ else
+ {
+ // no other types supported... throw an exception
+ // there are currently no other supported element types
+ // so throw an exception
+ throw new BuildException(ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error2") //$NON-NLS-1$
+ + element.getName()
+ + ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error3") //$NON-NLS-1$
+ + EXTENSION_POINT_ID);
+ }
+ }
+ }
+ }
+ }
+
+ private static void loadProjectType(IConfigurationElement element,
+ MBSCustomPageData currentPageData) throws BuildException
+ {
+ String projectType = element.getAttribute(PROJECT_TYPE_ID);
+
+ if (projectType != null)
+ currentPageData.addProjectType(projectType);
+ else
+ throw new BuildException(ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error4")); //$NON-NLS-1$
+ }
+
+ private static void loadToolchain(IConfigurationElement element,
+ MBSCustomPageData currentPageData) throws BuildException
+ {
+ String toolchainID = element.getAttribute(TOOLCHAIN_ID);
+
+ if (toolchainID != null)
+ {
+ // get the supported versions
+ String unparsedVersions = element.getAttribute(VERSIONS_SUPPORTED);
+ String[] versionsSupported = null;
+
+ if (unparsedVersions != null)
+ {
+ // parse out the individual versions - they are comma separated
+ versionsSupported = unparsedVersions.split(","); //$NON-NLS-1$
+ }
+
+ // add toolchain data for the page
+ currentPageData.addToolchain(toolchainID, versionsSupported);
+ }
+ else
+ throw new BuildException(ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error5")); //$NON-NLS-1$
+ }
+
+ private static void loadNature(IConfigurationElement element,
+ MBSCustomPageData currentPageData) throws BuildException
+ {
+ String nature = element.getAttribute(NATURE_ID);
+
+ if (nature != null)
+ currentPageData.addNature(nature);
+ else
+ throw new BuildException(ManagedBuilderUIMessages.getResourceString("MBSCustomPageManager.error6")); //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @param pageID - The unique ID of the page to search for.
+ *
+ * @return - The MBSCustomPageData corresponding to the page, or null
+ * if not found.
+ *
+ * @since 3.0
+ */
+ public static MBSCustomPageData getPageData(String pageID)
+ {
+ return (MBSCustomPageData) idToPageDataMap.get(pageID);
+ }
+
+ /**
+ * @param pageID - The unique ID of the page to be tested.
+ * @return true if the page is visible given the currently selected project type, nature, and toolchain. false otherwise.
+ * @since 3.0
+ */
+ public static boolean isPageVisible(String pageID)
+ {
+ MBSCustomPageData page = getPageData(pageID);
+
+ if(page == null)
+ return false;
+
+
+ // first, find out what project type, toolchain, and nature have been set
+ Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(CProjectPlatformPage.PAGE_ID);
+
+ String projectType = pagePropertiesMap.get(CProjectPlatformPage.PROJECT_TYPE).toString();
+
+ Set toolchainSet = (Set) pagePropertiesMap.get(CProjectPlatformPage.TOOLCHAIN);
+
+ String nature = pagePropertiesMap.get(CProjectPlatformPage.NATURE).toString();
+
+ // does the page follow nature and project type constraints?
+ if (page.shouldBeVisibleForNature(nature)
+ && page.shouldBeVisibleForProjectType(projectType))
+ {
+
+ MBSCustomPageData.ToolchainData[] toolchainData = page.getToolchains();
+
+ // if no toolchains are specified then we're done
+ if (toolchainData == null)
+ {
+ return true;
+ }
+
+ // otherwise, iterate through the toolchains to see if one matches
+ for (int k = 0; k < toolchainData.length; k++)
+ {
+
+ // check all toolchains, see if there is one for which we should be present
+ Iterator toolchainIterator = toolchainSet.iterator();
+
+ while (toolchainIterator.hasNext())
+ {
+ IToolChain toolchain = (IToolChain) toolchainIterator.next();
+
+ // get the ID and version
+ // version support in MBS is not complete yet so just check the id for now
+ // TODO: implement version support
+ if (toolchain.getId().equals(toolchainData[k].getId()))
+ {
+ return true;
+ }
+ }
+
+ }
+
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ * Publishes a piece of data associated with a wizard page. Clients (e.g. other wizard pages) can retrieve
+ * the values of these pieces of data later given the proper page ID and key.
+ *
+ * @param pageID - The unique ID of the page for which the data is being added.
+ *
+ * @param key - A unique name by which the data is referred to.
+ *
+ * @param data - The data to be stored. No assumptions are made about the type of data stored. It is up to the
+ * contributor of a given page to establish their own contract as to what type of data is stored.
+ *
+ * @since 3.0
+ *
+ * @see org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager#getPageProperty(String, String)
+ */
+ public static void addPageProperty(String pageID, String key, Object data)
+ {
+ Map propertiesMap = (Map) pageIDtoPagePropertiesMap.get(pageID);
+
+ if (propertiesMap == null)
+ {
+ propertiesMap = new TreeMap();
+ pageIDtoPagePropertiesMap.put(pageID, propertiesMap);
+ }
+
+ propertiesMap.put(key, data);
+ }
+
+ /**
+ * Retrieves a previously published piece of data associated with a wizard page.
+ *
+ *
+ * @param pageID - The unique ID of the page for which the
+ * data should be retrieved.
+ *
+ * @param key - The unique name of the data to be retrieved.
+ *
+ * @return The data that was stored for the given key. No assumptions are made about the type of data stored. It is up to the
+ * contributor of a given page to establish their own contract as to what type of data is stored.
+ *
+ * There are certain well known pieces of data published by the stock wizard pages provided by the Managed Build System.
+ * See org.eclipse.cdt.maangedbuilder.ui.wizards.CProjectPlatformPage.
+ *
+ * @see org.eclipse.cdt.maangedbuilder.ui.wizards.CProjectPlatformPage
+ * @see org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager#addPageProperty(String, String, Object)
+ *
+ * @since 3.0
+ */
+ public static Object getPageProperty(String pageID, String key)
+ {
+ Map propertiesMap = (Map) pageIDtoPagePropertiesMap.get(pageID);
+
+ if (propertiesMap != null)
+ {
+ return propertiesMap.get(key);
+ }
+
+ else
+ return null;
+ }
+
+ /**
+ * Gets the next page that should appear in the wizard. This takes into account the selected
+ * project type, project nature, and toolchains.
+ *
+ * @param currentPageID - The unique ID of the page the wizard is currently displaying.
+ * @return The next page that should be displayed in the wizard, or null if at the end of the wizard.
+ * @since 3.0
+ */
+ public static IWizardPage getNextPage(String currentPageID)
+ {
+ // find the current page in the set of pages
+ MBSCustomPageData pageData = getPageData(currentPageID);
+ MBSCustomPageData currentData = null;
+
+ Iterator iterator = pageSet.iterator();
+
+ while (iterator.hasNext())
+ {
+ currentData = (MBSCustomPageData) iterator.next();
+
+ if (currentData == pageData)
+ {
+
+ // we found the page we're looking for so stop looking
+ break;
+ }
+ }
+
+ if (currentData == pageData)
+ {
+ // we found our page
+ // look for the next page that satisfies all project type, toolchain, and nature criteria
+
+ // first, find out what project type, toolchain, and nature have been set
+ Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(CProjectPlatformPage.PAGE_ID);
+
+ String projectType = pagePropertiesMap.get(CProjectPlatformPage.PROJECT_TYPE).toString();
+
+ Set toolchainSet = (Set) pagePropertiesMap.get(CProjectPlatformPage.TOOLCHAIN);
+
+ String nature = pagePropertiesMap.get(CProjectPlatformPage.NATURE).toString();
+
+ IWizardPage nextPage = null;
+
+ boolean pageFound = false;
+
+ while (iterator.hasNext() && !pageFound)
+ {
+ MBSCustomPageData potentialPage = (MBSCustomPageData) iterator.next();
+
+ if (isPageVisible(potentialPage.getID()))
+ {
+ pageFound = true;
+ nextPage = potentialPage.getWizardPage();
+ }
+ }
+
+ if (pageFound)
+ return nextPage;
+
+ }
+
+ return null;
+ }
+
+ /**
+ * Adds an entry for a stock page into the manager. This is used for pages provided by the Managed Build System that are not loaded via the
+ * extension point mechanism.
+ *
+ * @param page - The IWizardPage to add.
+ * @param pageID - A unique ID to associate with this page. This ID will be used to refer to the page by the rest of the system.
+ * @since 3.0
+ */
+ public static void addStockPage(IWizardPage page, String pageID)
+ {
+ MBSCustomPageData pageData = new MBSCustomPageData(pageID, page, null, true);
+ idToPageDataMap.put(pageID, pageData);
+ pageSet.add(pageData);
+ }
+
+ /**
+ * Gets the previous page that should appear in the wizard. This takes into account the selected
+ * project type, project nature, and toolchains. Stock pages can be returned by this method as well as
+ * custom pages.
+ *
+ * @param currentPageID - The unique ID of the page currently being displayed in the wizard.
+ * @return - The IWizardPage that corresponds to the previous page to be displayed in the wizard, or null if at the start of the wizard.
+ * @since 3.0
+ */
+ public static IWizardPage getPreviousPage(String currentPageID)
+ {
+ // find the current page in the set of pages
+ MBSCustomPageData pageData = getPageData(currentPageID);
+ MBSCustomPageData currentData = null;
+
+ Iterator iterator = pageSet.iterator();
+
+ // since Java has no concept of a reverse-iterator yet, we must keep a stack of the
+ // pages we have visited, so that we can get them in reverse chronological order
+ Stack pageDataStack = new Stack();
+
+ while (iterator.hasNext())
+ {
+ currentData = (MBSCustomPageData) iterator.next();
+
+ if (currentData == pageData)
+ {
+
+ // we found the page we're looking for so stop looking
+ break;
+ }
+
+ else
+ {
+ pageDataStack.push(currentData);
+ }
+ }
+
+ if (currentData == pageData)
+ {
+ // we found our page
+ // look for the previous page that satisfies all project type, toolchain, and nature criteria
+
+ // first, find out what project type, toolchain, and nature have been set
+ Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(CProjectPlatformPage.PAGE_ID);
+
+ String projectType = pagePropertiesMap.get(CProjectPlatformPage.PROJECT_TYPE).toString();
+
+ Set toolchainSet = (Set) pagePropertiesMap.get(CProjectPlatformPage.TOOLCHAIN);
+
+ String nature = pagePropertiesMap.get(CProjectPlatformPage.NATURE).toString();
+
+ IWizardPage prevPage = null;
+
+ boolean pageFound = false;
+
+ // use the stack to visit the previous pages
+ while (pageDataStack.size() != 0 && !pageFound)
+ {
+ MBSCustomPageData potentialPage = (MBSCustomPageData) pageDataStack.pop();
+
+ if (isPageVisible(potentialPage.getID()))
+ {
+ pageFound = true;
+ prevPage = potentialPage.getWizardPage();
+ }
+
+ }
+
+ if (pageFound)
+ return prevPage;
+
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets the pages that the page manager knows about.
+ *
+ * @return An array of IWizardPage objects corresponding to all pages the manager knows about.
+ * Pages are returned in the order they appear in the wizard, and include both stock and custom pages.
+ *
+ * @since 3.0
+ *
+ * @see getCustomPages()
+ */
+ public static IWizardPage[] getPages()
+ {
+ IWizardPage[] pages = new IWizardPage[pageSet.size()];
+
+ Iterator iterator = pageSet.iterator();
+
+ int k = 0;
+
+ while(iterator.hasNext())
+ {
+ MBSCustomPageData page = (MBSCustomPageData) iterator.next();
+
+ pages[k++] = page.getWizardPage();
+ }
+
+ return pages;
+ }
+
+ /**
+ * Gets all custom pages that the page manager knows about.
+ *
+ * @return An array of IWizardPage objects corresponding to all custom pages the manager knows about.
+ * Pages are returned in the order they appear in the wizard. Stock pages are not included.
+ *
+ * @since 3.0
+ *
+ * @see getPages()
+ */
+ public static IWizardPage[] getCustomPages()
+ {
+ Set customPageSet = new LinkedHashSet();
+
+ Iterator pageIterator = pageSet.iterator();
+
+ while(pageIterator.hasNext())
+ {
+ MBSCustomPageData page = (MBSCustomPageData) pageIterator.next();
+
+ if (!page.isStockPage())
+ {
+ customPageSet.add(page.getWizardPage());
+ }
+
+ }
+
+ Iterator iterator = customPageSet.iterator();
+
+ IWizardPage[] pages = new IWizardPage[customPageSet.size()];
+
+ int k = 0;
+ while (iterator.hasNext())
+ {
+ pages[k++] = (IWizardPage) iterator.next();
+ }
+
+ return pages;
+ }
+
+ /**
+ * Gets all operations that should be run during the wizard's DoRunEpilogue() method. Only operations for visible pages are returned.
+ *
+ * @return array of type Runnable[] corresponding to the operations.
+ *
+ * @since 3.0
+ */
+ public static Runnable[] getOperations()
+ {
+ Set operationSet = new LinkedHashSet();
+
+ Iterator pageIterator = pageSet.iterator();
+
+ while(pageIterator.hasNext())
+ {
+ MBSCustomPageData page = (MBSCustomPageData) pageIterator.next();
+
+ if (!page.isStockPage()
+ && isPageVisible(page.getID()))
+ {
+ if (page.getOperation() != null)
+ {
+ operationSet.add(page.getOperation());
+ }
+ }
+
+ }
+
+ if(operationSet.size() == 0)
+ return null;
+
+ Iterator iterator = operationSet.iterator();
+
+ Runnable[] operations = new Runnable[operationSet.size()];
+
+ int k = 0;
+ while (iterator.hasNext())
+ {
+ operations[k++] = (Runnable) iterator.next();
+ }
+
+ return operations;
+
+ }
+
+ /**
+ * Initializes the manager.
+ *
+ * This method should be called before any other operations are performed using this class.
+ *
+ * Initialization is only performed once.
+ *
+ * @since 3.0
+ */
+ public static void init()
+ {
+ if(!initialized)
+ {
+ initialized = true;
+ idToPageDataMap = new TreeMap();
+ pageIDtoPagePropertiesMap = new TreeMap();
+ pageSet = new LinkedHashSet();
+ }
+ }
+
+ // singleton class - do not use
+ private MBSCustomPageManager()
+ {
+
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCCProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCCProjectWizard.java
index 5d5915b85da..1ce44d3ad67 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCCProjectWizard.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCCProjectWizard.java
@@ -1,7 +1,7 @@
package org.eclipse.cdt.managedbuilder.ui.wizards;
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002, 2005 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -12,11 +12,14 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
* **********************************************************************/
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.wizard.IWizardPage;
public class NewManagedCCProjectWizard extends NewManagedProjectWizard {
private static final String WZ_TITLE = "MngCCWizard.title"; //$NON-NLS-1$
@@ -27,15 +30,41 @@ public class NewManagedCCProjectWizard extends NewManagedProjectWizard {
public NewManagedCCProjectWizard() {
this(ManagedBuilderUIMessages.getResourceString(WZ_TITLE), ManagedBuilderUIMessages.getResourceString(WZ_DESC));
+
}
public NewManagedCCProjectWizard(String title, String desc) {
super(title, desc);
+
}
public void addPages() {
// Add the default page for all new managed projects
super.addPages();
+
+ // support for custom wizard pages
+ // publish our nature with the page manager
+ MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, CCProjectNature.CC_NATURE_ID);
+
+ // load all pages specified via extensions
+ try
+ {
+ MBSCustomPageManager.loadExtensions();
+ }
+ catch (BuildException e)
+ {
+ e.printStackTrace();
+ }
+
+ IWizardPage[] customPages = MBSCustomPageManager.getCustomPages();
+
+ if (customPages != null)
+ {
+ for (int k = 0; k < customPages.length; k++)
+ {
+ addPage(customPages[k]);
+ }
+ }
}
protected void doRun(IProgressMonitor monitor) throws CoreException {
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCProjectWizard.java
index f8ad8e0091e..c49fb40da24 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCProjectWizard.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedCProjectWizard.java
@@ -1,7 +1,7 @@
package org.eclipse.cdt.managedbuilder.ui.wizards;
/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * Copyright (c) 2002, 2005 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -11,7 +11,15 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
public class NewManagedCProjectWizard extends NewManagedProjectWizard {
// String constants
@@ -34,6 +42,31 @@ public class NewManagedCProjectWizard extends NewManagedProjectWizard {
public void addPages() {
// Add the default page for all new managed projects
super.addPages();
+
+ // support for custom wizard pages
+ // publish our nature with the page manager
+ MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, CProjectNature.C_NATURE_ID);
+
+ // load all pages specified via extensions
+ try
+ {
+ MBSCustomPageManager.loadExtensions();
+ }
+ catch (BuildException e)
+ {
+ e.printStackTrace();
+ }
+
+
+ IWizardPage[] customPages = MBSCustomPageManager.getCustomPages();
+
+ if (customPages != null)
+ {
+ for (int k = 0; k < customPages.length; k++)
+ {
+ addPage(customPages[k]);
+ }
+ }
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
index d27ee07522b..022fc6d33d8 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectOptionPage.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2002,2005 IBM Corporation and others.
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -26,10 +26,12 @@ import org.eclipse.cdt.ui.wizards.NewCProjectWizardOptionPage;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.jface.wizard.IWizardPage;
public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
-
+ public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.projectOptionsPage"; //$NON-NLS-1$
+
public class ManagedWizardOptionBlock extends ManagedProjectOptionBlock {
NewManagedProjectOptionPage parent;
@@ -127,4 +129,9 @@ public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
optionBlock.setupHelpContextIds();
}
+ public IWizardPage getNextPage()
+ {
+ return MBSCustomPageManager.getNextPage(PAGE_ID); // get first custom page, if any
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
index cc51d948aa9..0f6bd3869b3 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/NewManagedProjectWizard.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2002,2005 IBM Corporation and others.
+ * Copyright (c) 2002, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
@@ -62,6 +62,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
public NewManagedProjectWizard() {
this(ManagedBuilderUIMessages.getResourceString(WZ_TITLE), ManagedBuilderUIMessages.getResourceString(WZ_DESC));
+
}
public NewManagedProjectWizard(String title, String description) {
@@ -83,6 +84,16 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
optionPage.setTitle(ManagedBuilderUIMessages.getResourceString(OPTIONS_TITLE));
optionPage.setDescription(ManagedBuilderUIMessages.getResourceString(OPTIONS_DESC));
addPage(optionPage);
+
+ // add custom pages
+ MBSCustomPageManager.init();
+
+ // add stock pages
+ // TODO: MBSCustomPageManager.addStockPage(fMainPage, NewCProjectWizardPage.PAGE_ID);
+ MBSCustomPageManager.addStockPage(fMainPage, "org.eclipse.cdt.ui.wizard.basicPage");
+ MBSCustomPageManager.addStockPage(projectConfigurationPage, CProjectPlatformPage.PAGE_ID);
+ MBSCustomPageManager.addStockPage(optionPage, NewManagedProjectOptionPage.PAGE_ID);
+
}
public void createPageControls(Composite pageContainer) {
@@ -217,6 +228,17 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
// At this point, I can live with a failure
ManagedBuilderUIPlugin.log(initResult);
}
+
+ // execute any operations specified by custom pages
+ Runnable operations[] = MBSCustomPageManager.getOperations();
+
+ if(operations != null)
+ {
+ for(int k = 0; k < operations.length; k++)
+ {
+ operations[k].run();
+ }
+ }
}
/* (non-Javadoc)

Back to the top