File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Rename a file/folder (IResource) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Rename a file/folder (IResource)" Watch "Rename a file/folder (IResource)" New topic

Rename a file/folder (IResource)

Dinesh Bang
Ranch Hand

Joined: Jun 15, 2006
Posts: 52
Hi Ranchers,

I have view which displays files/ folders present in workspace. I have to add a "Rename" action on right click after selecting the resource.
Is there some jface or EMF commands to do it.
I found org.eclipse.ui.actions.RenameResourceAction , but not sure how to use it.


SCJP 1.4,SCBCD 1.3, SCWCD 1.5, ???
Nandkishore Dhilde

Joined: May 09, 2002
Posts: 20

If you are using javax.swing.JTree for displaying File Tree then you can use its jTree.setEditable(true) .. which adds listner to rename file and folder. After setting this true you dont have to do much, by double clicking on file/folder name, it allows rename it just like windows explorer

Ref :

Code example :

SCJP1.4 certified, IBM SOA Solution Designer[2007]
Rob Spoor

Joined: Oct 27, 2005
Posts: 19718

Except this isn't about Swing but JFace / EMF.

How To Ask Questions How To Answer Questions
Dinesh Bang
Ranch Hand

Joined: Jun 15, 2006
Posts: 52
Hey Nandkishore,

I wasn't properly using the run method inside org.eclipse.ui.actions.RenameResourceAction. Thus it was failing.
Got the way out.

I agree. Here's the link:
subject: Rename a file/folder (IResource)