Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rename a file/folder (IResource)

 
Dinesh Bang
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nandkishore Dhilde
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except this isn't about Swing but JFace / EMF.
 
Dinesh Bang
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Nandkishore,

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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic