--- /dev/null
+package net.sourceforge.phpeclipse.wiki.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+
+import net.sourceforge.phpeclipse.wiki.builder.AddBuilderAction;
+import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+public class NewProjectCreationWizard extends BasicNewResourceWizard implements INewWizard, IExecutableExtension {
+ protected WizardNewProjectCreationPage projectPage;
+
+ protected IConfigurationElement configurationElement;
+
+ protected IProject newProject;
+
+ public NewProjectCreationWizard() {
+ setWindowTitle(WizardMessages.getString("NewProjectCreationWizard.windowTitle"));
+ }
+
+ public boolean performFinish() {
+ IRunnableWithProgress projectCreationOperation = new WorkspaceModifyDelegatingOperation(getProjectCreationRunnable());
+
+ try {
+ getContainer().run(false, true, projectCreationOperation);
+ } catch (Exception e) {
+ WikiEditorPlugin.log(e);
+ return false;
+ }
+
+ BasicNewProjectResourceWizard.updatePerspective(configurationElement);
+ selectAndReveal(newProject);
+
+ return true;
+ }
+
+ protected IRunnableWithProgress getProjectCreationRunnable() {
+ return new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ int remainingWorkUnits = 10;
+ monitor.beginTask(WizardMessages.getString("NewProjectCreationWizard.projectCreationMessage"), remainingWorkUnits);
+
+ IWorkspace workspace = WikiEditorPlugin.getWorkspace();
+ newProject = projectPage.getProjectHandle();
+
+ IProjectDescription description = workspace.newProjectDescription(newProject.getName());
+ IPath path = Platform.getLocation();
+ IPath customPath = projectPage.getLocationPath();
+ if (!path.equals(customPath)) {
+ path = customPath;
+ description.setLocation(path);
+ }
+
+ try {
+ if (!newProject.exists()) {
+ newProject.create(description, new SubProgressMonitor(monitor, 1));
+ remainingWorkUnits--;
+ }
+ if (!newProject.isOpen()) {
+ newProject.open(new SubProgressMonitor(monitor, 1));
+ remainingWorkUnits--;
+ }
+// addWikipediaNature(newProject, new SubProgressMonitor(monitor, remainingWorkUnits));
+ AddBuilderAction.addBuilder(newProject);
+ }
+ catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+ }
+
+// public static void addWikipediaNature(IProject project, IProgressMonitor monitor) throws CoreException {
+// if (!project.hasNature(WikiEditorPlugin.NATURE_ID)) {
+// IProjectDescription description = project.getDescription();
+// String[] prevNatures = description.getNatureIds();
+// String[] newNatures = new String[prevNatures.length + 1];
+// System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+// newNatures[prevNatures.length] = WikiEditorPlugin.NATURE_ID;
+// description.setNatureIds(newNatures);
+// project.setDescription(description, monitor);
+// }
+// }
+
+ public void addPages() {
+ super.addPages();
+
+ projectPage = new WizardNewProjectCreationPage(WizardMessages.getString("WizardNewProjectCreationPage.pageName"));
+ projectPage.setTitle(WizardMessages.getString("WizardNewProjectCreationPage.pageTitle"));
+ projectPage.setDescription(WizardMessages.getString("WizardNewProjectCreationPage.pageDescription"));
+
+ addPage(projectPage);
+ }
+
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ configurationElement = config;
+ }
+
+}
\ No newline at end of file