diff --git a/bundles/org.eclipse.tools.templates.ui/schema/templates.exsd b/bundles/org.eclipse.tools.templates.ui/schema/templates.exsd index bc058d85e72..52cdbd5c71b 100644 --- a/bundles/org.eclipse.tools.templates.ui/schema/templates.exsd +++ b/bundles/org.eclipse.tools.templates.ui/schema/templates.exsd @@ -85,7 +85,7 @@ - + diff --git a/bundles/org.eclipse.tools.templates.ui/src/org/eclipse/tools/templates/ui/NewWizard.java b/bundles/org.eclipse.tools.templates.ui/src/org/eclipse/tools/templates/ui/NewWizard.java new file mode 100644 index 00000000000..b6b7739487f --- /dev/null +++ b/bundles/org.eclipse.tools.templates.ui/src/org/eclipse/tools/templates/ui/NewWizard.java @@ -0,0 +1,67 @@ +package org.eclipse.tools.templates.ui; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; + +/** + * Wizard to be used to launch the template selection page. + */ +public class NewWizard extends Wizard implements INewWizard { + + private final String[] tags; + + private String templateSelectionPageTitle; + private IWorkbench workbench; + private IStructuredSelection selection; + private TemplateSelectionPage templateSelectionPage; + + protected NewWizard(String... tags) { + this.tags = tags; + setForcePreviousAndNextButtons(true); + } + + protected void setTemplateSelectionPageTitle(String title) { + this.templateSelectionPageTitle = title; + if (templateSelectionPage != null) { + templateSelectionPage.setTitle(title); + } + } + + @Override + public void addPages() { + templateSelectionPage = new TemplateSelectionPage("templateSelection", tags); //$NON-NLS-1$ + templateSelectionPage.setTitle(templateSelectionPageTitle); + this.addPage(templateSelectionPage); + } + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.workbench = workbench; + this.selection = selection; + } + + /** + * Initialize the template wizard that comes next. + * + * @param nextWizard + * the next wizard to show + */ + public void initialize(INewWizard nextWizard) { + nextWizard.init(workbench, selection); + } + + @Override + public boolean canFinish() { + // Need to check with the template wizard + return false; + } + + @Override + public boolean performFinish() { + // The template wizard will do the real finish. + return true; + } + +} diff --git a/bundles/org.eclipse.tools.templates.ui/src/org/eclipse/tools/templates/ui/TemplateSelectionPage.java b/bundles/org.eclipse.tools.templates.ui/src/org/eclipse/tools/templates/ui/TemplateSelectionPage.java index fd02ca7df49..da1edbc7856 100644 --- a/bundles/org.eclipse.tools.templates.ui/src/org/eclipse/tools/templates/ui/TemplateSelectionPage.java +++ b/bundles/org.eclipse.tools.templates.ui/src/org/eclipse/tools/templates/ui/TemplateSelectionPage.java @@ -29,8 +29,6 @@ import org.eclipse.tools.templates.ui.internal.TagListViewer; import org.eclipse.tools.templates.ui.internal.Template; import org.eclipse.tools.templates.ui.internal.TemplateExtension; import org.eclipse.tools.templates.ui.internal.TemplateTable; -import org.eclipse.ui.IWorkbenchWizard; -import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; public class TemplateSelectionPage extends WizardPage { @@ -99,9 +97,9 @@ public class TemplateSelectionPage extends WizardPage { Template template = templateTable.getSelectedTemplate(); if (template != null) { try { - IWorkbenchWizard nextWizard = template.getWizard(); - BasicNewResourceWizard oldWizard = (BasicNewResourceWizard) getWizard(); - nextWizard.init(oldWizard.getWorkbench(), oldWizard.getSelection()); + NewWizard oldWizard = (NewWizard) getWizard(); + TemplateWizard nextWizard = (TemplateWizard) template.getWizard(); + oldWizard.initialize(nextWizard); nextWizard.addPages(); return nextWizard.getPages()[0]; } catch (CoreException e) {