I'm developing an Eclipse Plug-in.
I need to programmatically get both filepath and filename of the selected/active file in the eclipse editor.
Also need to programmatically add an existing file (located outside the project) to the project and then open it on the editor.
I'm a totally beginner with Eclipse, so complete solution would be appreciated.
How to programmatically get information in Eclipse
792 views Asked by Crazy Ivan At
3
There are 3 answers
0
On
You question is quite general, but this should clear things up a bit:
Eclipse Plugin Development Tutorial
About adding a file to the project, you have to read the documentation and find where eclipse handles projects. I think that if you have a reference to the project it should be easy.
Hope it helps =)
3
On
Your editor is most likely inheriting from IEditorPart
, so you should be able to call getEditorInput()
, which then may or may not turn out to be a FileEditorInput
, for example. From there, you can get at the underlying details of the file.
For your second problem, you can use IProject.create()
and then e.g. do an IFile.createLink()
and use a local filesystem path, or copy the file using IFile.appendContents()
.
Have you tried the solution proposed in http://www.eclipse.org/forums/index.php/mv/msg/97927/300308/#msg_300308?