在Eclipse插件开发中,我如何以编程方式激活视图?

时间:2022-09-11 19:21:56

I have a tree view that is acting as a selection provider. In response to different types of selected items I would like to show a view. (Instantiate it is needed).

我有一个树视图作为选择提供者。为了回应不同类型的选定项目,我想展示一个视图。 (需要实例化)。

Can I do this by VIEW_ID and the workbench getViewRegistry?

我可以通过VIEW_ID和工作台getViewRegistry来做到这一点吗?

1 个解决方案

#1


The basic technique is described best by the article
"Make your Eclipse applications richer with view linking",
based on a "selection provider-selection listener" pattern, which is a handy way to create views that respond to changes in other views, updated now with the Selection Service.

基于“选择提供者 - 选择监听器”模式的文章“使您的Eclipse应用程序更富有视图链接”这一基本技术得到了最好的描述,这是一种创建视图以响应其他视图中的更改的便捷方法,现在更新与选择服务。

Something like:

IViewRegistry viewRegistry = this.getWorkbenchWindow().getWorkbench().getViewRegistry();
IViewDescriptor desc = viewRegistry.find(VIEW_ID);
window.getActivePage().showView(VIEW_ID);

should be able to open/create the view

应该能够打开/创建视图

#1


The basic technique is described best by the article
"Make your Eclipse applications richer with view linking",
based on a "selection provider-selection listener" pattern, which is a handy way to create views that respond to changes in other views, updated now with the Selection Service.

基于“选择提供者 - 选择监听器”模式的文章“使您的Eclipse应用程序更富有视图链接”这一基本技术得到了最好的描述,这是一种创建视图以响应其他视图中的更改的便捷方法,现在更新与选择服务。

Something like:

IViewRegistry viewRegistry = this.getWorkbenchWindow().getWorkbench().getViewRegistry();
IViewDescriptor desc = viewRegistry.find(VIEW_ID);
window.getActivePage().showView(VIEW_ID);

should be able to open/create the view

应该能够打开/创建视图