public static void createProject(IProject project, URI locationURI, IProgressMonitor monitor) throws CoreException { if (monitor == null) { monitor= new NullProgressMonitor(); } monitor.beginTask(NewWizardMessages.BuildPathsBlock_operationdesc_project, 10); // create the project try { if (!project.exists()) { IProjectDescription desc= project.getWorkspace().newProjectDescription(project.getName()); if (locationURI != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(locationURI)) { locationURI= null; } desc.setLocationURI(locationURI); project.create(desc, monitor); monitor= null; } if (!project.isOpen()) { project.open(monitor); monitor= null; } } finally { if (monitor != null) { monitor.done(); } } }
public static void createProject(IProject project, URI locationURI, IProgressMonitor monitor) throws CoreException { if (monitor == null) { monitor= new NullProgressMonitor(); } monitor.beginTask(NewWizardMessages.BuildPathsBlock_operationdesc_project, 10); // create the project try { if (!project.exists()) { IProjectDescription desc= project.getWorkspace().newProjectDescription(project.getName()); if (locationURI != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(locationURI)) { locationURI= null; } desc.setLocationURI(locationURI); project.create(desc, monitor); monitor= null; } if (!project.isOpen()) { project.open(monitor); monitor= null; } } finally { if (monitor != null) { monitor.done(); } } }
public static void createProject(IProject project, URI locationURI, IProgressMonitor monitor) throws CoreException { if (monitor == null) { monitor= new NullProgressMonitor(); } monitor.beginTask(NewWizardMessages.BuildPathsBlock_operationdesc_project, 10); // create the project try { if (!project.exists()) { IProjectDescription desc= project.getWorkspace().newProjectDescription(project.getName()); if (locationURI != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(locationURI)) { locationURI= null; } desc.setLocationURI(locationURI); project.create(desc, monitor); monitor= null; } if (!project.isOpen()) { project.open(monitor); monitor= null; } } finally { if (monitor != null) { monitor.done(); } } }
public static void checkout(ICheckoutSource checkoutSource, String projectName, IProgressMonitor monitor) throws Exception { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); IProject project = root.getProject(projectName); if (project.exists()) { throw new IOException("Project " + projectName + " already exists"); } File projectFolder = root.getLocation().append(projectName).toFile(); URI uri = checkout(checkoutSource, projectName, projectFolder); IProjectDescription description = workspace.newProjectDescription(projectName); description.setLocationURI(uri); project.create(description, new NullProgressMonitor()); if (!project.isOpen()) { project.open(new NullProgressMonitor()); } }
URI moveProject(IProject project, URI locationURI, IProgressMonitor monitor) throws CoreException { monitor .setTaskName(UndoMessages.AbstractCopyOrMoveResourcesOperation_moveProjectProgress); IProjectDescription description = project.getDescription(); // Record the original path so this can be undone URI newDestinationURI = description.getLocationURI(); // Set the new location into the project's description description.setLocationURI(locationURI); project.move(description, IResource.FORCE | IResource.SHALLOW, monitor); // Now adjust the projectLocation so this can be undone/redone. return newDestinationURI; }
bareProjectHandle.getWorkspace().newProjectDescription("TestProject"); description.setLocationURI(bareProjectHandle.getLocationURI() );
final IProjectDescription description = workspace .newProjectDescription(newProjectHandle.getName()); description.setLocationURI(location);
IProject copyProject(IProject project, IPath destinationPath, URI locationURI, IProgressMonitor monitor) throws CoreException { monitor.setTaskName(UndoMessages.AbstractCopyOrMoveResourcesOperation_copyProjectProgress); boolean open = project.isOpen(); if (!open) { // Must open project in order to get the original project // description for performing the undo. project.open(null); } originalProjectDescription = new ProjectDescription(project); IProjectDescription description = project.getDescription(); // Set the new name and location into the project's description description.setName(destinationPath.lastSegment()); description.setLocationURI(locationURI); project.copy(description, IResource.FORCE | IResource.SHALLOW, monitor); // Close the original project if it was closed when we started. if (!open) { project.close(null); } // Now return the handle of the new project return (IProject) getWorkspace().getRoot().findMember(destinationPath); } }
if (projectLocationURI != null) projectDescription.setLocationURI(new java.net.URI(projectLocationURI.toString()));
if (projectLocationURI != null) projectDescription.setLocationURI(new java.net.URI(projectLocationURI.toString()));
/** * Create and open the described project, as necessary. * * @param description project description * @exception CoreException on failure */ private void createProject(IBundleProjectDescription description) throws CoreException { IProject project = description.getProject(); if (!project.exists()) { IProjectDescription pd = project.getWorkspace().newProjectDescription(project.getName()); pd.setLocationURI(description.getLocationURI()); project.create(pd, null); } if (!project.isOpen()) { project.open(null); } }