package net.sourceforge.phpeclipse.wizards;
import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
import net.sourceforge.phpdt.core.JavaCore;
import net.sourceforge.phpdt.ui.actions.OpenPHPPerspectiveAction;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
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;
remainingWorkUnits);
IWorkspace workspace = PHPeclipsePlugin.getWorkspace();
- newProject = projectPage.getProjectHandle();
-
+ String projectName = projectPage.getProjectHandle().getName();
+ newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
IProjectDescription description = workspace
- .newProjectDescription(newProject.getName());
- IPath path = Platform.getLocation();
- IPath customPath = projectPage.getLocationPath();
- if (!path.equals(customPath)) {
- path = customPath;
- description.setLocation(path);
+ .newProjectDescription(projectName);
+
+ URI uriPath = (!projectPage.useDefaults()) ? projectPage
+ .getLocationURI() : null;
+ if (uriPath != null) {
+ description.setLocationURI(uriPath);
}
try {
remainingWorkUnits--;
}
if (!newProject.isOpen()) {
- newProject.open(new SubProgressMonitor(monitor, 1));
+ newProject.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 1));
remainingWorkUnits--;
}
JavaCore.addPHPNature(newProject, new SubProgressMonitor(
monitor, remainingWorkUnits));
+
} catch (CoreException e) {
+ System.out.println(e);
throw new InvocationTargetException(e);
} finally {
monitor.done();