Getting IProject instance associated to a Diagram [message #754490] |
Wed, 02 November 2011 17:55 |
Julien Delange Messages: 82 Registered: October 2011 |
Member |
|
|
Dear all,
I'm looking for a method to retrieve the current project using different resources. If I found methods for a text file, I don't find how to do using a diagram. In particular, when I get the diagram object from the current editor, I would like to retrieve the associated IProject object (and so, all its related information, path, etc ...).
I look at available methods in the Diagram object but didn't find any relevant information. Is there a specific method to do so ?
Thanks for any help,
Best,
|
|
|
Re: Getting IProject instance associated to a Diagram [message #754530 is a reply to message #754490] |
Thu, 03 November 2011 00:18 |
Hernan Gonzalez Messages: 188 Registered: October 2010 Location: Buenos Aires, Argentina |
Senior Member |
|
|
Hi Julien. A Diagram doesn't know about a IProject, because a Diagram is not related to Eclipse workbench concepts (you could have a Diagram that is instantiated outside an Eclipse workbench environment). Even inside Eclipse, I Diagram could be instantiated from outside a Project (or even from several projects!).
That would be rather an Editor task: your (Eclipse) editor has an Diagram and it might know from where it opened it (though, again, this could vary, this is dictated not Graphiti ). A possible way, assuming that you opened your diagram from a file inside some eclipse project, is to get the editor input and try to "adapt" to an IFile (editor.getEditorInput().adapt(IFile.class)) and, if that works, ask the Ifile for its iproject. A less clean way is to get the URI for the diagram and try to deduce from it the Project.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04592 seconds