Getting the content of a view Eclipse RCP

2019-08-03 02:05发布

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条回答
\"骚年 ilove
2楼-- · 2019-08-03 02:55

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
}
查看更多
登录 后发表回答