Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to rename project on the disk programatically
How to rename project on the disk programatically [message #1743553] Fri, 16 September 2016 10:18 Go to next message
Nemanja Bjelica is currently offline Nemanja BjelicaFriend
Messages: 14
Registered: October 2015
Junior Member
Hi all,

I was wondering how to rename IProject programatically? I'm using

resource.move(newPath, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());

to rename all IResources, but only IProject does not rename itself on the disk, just the .project file. Is there any other method to do renaming?

Thanks in advance!
Re: How to rename project on the disk programatically [message #1743600 is a reply to message #1743553] Fri, 16 September 2016 18:16 Go to previous messageGo to next message
Eclipse UserFriend
Is the project in the workspace, or outside of the workspace?

(Wondering if it's similar to https://bugs.eclipse.org/bugs/show_bug.cgi?id=39453)
Re: How to rename project on the disk programatically [message #1743705 is a reply to message #1743600] Mon, 19 September 2016 07:02 Go to previous messageGo to next message
Nemanja Bjelica is currently offline Nemanja BjelicaFriend
Messages: 14
Registered: October 2015
Junior Member
Yes, it's outside the workspace. Is there anything I can do?

[Updated on: Mon, 19 September 2016 09:19]

Report message to a moderator

Re: How to rename project on the disk programatically [message #1744020 is a reply to message #1743705] Wed, 21 September 2016 13:29 Go to previous message
Nemanja Bjelica is currently offline Nemanja BjelicaFriend
Messages: 14
Registered: October 2015
Junior Member
I've managed to do it using this code.

 final IPath newWorkspacePath = resource.getFullPath().removeLastSegments(1).append(newName);
            final IPath newProjectPath = resource.getRawLocation().removeLastSegments(1).append(newName);
            final IProject project = resource.getProject();
            
	try {
		final IProjectDescription description = project.getDescription();
                description.setName(newName);
                description.setLocation(newProjectPath);
		project.move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
		return ResourcesPlugin.getWorkspace().getRoot().findMember(newWorkspacePath);
	} catch (final CoreException e) {
			return null;
	}
Previous Topic:Associating a Perspective with a File Type
Next Topic:Conflicts between identical handlers in Eclipse RCP
Goto Forum:
  


Current Time: Sat Apr 20 03:05:36 GMT 2024

Powered by FUDForum. Page generated in 0.03321 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top