views:

18

answers:

1

I have a basic GEF editor where I want to use the model from the currently open/selected java source editor to display extra information, but I can't figure out how to get access to java model from inside my editor.

Any ideas? I'm finding the Eclipse docs hard to navigate.

+1  A: 

It is a hard job, as using the GEF editor the current editor is the GEF editor, not the Java one.

If you have the IResource representing the Java file to display, you can use the static methods of the JavaCore class to get the Java Model.

How to get the IResource: maybe you can iterate over the open editors, and select their input, and check whether its an IFileInput, etc., or listen to selection changes in the Package Explorer.

Zoltán Ujhelyi
Yes. You probably want something like: ICompilationUnit icu = (ICompilationUnit) JavaCore.create(resource);
zvikico