如何在Eclipse RCP中的视图之间进行通信? [英] How to communicate between views in Eclipse RCP?

查看:93
本文介绍了如何在Eclipse RCP中的视图之间进行通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Eclipse RCP中,我使用为视图创建视图IPageLayout.addView(...)

In Eclipse RCP, I am creating views for the Perspective using IPageLayout.addView(...)

但是这种方式我没有对视图的引用。因此,我不知道如何告诉ViewA更新ViewB。

But this way I don't have a reference to the view. Therefore I don't know how I can tell ViewA to update ViewB.

这里使用的最佳模式是什么?

What's the best pattern to use here?

推荐答案

除了上面提到的VonC之外,如果您所需的更改不是由选择触发的,您还可以使用 ISourceProviderListener

Besides what VonC has mentioned above, you can also use ISourceProviderListener if the changes you need are not triggered by selection.


  • 拥有 ViewB 实现 ISourceProviderListener

  • 创建 ISourceProvider 的实现并在服务中注册

  • 拥有 ViewA 获取 ISourceProvider 并更新它以触发 ViewB

  • Have ViewB implements ISourceProviderListener
  • Create an implementation of ISourceProvider and register it in the services
  • Have ViewA get the ISourceProvider and update it to trigger the changes in ViewB

阅读这些界面上的文档以及 IServiceLocator ISourceProviderService 更好地了解它是如何发挥作用的。

Read the documentation on those interfaces along with IServiceLocator and ISourceProviderService to get better idea how it all plays out.

您还可以看到这个Lars Vogel的教程,其中有一些示例如何使用 ISourceProvider

You can also see this Lars Vogel's tutorial which has some example how to use the ISourceProvider

这篇关于如何在Eclipse RCP中的视图之间进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆