Java Code Examples for org.eclipse.core.resources.IProjectDescription#setName()
The following examples show how to use
org.eclipse.core.resources.IProjectDescription#setName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceHelper.java From tlaplus with MIT License | 6 votes |
/** * Renames and moves the project, but does not delete the old project. It's * the callee's reponsibility. * * @param project * @param aNewName */ public static IProject projectRename(final IProject project, final String aNewName, final IProgressMonitor aMonitor) { try { // move the project location to the new location and name final IProjectDescription description = project.getDescription(); final IPath basePath = description.getLocation().removeLastSegments(1).removeTrailingSeparator(); final IPath newPath = basePath.append(aNewName.concat(TOOLBOX_DIRECTORY_SUFFIX)).addTrailingSeparator(); description.setLocation(newPath); description.setName(aNewName); // refresh the project prior to moving to make sure the fs and resource fw are in sync project.refreshLocal(IResource.DEPTH_INFINITE, aMonitor); project.copy(description, IResource.NONE | IResource.SHALLOW, aMonitor); return ResourcesPlugin.getWorkspace().getRoot().getProject(aNewName); } catch (CoreException e) { Activator.getDefault().logError("Error renaming a specification", e); } return null; }
Example 2
Source File: SVNProjectSetCapability.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Creates a new project in the workbench from an existing one * * @param monitor * @throws CoreException */ void createExistingProject(IProgressMonitor monitor) throws CoreException { String projectName = project.getName(); IProjectDescription description; try { monitor.beginTask("Creating " + projectName, 2 * 1000); description = ResourcesPlugin.getWorkspace() .loadProjectDescription( new Path(directory + File.separatorChar + ".project")); //$NON-NLS-1$ description.setName(projectName); project.create(description, new SubProgressMonitor(monitor, 1000)); project.open(new SubProgressMonitor(monitor, 1000)); } finally { monitor.done(); } }
Example 3
Source File: RenameJavaProjectChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void doRename(IProgressMonitor pm) throws CoreException { try { pm.beginTask(getName(), 2); if (fUpdateReferences) modifyClassPaths(new SubProgressMonitor(pm, 1)); IProject project= getProject(); if (project != null) { IProjectDescription description= project.getDescription(); description.setName(getNewName()); project.move(description, IResource.FORCE | IResource.SHALLOW, new SubProgressMonitor(pm, 1)); } } finally { pm.done(); } }
Example 4
Source File: EclipseProjectImporter.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void importDir(java.nio.file.Path dir, IProgressMonitor m) { SubMonitor monitor = SubMonitor.convert(m, 4); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IPath dotProjectPath = new Path(dir.resolve(DESCRIPTION_FILE_NAME).toAbsolutePath().toString()); IProjectDescription descriptor; try { descriptor = workspace.loadProjectDescription(dotProjectPath); String name = descriptor.getName(); if (!descriptor.hasNature(JavaCore.NATURE_ID)) { return; } IProject project = workspace.getRoot().getProject(name); if (project.exists()) { IPath existingProjectPath = project.getLocation(); existingProjectPath = fixDevice(existingProjectPath); dotProjectPath = fixDevice(dotProjectPath); if (existingProjectPath.equals(dotProjectPath.removeLastSegments(1))) { project.open(IResource.NONE, monitor.newChild(1)); project.refreshLocal(IResource.DEPTH_INFINITE, monitor.newChild(1)); return; } else { project = findUniqueProject(workspace, name); descriptor.setName(project.getName()); } } project.create(descriptor, monitor.newChild(1)); project.open(IResource.NONE, monitor.newChild(1)); } catch (CoreException e) { JavaLanguageServerPlugin.log(e.getStatus()); throw new RuntimeException(e); } finally { monitor.done(); } }
Example 5
Source File: ProjectImporter.java From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 | 3 votes |
/** * Imports a project into workspace. * https://www.eclipse.org/forums/index.php/t/560903/ * * @param projectFile * The project file to be imported. * @param projectName * The project name that will be used to create the project * @throws CoreException * Project cannot be created: if this method fails. Reasons include: * - This project already exists in the workspace. - The name of * this resource is not valid (according to * IWorkspace.validateName). - The project location is not valid * (according to IWorkspace.validateProjectLocation). - The project * description file could not be created in the project content * area. - Resource changes are disallowed during certain types of * resource change event notification. See IResourceChangeEvent for * more details. .project file has troubles. Reasons include: - The * project description file does not exist. - The file cannot be * opened or read. - The file cannot be parsed as a legal project * description. or during opening - Resource changes are disallowed * during certain types of resource change event notification. See * IResourceChangeEvent for more details. */ public static void importProject(final Path projectFile, final String projectName) throws CoreException { IProjectDescription description = ResourcesPlugin.getWorkspace() .loadProjectDescription(new org.eclipse.core.runtime.Path(projectFile.toFile().getAbsolutePath())); description.setName(projectName); create(description, projectName); }