问题
How can I get the content of a specific view ? For instance, I want to get the size of a table in a view. I only have the view ID wanted and more globally the workbench. I cannot modify the original RCP project.
Thanks
回答1:
You can use org.eclipse.ui.IWorkbenchPage.findView(String) to return the IViewPart (the instance of the contributed object that created that view). From there, you would have to know and have access to the class and internals to get ahold of their Tree object:
IViewPart part = workbench.getActiveWorkbenchWindow().getActivePage()
.findView(MyView.ID);
if (part instanceof MyView) {
MyView view = (MyView) part;
// now access whatever internals you can get to
}
来源:https://stackoverflow.com/questions/17151277/getting-the-content-of-a-view-eclipse-rcp