如何在Eclipse RCP中的视图之间进行通信? [英] How to communicate between views in 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
implementsISourceProviderListener
- Create an implementation of
ISourceProvider
and register it in the services - Have
ViewA
get theISourceProvider
and update it to trigger the changes inViewB
阅读这些界面上的文档以及 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屋!