From 672ce6566777fd2289f315067b542ff89cd2bb76 Mon Sep 17 00:00:00 2001
From: Andrew Ferguson
Date: Thu, 25 Oct 2007 14:45:39 +0000
Subject: [PATCH] 205182: apply fix and add example template
---
.../ui/wizards/MBSWizardHandler.java | 3 +
.../cdt/core/templateengine/TemplateCore.java | 2 +
.../core/templateengine/TemplateEngine.java | 18 +++--
.../cdt/core/templateengine/TemplateInfo.java | 44 ++++++-----
core/org.eclipse.cdt.ui.tests/plugin.xml | 9 +++
.../projectTemplates/testExtraPages/hello.cpp | 10 +++
.../testExtraPages/template.xml | 28 +++++++
.../TestExtraPagesProvider.java | 73 +++++++++++++++++++
.../AbstractWizardDataPage.java | 65 +++++++++++++++++
.../IPagesAfterTemplateSelectionProvider.java | 10 ++-
.../ui/templateengine/IWizardDataPage.java | 14 +++-
.../templateengine/ProjectSelectionPage.java | 23 +++++-
.../cdt/ui/templateengine/Template.java | 63 ++++++++--------
.../templateengine/TemplatesChoiceWizard.java | 30 +++-----
.../pages/NewProjectCreationPage.java | 27 ++++++-
15 files changed, 339 insertions(+), 80 deletions(-)
create mode 100644 core/org.eclipse.cdt.ui.tests/resources/projectTemplates/testExtraPages/hello.cpp
create mode 100644 core/org.eclipse.cdt.ui.tests/resources/projectTemplates/testExtraPages/template.xml
create mode 100644 core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestExtraPagesProvider.java
create mode 100644 core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java
index d66f4a84917..c36be5d1d77 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java
@@ -43,6 +43,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin;
import org.eclipse.cdt.managedbuilder.ui.properties.Messages;
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
+import org.eclipse.cdt.ui.templateengine.IWizardDataPage;
import org.eclipse.cdt.ui.templateengine.Template;
import org.eclipse.cdt.ui.templateengine.TemplateEngineUI;
import org.eclipse.cdt.ui.templateengine.TemplateEngineUIUtil;
@@ -179,6 +180,8 @@ public class MBSWizardHandler extends CWizardHandler {
IWizardPage page = templatePages[i];
if (page instanceof UIWizardPage)
valueStore.putAll(((UIWizardPage)page).getPageData());
+ if (page instanceof IWizardDataPage)
+ valueStore.putAll(((IWizardDataPage)page).getPageData());
}
if (map != null) {
valueStore.putAll(map);
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java
index 6b95af1df96..e4f6bb45aca 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java
@@ -77,6 +77,8 @@ public class TemplateCore {
String msg= MessageFormat.format(TemplateEngineMessages.getString("TemplateCore.InitFailed"), new Object[]{templateInfo.getTemplatePath()}); //$NON-NLS-1$
throw new TemplateInitializationException(msg);
}
+ if(descriptorURL==null)
+ throw new TemplateInitializationException("Unable to load project template. Location URL is null for "+templateInfo.getTemplateId()); //$NON-NLS-1$
templateDescriptor = new TemplateDescriptor(descriptorURL, templateInfo.getPluginId());
valueStore = new ValueStore/**/(this);
valueStore.putAll(templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement()));
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java
index 181cdbec2d1..0b7437170d9 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java
@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -55,7 +56,7 @@ public class TemplateEngine {
private Map/*>*/ templateInfoMap;
/**
- * TemplateEngine constructor, create and initialize SharedDefaults.
+ * TemplateEngine constructor, create and initialise SharedDefaults.
*/
private TemplateEngine() {
templateInfoMap = new LinkedHashMap/*>*/();
@@ -73,7 +74,7 @@ public class TemplateEngine {
try {
tcores.add(TemplateCore.getTemplate(info));
} catch (TemplateInitializationException e) {
- CCorePlugin.log(e);
+ CCorePlugin.log(CCorePlugin.createStatus(e.getMessage(), e));
}
}
return (TemplateCore[]) tcores.toArray(new TemplateCore[tcores.size()]);
@@ -211,7 +212,7 @@ public class TemplateEngine {
String projectType = null;
String filterPattern = null;
boolean isCategory = false;
- String extraPagesProvider = null;
+ Object /*IPagesAfterTemplateSelectionProvider*/ extraPagesProvider = null;
IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(TEMPLATES_EXTENSION_ID).getExtensions();
for(int i=0; i
+
+
+
diff --git a/core/org.eclipse.cdt.ui.tests/resources/projectTemplates/testExtraPages/hello.cpp b/core/org.eclipse.cdt.ui.tests/resources/projectTemplates/testExtraPages/hello.cpp
new file mode 100644
index 00000000000..ae2678806b6
--- /dev/null
+++ b/core/org.eclipse.cdt.ui.tests/resources/projectTemplates/testExtraPages/hello.cpp
@@ -0,0 +1,10 @@
+#include
+using namespace std;
+
+int main() {
+ cout << "$(projectName)" << endl;
+ cout << "$(exampleAttr1)" << endl;
+ cout << "$(exampleAttr2)" << endl;
+ cout << "$(exampleAttr3)" << endl;
+ return 0;
+}
diff --git a/core/org.eclipse.cdt.ui.tests/resources/projectTemplates/testExtraPages/template.xml b/core/org.eclipse.cdt.ui.tests/resources/projectTemplates/testExtraPages/template.xml
new file mode 100644
index 00000000000..fc6f76a2971
--- /dev/null
+++ b/core/org.eclipse.cdt.ui.tests/resources/projectTemplates/testExtraPages/template.xml
@@ -0,0 +1,28 @@
+
+
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestExtraPagesProvider.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestExtraPagesProvider.java
new file mode 100644
index 00000000000..fa2f2963da8
--- /dev/null
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestExtraPagesProvider.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited 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:
+ * Andrew Ferguson (Symbian) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.tests.templateengine;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+
+import org.eclipse.cdt.ui.templateengine.AbstractWizardDataPage;
+import org.eclipse.cdt.ui.templateengine.IPagesAfterTemplateSelectionProvider;
+import org.eclipse.cdt.ui.templateengine.IWizardDataPage;
+
+/**
+ * An example implementation of {@link IPagesAfterTemplateSelectionProvider} for
+ * testing purposes.
+ */
+public class TestExtraPagesProvider implements IPagesAfterTemplateSelectionProvider {
+ IWizardDataPage[] pages;
+
+ public IWizardDataPage[] createAdditionalPages(IWorkbenchWizard wizard,
+ IWorkbench workbench, IStructuredSelection selection) {
+ pages= new IWizardDataPage[3];
+ pages[0]= new MyPage("Example custom page 1", "exampleAttr1", "Value1");
+ pages[1]= new MyPage("Example custom page 2", "exampleAttr2", "Value2");
+ pages[2]= new MyPage("Example custom page 3", "exampleAttr3", "Value3");
+ return pages;
+ }
+
+ public IWizardDataPage[] getCreatedPages(IWorkbenchWizard wizard) {
+ return pages;
+ }
+
+ /**
+ * An example implementation of {@link IWizardDataPage} for test purposes.
+ */
+ static class MyPage extends AbstractWizardDataPage implements IWizardDataPage {
+ String labelText , dataKey, dataValue;
+
+ public MyPage(String labelText, String dataKey, String dataValue) {
+ super("CustomTestPageName", "Title", null);
+ setMessage("Custom test page message");
+ this.labelText= labelText;
+ this.dataKey= dataKey;
+ this.dataValue= dataValue;
+ }
+
+ public Map getPageData() {
+ return Collections.singletonMap(dataKey, dataValue);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Label l= new Label(parent, SWT.NONE);
+ l.setText(labelText);
+ setControl(l);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java
new file mode 100644
index 00000000000..92eda249378
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited 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:
+ * Andrew Ferguson (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+
+/**
+ * Implementation of standard behaviours intended to be subclassed by clients.
+ * @since 4.0.2
+ */
+public abstract class AbstractWizardDataPage extends WizardPage implements IWizardDataPage {
+ protected IWizardPage next;
+
+ /**
+ * Creates a new wizard page with the given name, and
+ * with no title or image.
+ *
+ * @param pageName the name of the page
+ */
+ public AbstractWizardDataPage(String pageName) {
+ super(pageName);
+ }
+
+ /**
+ * Creates a new wizard page with the given name, title, and image.
+ *
+ * @param pageName the name of the page
+ * @param title the title for this wizard page,
+ * or null
if none
+ * @param imageDescriptor the image descriptor for the title of this wizard page,
+ * or null
if none
+ */
+ public AbstractWizardDataPage(String pageName, String title, ImageDescriptor imageDescriptor) {
+ super(pageName, title, imageDescriptor);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.templateengine.IWizardDataPage#setNextPage(org.eclipse.jface.wizard.IWizardPage)
+ */
+ public void setNextPage(IWizardPage next) {
+ this.next= next;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#getNextPage()
+ */
+ public IWizardPage getNextPage() {
+ if(next != null) {
+ return next;
+ }
+ return super.getNextPage();
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/IPagesAfterTemplateSelectionProvider.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/IPagesAfterTemplateSelectionProvider.java
index d43f40148fd..59ef8012b10 100644
--- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/IPagesAfterTemplateSelectionProvider.java
+++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/IPagesAfterTemplateSelectionProvider.java
@@ -15,16 +15,20 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWizard;
+/**
+ * Interface for extensions that provide additional custom pages as part of
+ * project configuration.
+ * @since 4.0
+ */
public interface IPagesAfterTemplateSelectionProvider {
-
/**
* Creates pages that will be appended to the pages returned from
* TemplatesChoiceWizard.getPagesAfterTemplateSelection()
- * Parameters are those used to initialize the wizard.
+ * Parameters are those used to initialise the wizard.
*
* @param wizard the wizard requesting the pages
* @param workbench the current workbench
- * @param selection the current object selection
+ * @param selection the current object selection, or null if no context is available
*
* @since 4.0
*/
diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/IWizardDataPage.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/IWizardDataPage.java
index 04aac5e5e39..0ada4110655 100644
--- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/IWizardDataPage.java
+++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/IWizardDataPage.java
@@ -15,10 +15,22 @@ import java.util.Map;
import org.eclipse.jface.wizard.IWizardPage;
/**
- * IWizardDataPage
+ * IWizardDataPage is a page which can participate in a custom project template
+ * wizard sequence.
*
* @since 4.0
*/
public interface IWizardDataPage extends IWizardPage {
+ /**
+ * @return a map of (key,value) pairs that should be added to the
+ * associated project template's value store.
+ */
Map/**/ getPageData();
+
+ /**
+ * Set the page that follows this one. Implementations must ensure
+ * {@link IWizardPage#getNextPage()} returns the specified value
+ * @param next
+ */
+ public void setNextPage(IWizardPage next);
}
diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java
index ccab0d912cc..2ba7c73e24b 100644
--- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java
+++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java
@@ -24,6 +24,7 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -66,6 +67,7 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage
private IWorkspaceRoot workspaceRoot;
private ICProject currentCProject;
+ private IWizardPage next;
public ProjectSelectionPage() {
super(PAGE_NAME);
@@ -326,5 +328,24 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage
return (ICProject) dialog.getFirstResult();
}
return null;
- }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.templateengine.IWizardDataPage#setNextPage(org.eclipse.jface.wizard.IWizardPage)
+ */
+ public void setNextPage(IWizardPage next) {
+ this.next= next;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#getNextPage()
+ */
+ public IWizardPage getNextPage() {
+ if(next != null) {
+ return next;
+ }
+ return super.getNextPage();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/Template.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/Template.java
index 94cde9ebb5a..ddb3bda07d5 100644
--- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/Template.java
+++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/Template.java
@@ -12,7 +12,6 @@ package org.eclipse.cdt.ui.templateengine;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -20,9 +19,12 @@ import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.w3c.dom.Element;
@@ -111,43 +113,43 @@ public class Template extends TemplateCore {
page.setWizard(wizard);
prevPage = page;
}
-
- try {
- IWizardDataPage[] extraPages = getExtraCreatedPages((IWorkbenchWizard)wizard);
- for (int i=0; i < extraPages.length; i++) {
- IWizardDataPage page = extraPages[i];
- pages.add(page);
- page.setPreviousPage(prevPage);
- //TODO: set the next page for page
- //page.setNextPage(extraPages[i+1]);
- page.setWizard(wizard);
- prevPage = page;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- followingPage.setPreviousPage(prevPage);
- } else {
- followingPage.setPreviousPage(predatingPage);
+ predatingPage= prevPage;
}
-// pages.add(followingPage);
+ try {
+ IWizardPage prevPage = predatingPage;
+ IWizardDataPage[] extraPages = getExtraCreatedPages((IWorkbenchWizard)wizard, PlatformUI.getWorkbench(), null);
+ for (int i=0; i < extraPages.length; i++) {
+ IWizardDataPage page = extraPages[i];
+ pages.add(page);
+ page.setPreviousPage(prevPage);
+
+ if(prevPage instanceof IWizardDataPage) {
+ ((IWizardDataPage)prevPage).setNextPage(page);
+ }
+
+ page.setWizard(wizard);
+ prevPage = page;
+ }
+
+ if(prevPage instanceof IWizardDataPage) {
+ ((IWizardDataPage)prevPage).setNextPage(followingPage);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ followingPage.setPreviousPage(predatingPage);
return (IWizardPage[]) pages.toArray(new IWizardPage[pages.size()]);
}
- IWizardDataPage[] getExtraCreatedPages(IWorkbenchWizard wizard) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+ IWizardDataPage[] getExtraCreatedPages(IWorkbenchWizard wizard, IWorkbench workbench, IStructuredSelection selection) {
TemplateInfo templateInfo = getTemplateInfo();
- String pagesProvider = templateInfo.getExtraPagesProvider();
- if (pagesProvider != null) {
- IPagesAfterTemplateSelectionProvider extraPagesProvider = (IPagesAfterTemplateSelectionProvider) Class.forName(pagesProvider).newInstance();
- if (extraPagesProvider != null) {
- List/**/ pageList = new ArrayList/**/();
- IWizardDataPage[] extraPages = extraPagesProvider.getCreatedPages(wizard);
- pageList.addAll(Arrays.asList(extraPages));
- return (IWizardDataPage[]) pageList.toArray(new IWizardDataPage[pageList.size()]);
- }
+ IPagesAfterTemplateSelectionProvider extraPagesProvider = (IPagesAfterTemplateSelectionProvider) templateInfo.getExtraPagesProvider();
+ if (extraPagesProvider != null) {
+ return extraPagesProvider.createAdditionalPages(wizard, null, null);
}
return new IWizardDataPage[0];
}
@@ -203,5 +205,4 @@ public class Template extends TemplateCore {
}
return result[0];
}
-
}
diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java
index 0c1275e8b16..0877948fc58 100644
--- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java
+++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java
@@ -85,30 +85,24 @@ public abstract class TemplatesChoiceWizard extends Wizard implements ITemplates
IWizardDataPage[] getPagesAfterTemplateSelectionWithExtraPages(Template template) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
IWizardDataPage[] pages = getPagesAfterTemplateSelection();
TemplateInfo templateInfo = template.getTemplateInfo();
- String pagesProvider = templateInfo.getExtraPagesProvider();
- if (pagesProvider != null) {
- IPagesAfterTemplateSelectionProvider extraPagesProvider = (IPagesAfterTemplateSelectionProvider) Class.forName(pagesProvider).newInstance();
- if (extraPagesProvider != null) {
- List/**/ pageList = new ArrayList/**/(Arrays.asList(pages));
- IWizardDataPage[] extraPages = extraPagesProvider.createAdditionalPages(this, workbench, selection);
- pageList.addAll(Arrays.asList(extraPages));
- pages = (IWizardDataPage[]) pageList.toArray(new IWizardDataPage[pageList.size()]);
- }
+ IPagesAfterTemplateSelectionProvider extraPagesProvider = (IPagesAfterTemplateSelectionProvider) templateInfo.getExtraPagesProvider();
+ if (extraPagesProvider != null) {
+ List/**/ pageList = new ArrayList/**/(Arrays.asList(pages));
+ IWizardDataPage[] extraPages = extraPagesProvider.createAdditionalPages(this, workbench, selection);
+ pageList.addAll(Arrays.asList(extraPages));
+ pages = (IWizardDataPage[]) pageList.toArray(new IWizardDataPage[pageList.size()]);
}
return pages;
}
IWizardDataPage[] getExtraCreatedPages(Template template) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
TemplateInfo templateInfo = template.getTemplateInfo();
- String pagesProvider = templateInfo.getExtraPagesProvider();
- if (pagesProvider != null) {
- IPagesAfterTemplateSelectionProvider extraPagesProvider = (IPagesAfterTemplateSelectionProvider) Class.forName(pagesProvider).newInstance();
- if (extraPagesProvider != null) {
- List/**/ pageList = new ArrayList/**/();
- IWizardDataPage[] extraPages = extraPagesProvider.getCreatedPages(this);
- pageList.addAll(Arrays.asList(extraPages));
- return (IWizardDataPage[]) pageList.toArray(new IWizardDataPage[pageList.size()]);
- }
+ IPagesAfterTemplateSelectionProvider extraPagesProvider = (IPagesAfterTemplateSelectionProvider) templateInfo.getExtraPagesProvider();
+ if (extraPagesProvider != null) {
+ List/**/ pageList = new ArrayList/**/();
+ IWizardDataPage[] extraPages = extraPagesProvider.getCreatedPages(this);
+ pageList.addAll(Arrays.asList(extraPages));
+ return (IWizardDataPage[]) pageList.toArray(new IWizardDataPage[pageList.size()]);
}
return new IWizardDataPage[0];
}
diff --git a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java
index 3722597ad26..5ac61dc3ea9 100644
--- a/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java
+++ b/core/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java
@@ -15,6 +15,7 @@ import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -24,15 +25,17 @@ import org.eclipse.cdt.ui.templateengine.IWizardDataPage;
* The first page in a NewProjectWizard. This is the wizard page that
* asks the user for the name and location of the new project.
*/
-public class NewProjectCreationPage extends WizardNewProjectCreationPage implements IWizardDataPage {
- private Map data = new HashMap(2);
-
+public class NewProjectCreationPage extends WizardNewProjectCreationPage implements IWizardDataPage {
private static final String ERROR_SUFFIX = Messages.getString("NewProjectCreationPage.0"); //$NON-NLS-1$
private static final String ERROR_SUFFIX_TOO_LONG = Messages.getString("NewProjectCreationPage.1"); //$NON-NLS-1$
private static final Status OK_STATUS = new Status(IStatus.OK, CUIPlugin.getPluginId(), 0, "", null); //$NON-NLS-1$
+ private Map data;
+ private IWizardPage next;
+
public NewProjectCreationPage(String name) {
super(name);
+ data= new HashMap();
this.setDescription(Messages.getString("NewProjectCreationPage.3")); //$NON-NLS-1$
}
@@ -106,4 +109,22 @@ public class NewProjectCreationPage extends WizardNewProjectCreationPage impleme
return OK_STATUS;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.ui.templateengine.IWizardDataPage#setNextPage(org.eclipse.jface.wizard.IWizardPage)
+ */
+ public void setNextPage(IWizardPage next) {
+ this.next= next;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#getNextPage()
+ */
+ public IWizardPage getNextPage() {
+ if(next != null) {
+ return next;
+ }
+ return super.getNextPage();
+ }
}