IPath workspaceLocation = workspace.getRoot().getRawLocation();
IPath location = new Path(newDir);
// if the new location overlaps the workspace, then set location to null
// to force eclipse to move the project to the default location in the
// workspace. Also, take the last segment as the new project name.
if (location.toOSString().toLowerCase().startsWith(
workspaceLocation.toOSString().toLowerCase()))
{
String name = location.removeFirstSegments(
location.matchingFirstSegments(workspaceLocation)).toString();
// hack for windows... manually remove drive letter