mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 14:25:37 +02:00
Provide a New Wizard class for the Template Selection page.
Makes the TemplateWizard class now manditory as the parent for template wizards. Change-Id: I52ec2a1ba130ac00b9a0294bdd15beeff5ed2c1c
This commit is contained in:
parent
6848810854
commit
587cb567e9
3 changed files with 71 additions and 6 deletions
|
@ -85,7 +85,7 @@
|
|||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.ui.INewWizard"/>
|
||||
<meta.attribute kind="java" basedOn="org.eclipse.tools.templates.ui.TemplateWizard:"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue