Hi all,
We'd like to reuse the javadoc and declaration view to display
javadoc/java source corresponding to an element in a configuration file
in one of the projects in the workspace.
We're able to get hold of the IJavaElement and are putting in this
reflection hack to update the javadoc/declaration view with the
IJavaElement.
Is there a better way to do this ? Does my editor need to publish
something that I should be ?
/**
* Shows the java element in view specified by viewId
*/
public void show(final IJavaElement element, String viewId){
// get hold of the view javadoc/declaration view
AbstractInfoView infoView = (AbstractInfoView)
workbenchPart.getSite().getPage().findView(viewId);
// get hold of the computeInput protected method, and invoke it.
// returns the text to be set into the view.
Method computeInput =
AbstractInfoView.class.getDeclaredMethod("computeInput", Object.class);
computeInput.setAccessible(true);
String source = (String) computeInput.invoke(infoView, element);
// set the IJavaElement into the view.
Field fCurrentViewInput =
AbstractInfoView.class.getDeclaredField("fCurrentViewInput");
fCurrentViewInput.setAccessible(true);
fCurrentViewInput.set(infoView, element);
// set the text into the view
Method doSetInput =
AbstractInfoView.class.getDeclaredMethod("doSetInput", Object.class);
doSetInput.setAccessible(true);
doSetInput.invoke(infoView, source);
}
Cheers,
Ketan Padegaonkar
I blog... therefore I am... http://ketan.padegaonkar.name/
http://swtbot.org
Slackware is not for you. You do not possess the Tao.
-- +Chiron+