package ilg.gnuarmeclipse.templates.freescale.pe.processes;

import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.wizards.IWizardDescriptor;

public class RunProcessorExpertWizard extends ProcessRunner {

	@Override
	public void process(TemplateCore template, ProcessArgument[] args,
			String processId, IProgressMonitor monitor)
			throws ProcessFailureException {

		System.out.println("ProcessorExpertWizard.process()");

		String id = "com.processorexpert.ui.pewizard.newprjwizard";

		IWizardDescriptor descriptor = PlatformUI.getWorkbench()
				.getNewWizardRegistry().findWizard(id);

		try {
			// Then if we have a wizard, open it.
			if (descriptor != null) {
				IWizard wizard = descriptor.createWizard();
				Display display = Display.getCurrent();

				WizardDialog wd = new WizardDialog(
						display.getActiveShell(), wizard);
				wd.setTitle(wizard.getWindowTitle());
				
				wd.open();
			}
		} catch (CoreException e) {
			e.printStackTrace();
		}
	}

}

@@ -855,16 +855,65 @@
 tion %7B%0A%0A
+%09%09String projectName = args%5B0%5D.getSimpleValue();%0A
 %09%09System
@@ -956,16 +956,45 @@
 process(
+projectName='%22+projectName+%22'
 )%22);%0A%0A%09%09
@@ -1329,16 +1329,225 @@
 ent();%0A%0A
+%09%09%09%09// We need a method to pass the project name to the wizard.%0A%09%09%09%09// This can be done either with a separate constructor or a %0A%09%09%09%09// new method, for example:%0A%09%09%09%09// wizard.setProjectName(projectName);%0A%09%09%09%09%0A
 %09%09%09%09Wiza

debug display the project name