package org.lamport.tla.toolbox.ui.wizard;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;

/**
 * A wizard for creation of new specifications
 * 
 * @author zambrovski
 */
public class NewSpecWizard extends Wizard implements INewWizard
{

    private IStructuredSelection selection;
    private NewSpecWizardPage page;

    private String specName;
	private String rootFilename;
	private boolean importExisting;
	private final String absolutePath;

	public NewSpecWizard(String absolutePath) {
		this.absolutePath = absolutePath;
	}

	/*
     * (non-Javadoc)
     * @see org.eclipse.jface.wizard.Wizard#performFinish()
     */
    public boolean performFinish()
    {

		// cache values now (won't be possible later from the page
		// due to widgets getting disposed of)
        rootFilename = page.getRootFilename();
        specName = page.getSpecName();
        importExisting = page.importExisting();

        return true;
    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
     * org.eclipse.jface.viewers.IStructuredSelection)
     */
    public void init(IWorkbench workbench, IStructuredSelection selection)
    {
        this.selection = selection;
    }

    /**
     * Adding the page to the wizard.
     */
    public void addPages()
    {
        page = new NewSpecWizardPage(this.absolutePath);
        addPage(page);
    }

    public ISelection getSelection()
    {
        return this.selection;
    }

	/**
	 * @return the specName
	 */
	public String getSpecName() {
		return specName;
	}

	/**
	 * @return the rootFilename
	 */
	public String getRootFilename() {
		return rootFilename;
	}

    /**
	 * @return the importExisting
	 */
	public boolean isImportExisting() {
		return importExisting;
	}
}

@@ -628,16 +628,63 @@
 ath;%0D%0A%0D%0A
+%09public NewSpecWizard() %7B%0D%0A%09%09this(%22%22);%0D%0A%09%7D%0D%0A%09%0D%0A
 %09public 

Allow new spec wizard to be opened from Eclipse's built-in (M1+N) creation wizard.