Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Renaming a project resource
Renaming a project resource [message #297313] Wed, 11 January 2006 17:39 Go to next message
Eclipse UserFriend
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at

Hi,

I want to rename a project resource (IProject). It tried IProject#move
and IProjectDescription#setName (retrieved via IProject#getDescription),
but neither works as expected: the project folder in the workspace is
renamed, but calling IProjectDescription#getName will still return the
old name. Plus, after renaming a project, I can't access its content
because the resource system still uses the old name (eg when I rename a
project from A to B and then want to add a file to B, I get an exception
telling me that 'Resource /A does not exist').

Can someone please give me direction how to correctly rename a project?

Thanks,
M
Re: Renaming a project resource [message #297317 is a reply to message #297313] Wed, 11 January 2006 21:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john.eclipsefaq.org

IProject#move(IProjectDescription, boolean, IProgressMonitor) is the
correct method. This will also change the description name. Note that
if you are renaming the project via #move, then the receiver no longer
refers to the existing project after the move. You need to get the
IProject handle for the destination project, and its description should
be as you expect.
--

martin wrote:
> Hi,
>
> I want to rename a project resource (IProject). It tried IProject#move
> and IProjectDescription#setName (retrieved via IProject#getDescription),
> but neither works as expected: the project folder in the workspace is
> renamed, but calling IProjectDescription#getName will still return the
> old name. Plus, after renaming a project, I can't access its content
> because the resource system still uses the old name (eg when I rename a
> project from A to B and then want to add a file to B, I get an exception
> telling me that 'Resource /A does not exist').
>
> Can someone please give me direction how to correctly rename a project?
>
> Thanks,
> M
Re: Renaming a project resource [message #297344 is a reply to message #297317] Thu, 12 January 2006 09:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at

John Arthorne wrote:
> IProject#move(IProjectDescription, boolean, IProgressMonitor) is the
> correct method. This will also change the description name. Note that
> if you are renaming the project via #move, then the receiver no longer
> refers to the existing project after the move. You need to get the
> IProject handle for the destination project, and its description should
> be as you expect.

Thanks a lot, works fine now :) Would be nice to find info like that in
the javadoc...

M
Re: Renaming a project resource [message #297390 is a reply to message #297344] Thu, 12 January 2006 16:34 Go to previous message
Eclipse UserFriend
Originally posted by: john.eclipsefaq.org

martin wrote:
> Thanks a lot, works fine now :) Would be nice to find info like that in
> the javadoc...

There are some comments to that effect in the IResource class comment,
saying they are handles represented by a path, but I suppose the comment
could be a bit clearer. This is just like java.io.File, whose renameTo
and other methods do not mutate the receiver.
--
Previous Topic:Eclipse Event Management
Next Topic:what does .snap file do?
Goto Forum:
  


Current Time: Tue Apr 23 09:09:20 GMT 2024

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

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

Back to the top