Win a copy of Functional Reactive Programming this week in the Other Languages 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: 20665
65
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