aspose file tools*
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Rename a file/folder (IResource)" Watch "Rename a file/folder (IResource)" New topic
Author

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.

TIA

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

Joined: May 09, 2002
Posts: 20
Hi

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 : http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JTree.html#setEditable(boolean)

Code example : http://www.java2s.com/Code/Java/Swing-JFC/FileSystemTree.htm


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

Joined: Oct 27, 2005
Posts: 19794
    
  20

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
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: http://aspose.com/file-tools
 
subject: Rename a file/folder (IResource)